
org.visallo.web.parameterProviders.SourceGuidParameterProviderFactory Maven / Gradle / Ivy
package org.visallo.web.parameterProviders;
import com.google.inject.Inject;
import com.v5analytics.webster.HandlerChain;
import com.v5analytics.webster.parameterProviders.ParameterProvider;
import com.v5analytics.webster.parameterProviders.ParameterProviderFactory;
import org.visallo.core.config.Configuration;
import org.visallo.core.model.user.UserRepository;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Source;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import static com.google.common.base.Preconditions.checkNotNull;
public class SourceGuidParameterProviderFactory extends ParameterProviderFactory {
private final ParameterProvider parameterProvider;
@Inject
public SourceGuidParameterProviderFactory(UserRepository userRepository, Configuration configuration) {
parameterProvider = new VisalloBaseParameterProvider(userRepository, configuration) {
@Override
public String getParameter(HttpServletRequest request, HttpServletResponse response, HandlerChain chain) {
return getSourceGuid(request);
}
};
}
@Override
public boolean isHandled(Method handleMethod, Class extends String> parameterType, Annotation[] parameterAnnotations) {
return getSourceGuidAnnotation(parameterAnnotations) != null;
}
@Override
public ParameterProvider createParameterProvider(Method handleMethod, Class> parameterType, Annotation[] parameterAnnotations) {
return parameterProvider;
}
private static SourceGuid getSourceGuidAnnotation(Annotation[] annotations) {
for (Annotation annotation : annotations) {
if (annotation instanceof SourceGuid) {
return (SourceGuid) annotation;
}
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy