Import configuration code from Bartlomiej Superson.
git-svn-id: https://svn.apache.org/repos/asf/manifoldcf/integration/elasticsearch-1.5/trunk@1688628 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerRestSearchAction.java b/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerRestSearchAction.java
index 138c1d6..583f95a 100644
--- a/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerRestSearchAction.java
+++ b/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerRestSearchAction.java
@@ -54,16 +54,6 @@
import java.util.List;
import java.util.Map;
- /*
- New parseSearchRequestMCF function added in utils to parse RestRequest.
- There are also problems with security using JavaSearchAPI, because it doesn't implements setParam function
- to set username param, but this can be ommited using JavaScriptAPI, which allows to do that.
- Security filter can be also applied in this class but there is a problem with proper extraSource parsing.
- There is also a possibility to create service, inject RestController into it, register RestFilter in it, which
- should be used only if request handled by RestSearchAction and replace query from this request with
- the same query wrapped by security filter.
- */
-
public class MCFAuthorizerRestSearchAction extends RestSearchAction {
protected final MCFAuthorizer authorizer;
@@ -71,9 +61,7 @@
@Inject
public MCFAuthorizerRestSearchAction(Settings settings, final RestController restController, Client client) {
super(settings,restController,client);
- // Set up MCFConfigurationParameters instance from settings
- final MCFConfigurationParameters conf = new MCFConfigurationParameters();
- // MHL
+ final MCFConfigurationParameters conf = new MCFConfigurationParameters(settings);
authorizer = new MCFAuthorizer(conf);
}
@@ -86,7 +74,6 @@
protected SearchRequest parseSearchRequestMCF(final RestRequest request) throws MCFAuthorizerException {
SearchRequest searchRequest;
- //if(usernameAndDomain[0]==null) throw new MCFAuthorizerException("Username not passed.");
if(request.param("u")!=null) {
String[] authenticatedUserNamesAndDomains = request.param("u").split(",");
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
diff --git a/src/main/java/org/apache/manifoldcf/elasticsearch/MCFConfigurationParameters.java b/src/main/java/org/apache/manifoldcf/elasticsearch/MCFConfigurationParameters.java
index b67bc7a..ca2263c 100644
--- a/src/main/java/org/apache/manifoldcf/elasticsearch/MCFConfigurationParameters.java
+++ b/src/main/java/org/apache/manifoldcf/elasticsearch/MCFConfigurationParameters.java
@@ -1,5 +1,5 @@
/* $Id$ */
-
+/* Modified 2015-07-01 by Bart Superson */
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,6 +18,8 @@
*/
package org.apache.manifoldcf.elasticsearch;
+import org.elasticsearch.common.settings.Settings;
+
/** This class represents the configuration information that the QueryModifier
* needs to perform its job.
*/
@@ -35,11 +37,21 @@
public String denyFieldPrefix = "deny_token_";
/** Connection pool size, e.g. 50 */
public int connectionPoolSize = 50;
-
+
+ public MCFConfigurationParameters(){};
+
+ public MCFConfigurationParameters(Settings settings) {
+ setBaseURL(settings.get("mcf.authority_service_base_url", authorityServiceBaseURL));
+ setConnectionTimeout(settings.getAsInt("mcf.http.connection_timeout", connectionTimeout));
+ setSocketTimeout(settings.getAsInt("mcf.http.socket_timeout",socketTimeout));
+ setAllowFieldPrefix(settings.get("mcf.allow_field_prefix"));
+ setDenyFieldPrefix(settings.get("mcf.deny_field_prefix"));
+ setConnectionPoolSize(settings.getAsInt("mcf.http.connection_pool_size",connectionPoolSize));
+ }
+
public MCFConfigurationParameters setBaseURL(String baseURL)
{
- this.authorityServiceBaseURL = baseURL;
- return this;
+ this.authorityServiceBaseURL = baseURL; return this;
}
public MCFConfigurationParameters setConnectionTimeout(int timeout)