initial commit for Apache Solr 5.x Plugin
git-svn-id: https://svn.apache.org/repos/asf/manifoldcf/integration/solr-5.x/trunk@1664763 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index 26ffbc2..d966b08 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,64 +1,7 @@
-Apache ManifoldCF Plugin for Apache Solr 4.x change Log
+Apache ManifoldCF Plugin for Apache Solr 5.x change Log
$Id$
-======================= 2.1-SNAPSHOT =====================
-
-CONNECTORS-914: Go to a Maven build system.
-(Ahmet Arslan)
-
-CONNECTORS-934 : Check if log level is enabled before constructing log message.
-(Ahmet Arslan)
-
-======================= Release 2.0 =====================
-
-CONNECTORS-886: Provide [allow|deny]_token_parent fields.
-Upgrade to this version now requires reindexing.
-(Shinichiro Abe, Karl Wright)
-
-CONNECTORS-848: Build against Lucene/Solr 4.6.0.
-
-======================= Release 1.1 =====================
-
-CONNECTORS-825: Fix infinite loop parsing multi-domain arguments.
-(Shinichiro Abe)
-
-Add functionality making the plugin compatible with multi-domain
-features of ManifoldCF. Specifically, allow multiple domain/username
-tuples to be passed in the request.
-(Karl Wright)
-
-======================= Release 0.4 =====================
-
-CONNECTORS-534: Repackage plugins to have a true binary release,
-with appropriate DEPENDENCIES.txt, README's etc.
-(Karl Wright)
-
-Port to Solr 4.1.0.
-(Karl Wright)
-
-======================= Release 0.3 =====================
-
-CONNECTORS-595: Fix tests to use new initCore() conventions and
-test resource layout.
-(Karl Wright)
-
-Port to final release of Solr 4.0.0.
-(Karl Wright)
-
-======================= Release 0.2 =====================
-
-CONNECTORS-485: Port to the latest 4.x code.
-(Karl Wright)
-
-CONNECTORS-354: Add a parameter to allow the maximum connection pool
-size to be configurated in solrconfig.xml.
-(Karl Wright)
-
-CONNECTORS-333: Use multithreaded connection manager and tcp-no-delay
-in order to avoid sockets accumulating in CLOSE_WAIT.
-(Simon Willnauer via Karl Wright)
-
======================= Release 0.1 =====================
Initial commit.
-(Karl Wright)
+(Ahmet Arslan)
diff --git a/DEPENDENCIES.txt b/DEPENDENCIES.txt
index 57e5e98..31646cb 100644
--- a/DEPENDENCIES.txt
+++ b/DEPENDENCIES.txt
@@ -1,9 +1,9 @@
-Apache ManifoldCF Plugin for Apache Solr 4.x requires
+Apache ManifoldCF Plugin for Apache Solr 5.x requires
---------------------------------------------------
-* JRE 1.6 or above
+* JRE 1.7 or above
* mvn 3.0 or higher
-For building Apache ManifoldCF Plugin for Apache Solr 4.x:
+For building Apache ManifoldCF Plugin for Apache Solr 5.x:
------------------------------------------------------
* Look at README.txt
diff --git a/KEYS b/KEYS
index 229e00c..44e6d54 100644
--- a/KEYS
+++ b/KEYS
@@ -127,4 +127,62 @@
1cqtTc96tSwb2XW3iA2uZlD4aTkrOmm3FKbauC/rFmCjkpvwpvqcIdpib4M2DgNx
zAZ2cJnxw3f57qc9Yh5qvhDUephwOAlAy8ekc1AmX14F+mwYE3GjcqeGdEbLNw==
=GLHu
+-----END PGP PUBLIC KEY BLOCK-----
+pub 4096R/3D7558E5 2014-04-15
+uid Ahmet Arslan (CODE SIGNING KEY) <iorixxx@apache.org>
+sig 3 3D7558E5 2014-04-15 Ahmet Arslan (CODE SIGNING KEY) <iorixxx@apache.org>
+sub 4096R/55C9450F 2014-04-15
+sig 3D7558E5 2014-04-15 Ahmet Arslan (CODE SIGNING KEY) <iorixxx@apache.org>
+
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1
+
+mQINBFNNk30BEAC06STETxE0u7EiJ5ZirlpnnFTKWvSjX4kyNUvX69C5fy0MjA7K
+DH//dygA1HxVHq4jKyhrm6U3WqSyKOHos39C3h4DeZZ0uNrmhfjHC5Wj0DeVkzmu
+mKpIho6EDFsLl25slQA9ptvZ3XEf5Gx0554yq+363F9Z7JEyeMM7AQQ1L19NjzKe
+IKMP6TQmo7u7dCn2gcAvpW2IFwaw1yQOw7+KpDcUSXTjmVv8FfdvtScTwWyjkNp/
+ZI5aTuAmLZofIiX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jCzwUyfB/53hBAVwx2fglylfQ
+SMxgURLtBEC9zm7eRrEVJO4uUyHZSgNtAlf+sKlV4A5Ix9NLje2B7808yU5PuGB/
+rAw6kMrhCJvjuXqWS1A4Lgw+H6gOMZ8m9iomPEb2Gvtnf9yE7S96B9ZE3yrVCpAj
+8HRjhW5Sbaf2BKmAs0k5ejIjGG1/IF6Nwch5Ig2YoBEMq5BYCAlMZxGx7FWlfIiW
+5HJDSET4XvJ59ztsQPIf5k+5HwEqLi3rG2eoA5ITgrylucXx/09KZi/QYj4EFPAH
+aY9mIhZX77halI9BLBkCezzCIo/30E7OtSKWzpFOseXOiNfrHLrjD95sdOm0us4Z
+yuX2c7YuhfVXPI73mHqQt3ThadniH0a/HJ4+g4ll06Qi+OxoY+4rljlwsK9sJ0NF
+G0ba71P1RAUqQT893RMBV7fVocHH72RMZqj1OBFc2ooXGF37nH+EA3fVoFMgKnDH
+kdbJThdxKZ938WUsk6zWP0XD5N4Kj07o/xOK9k1HU+cYDxtD77hphXhJFDSUXzxD
+Pm7NsfA29wLXsd3ZZZiS3y3JmVJeyyBimFKtyVBKC97hVrMLpNkdn6fM3k2HrFCL
+OWUgArPPt7zCcZpWTJCZOvhy
+=qHkm
-----END PGP PUBLIC KEY BLOCK-----
\ No newline at end of file
diff --git a/NOTICE.txt b/NOTICE.txt
index f768100..95ad911 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,5 +1,5 @@
-Apache ManifoldCF Plugin for Apache Solr 4.x
-Copyright 2010-2014 The Apache Software Foundation
+Apache ManifoldCF Plugin for Apache Solr 5.x
+Copyright 2010-2015 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
diff --git a/README.txt b/README.txt
index b7cc323..9c67c9b 100644
--- a/README.txt
+++ b/README.txt
@@ -21,22 +21,15 @@
above. It is backwards compatible with earlier versions as well, except for the fact
that two additional Solr fields are required for this plugin to work.
-Upgrading
----------
-If you are replacing a version of Apache ManifoldCF Plugin for Apache Solr 4.x that is
-older than version 2.0, you must declare two additional fields (representing parent
-acls and parent deny acls), and reindex all your documents, so all six fields have the.
-correct values. Otherwise, the plugin will prevent you from viewing any documents.
-
-Instructions for Building Apache ManifoldCF Plugin for Apache Solr 4.x from Source
+Instructions for Building Apache ManifoldCF Plugin for Apache Solr 5.x from Source
------------------------------------------------------------------------------
-1. Download the Java SE 6 JDK (Java Development Kit), or greater, from
+1. Download the Java SE 7 JDK (Java Development Kit), or greater, from
http://www.oracle.com/technetwork/java/index.html.
You will need the JDK installed, and the %JAVA_HOME%\bin directory included
on your command path. To test this, issue a "java -version" command from your
- shell and verify that the Java version is 1.6 or greater.
+ shell and verify that the Java version is 1.7 or greater.
2. Download and install Maven 3.0 or later. Maven installation and configuration
instructions can be found here: http://maven.apache.org
@@ -47,9 +40,9 @@
mvn package assembly:assembly
- The JAR packages can be found in the target folder:
+ The JAR package can be found in the target folder:
- target/solr4x-plugin-mcf-<VERSION>.jar where <VERSION> is the release version
+ target/apache-manifoldcf-solr5x-plugin-<VERSION>.jar where <VERSION> is the release version
Getting Started
@@ -161,7 +154,7 @@
Licensing
---------
-Apache ManifoldCF Plugin for Apache Solr 4.x is licensed under the
+Apache ManifoldCF Plugin for Apache Solr 5.x is licensed under the
Apache License 2.0. See the files called LICENSE.txt and NOTICE.txt
for more information.
@@ -190,7 +183,7 @@
The following provides more details on the included software that
may be subject to export controls on cryptographic software:
- The Apache ManifoldCF Solr 4.x Plugin does not include any
+ The Apache ManifoldCF Solr 5.x Plugin does not include any
implementation or usage of cryptographic software at this time.
Contact
diff --git a/pom.xml b/pom.xml
index a167590..92bc9e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,12 +20,12 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.manifoldcf.solr</groupId>
- <name>ManifoldCF Solr 4.x Plugin</name>
- <artifactId>solr4x-plugin-mcf</artifactId>
- <version>2.1-SNAPSHOT</version>
+ <name>ManifoldCF Solr 5.x Plugin</name>
+ <artifactId>apache-manifoldcf-solr5x-plugin</artifactId>
+ <version>0.1</version>
<packaging>jar</packaging>
- <description>ManifoldCF Plugin for Apache Solr 4.x</description>
- <inceptionYear>2014</inceptionYear>
+ <description>ManifoldCF Plugin for Apache Solr 5.x</description>
+ <inceptionYear>2015</inceptionYear>
<organization>
<name>The Apache Software Foundation</name>
@@ -34,8 +34,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <slf4j.version>1.6.6</slf4j.version>
- <solr.version>4.7.0</solr.version>
+ <solr.version>5.0.0</solr.version>
</properties>
<dependencies>
@@ -54,14 +53,6 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
- <scope>compile</scope>
- <type>jar</type>
- </dependency>
<dependency>
<groupId>commons-logging</groupId>
@@ -80,7 +71,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.17</version>
+ <version>2.18.1</version>
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
@@ -89,17 +80,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
+ <version>3.2</version>
<configuration>
<encoding>utf-8</encoding>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
+ <version>2.5</version>
<configuration>
<archive>
<manifestEntries>
@@ -118,7 +109,7 @@
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
- <version>2.4</version>
+ <version>2.5.3</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/bin.xml</descriptor>
diff --git a/solr/collection1/conf/schema-auth.xml b/solr/collection1/conf/schema-auth.xml
index eeca091..e4c1a6b 100644
--- a/solr/collection1/conf/schema-auth.xml
+++ b/solr/collection1/conf/schema-auth.xml
@@ -15,7 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<schema name="auth" version="1.4">
+<schema name="auth" version="1.5">
<types>
<fieldType name="string" class="solr.StrField"/>
</types>
@@ -29,6 +29,5 @@
<field name="allow_token_parent" type="string" indexed="true" stored="false" multiValued="true" default="__nosecurity__"/>
<field name="deny_token_parent" type="string" indexed="true" stored="false" multiValued="true" default="__nosecurity__"/>
</fields>
- <defaultSearchField>id</defaultSearchField>
<uniqueKey>id</uniqueKey>
</schema>
diff --git a/solr/collection1/conf/solrconfig-auth-load.xml b/solr/collection1/conf/solrconfig-auth-load.xml
index 587f3a1..4811761 100644
--- a/solr/collection1/conf/solrconfig-auth-load.xml
+++ b/solr/collection1/conf/solrconfig-auth-load.xml
@@ -27,8 +27,6 @@
<updateHandler class="solr.DirectUpdateHandler2">
</updateHandler>
- <requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
-
<!-- test MCF Security Filter settings -->
<searchComponent name="mcf-param" class="org.apache.solr.mcf.ManifoldCFSearchComponent" >
<str name="AuthorityServiceBaseURL">http://localhost:8346/mcf-as</str>
diff --git a/solr/collection1/conf/solrconfig-auth-qparser.xml b/solr/collection1/conf/solrconfig-auth-qparser.xml
index 16caec9..f1933d5 100644
--- a/solr/collection1/conf/solrconfig-auth-qparser.xml
+++ b/solr/collection1/conf/solrconfig-auth-qparser.xml
@@ -27,8 +27,6 @@
<updateHandler class="solr.DirectUpdateHandler2">
</updateHandler>
- <requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
-
<!-- test MCF Security Filter settings -->
<queryParser name="mcf-security_param" class="org.apache.solr.mcf.ManifoldCFQParserPlugin" >
<str name="AuthorityServiceBaseURL">http://localhost:8347/mcf-as</str>
diff --git a/solr/collection1/conf/solrconfig-auth.xml b/solr/collection1/conf/solrconfig-auth.xml
index c25e7c7..0f9faec 100644
--- a/solr/collection1/conf/solrconfig-auth.xml
+++ b/solr/collection1/conf/solrconfig-auth.xml
@@ -27,8 +27,6 @@
<updateHandler class="solr.DirectUpdateHandler2">
</updateHandler>
- <requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
-
<!-- test MCF Security Filter settings -->
<searchComponent name="mcf-param" class="org.apache.solr.mcf.ManifoldCFSearchComponent" >
<str name="AuthorityServiceBaseURL">http://localhost:8345/mcf-as</str>
diff --git a/src/main/assembly/bin.xml b/src/main/assembly/bin.xml
index 2eef161..7a54ad0 100644
--- a/src/main/assembly/bin.xml
+++ b/src/main/assembly/bin.xml
@@ -39,9 +39,23 @@
</moduleSet>
</moduleSets>
<fileSets>
+
<fileSet>
+ <directory>target</directory>
+ <outputDirectory/>
+ <fileMode>644</fileMode>
+ <directoryMode>755</directoryMode>
<includes>
- <include>**/target/*.jar</include>
+ <include>apache-manifoldcf-solr5x-plugin-${project.version}.jar</include>
+ </includes>
+ </fileSet>
+
+ <fileSet>
+ <directory>.</directory>
+ <outputDirectory/>
+ <fileMode>644</fileMode>
+ <directoryMode>755</directoryMode>
+ <includes>
<include>README.txt</include>
<include>LICENSE.txt</include>
<include>NOTICE.txt</include>
diff --git a/src/main/assembly/src.xml b/src/main/assembly/src.xml
index 8e67674..5659da2 100644
--- a/src/main/assembly/src.xml
+++ b/src/main/assembly/src.xml
@@ -24,10 +24,15 @@
<fileSets>
<!-- Release materials -->
<fileSet>
+ <directory>.</directory>
+ <outputDirectory/>
+ <fileMode>644</fileMode>
+ <directoryMode>755</directoryMode>
<excludes>
<exclude>**/.*</exclude>
<exclude>**/.*/**</exclude>
<exclude>**/*.iml/**</exclude>
+ <exclude>**/*.patch/**</exclude>
<exclude>**/target/**</exclude>
<exclude>**/lib/**</exclude>
<exclude>**/data/**</exclude>
diff --git a/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java b/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
index bbfe9d7..87822a5 100644
--- a/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
+++ b/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
@@ -16,6 +16,14 @@
*/
package org.apache.solr.mcf;
+import org.apache.http.ParseException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.entity.ContentType;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.lucene.index.*;
import org.apache.lucene.search.*;
import org.apache.solr.search.QParserPlugin;
@@ -28,15 +36,13 @@
import org.apache.solr.core.SolrCore;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.HttpResponse;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.util.EntityUtils;
-import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.DefaultRedirectStrategy;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.slf4j.*;
import java.io.*;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.net.*;
@@ -75,9 +81,9 @@
String fieldDenyParent = null;
int connectionTimeOut;
int socketTimeOut;
- Integer connectionManagerSynchronizer = new Integer(0);
- ThreadSafeClientConnManager httpConnectionManager = null;
- DefaultHttpClient client = null;
+ final Integer connectionManagerSynchronizer = 0;
+ PoolingHttpClientConnectionManager httpConnectionManager = null;
+ HttpClient client = null;
int poolSize;
public ManifoldCFQParserPlugin()
@@ -108,7 +114,7 @@
fieldAllowParent = allowAttributePrefix+"parent";
fieldDenyParent = denyAttributePrefix+"parent";
Integer connectionPoolSize = (Integer)args.get("ConnectionPoolSize");
- poolSize = (connectionPoolSize==null)?50:connectionPoolSize.intValue();
+ poolSize = (connectionPoolSize==null)?50:connectionPoolSize;
}
protected void initializeClient(SolrCore core)
@@ -118,16 +124,30 @@
if (client == null)
{
// Initialize the connection pool
- httpConnectionManager = new ThreadSafeClientConnManager();
+ httpConnectionManager = new PoolingHttpClientConnectionManager();
httpConnectionManager.setMaxTotal(poolSize);
httpConnectionManager.setDefaultMaxPerRoute(poolSize);
- BasicHttpParams params = new BasicHttpParams();
- params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,true);
- params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,false);
- params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,socketTimeOut);
- params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,connectionTimeOut);
- client = new DefaultHttpClient(httpConnectionManager,params);
- client.setRedirectStrategy(new DefaultRedirectStrategy());
+
+ RequestConfig.Builder requestBuilder = RequestConfig.custom()
+ .setCircularRedirectsAllowed(true)
+ .setSocketTimeout(socketTimeOut)
+ .setStaleConnectionCheckEnabled(false)
+ .setExpectContinueEnabled(true)
+ .setConnectTimeout(connectionTimeOut)
+ .setConnectionRequestTimeout(socketTimeOut);
+
+ HttpClientBuilder clientBuilder = HttpClients.custom()
+ .setConnectionManager(httpConnectionManager)
+ .setMaxConnTotal(1)
+ .disableAutomaticRetries()
+ .setDefaultRequestConfig(requestBuilder.build())
+ .setRedirectStrategy(new DefaultRedirectStrategy())
+ .setDefaultSocketConfig(SocketConfig.custom()
+ .setTcpNoDelay(true)
+ .setSoTimeout(socketTimeOut)
+ .build());
+ client = clientBuilder.build();
+
core.addCloseHook(new CloseHandler());
}
}
@@ -158,7 +178,7 @@
List<String> userAccessTokens;
// Map from domain to user
- Map<String,String> domainMap = new HashMap<String,String>();
+ Map<String,String> domainMap = new HashMap<>();
// Get the authenticated user name from the parameters
String authenticatedUserName = params.get(AUTHENTICATED_USER_NAME);
@@ -191,7 +211,7 @@
{
// No authenticated user name.
// mod_authz_annotate may be in use upstream, so look for tokens from it.
- userAccessTokens = new ArrayList<String>();
+ userAccessTokens = new ArrayList<>();
String[] passedTokens = params.getParams(USER_TOKENS);
if (passedTokens == null)
{
@@ -283,7 +303,7 @@
protected Query calculateCompleteSubquery(String allowField, String denyField, Query allowOpen, Query denyOpen, List<String> userAccessTokens)
{
BooleanQuery bq = new BooleanQuery();
- bq.setMaxClauseCount(1000000);
+ BooleanQuery.setMaxClauseCount(1000000);
// Add the empty-acl case
BooleanQuery subUnprotectedClause = new BooleanQuery();
@@ -335,53 +355,40 @@
int rval = httpResponse.getStatusLine().getStatusCode();
if (rval != 200)
{
- String response = EntityUtils.toString(httpResponse.getEntity(),"utf-8");
+ String response = EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Couldn't fetch user's access tokens from ManifoldCF authority service: "+Integer.toString(rval)+"; "+response);
}
- InputStream is = httpResponse.getEntity().getContent();
- try
+
+ try(InputStream is = httpResponse.getEntity().getContent())
{
- String charSet = EntityUtils.getContentCharSet(httpResponse.getEntity());
- if (charSet == null)
- charSet = "utf-8";
- Reader r = new InputStreamReader(is,charSet);
+ Charset charSet;
try
- {
- BufferedReader br = new BufferedReader(r);
- try
{
+ ContentType ct = ContentType.get(httpResponse.getEntity());
+ if (ct == null)
+ charSet = StandardCharsets.UTF_8;
+ else
+ charSet = ct.getCharset();
+ }catch (ParseException e){
+ charSet = StandardCharsets.UTF_8;
+ }
+
+ try( Reader r = new InputStreamReader(is,charSet); BufferedReader br = new BufferedReader(r)) {
// Read the tokens, one line at a time. If any authorities are down, we have no current way to note that, but someday we will.
- List<String> tokenList = new ArrayList<String>();
- while (true)
- {
+ List<String> tokenList = new ArrayList<>();
+ while (true) {
String line = br.readLine();
if (line == null)
break;
- if (line.startsWith("TOKEN:"))
- {
+ if (line.startsWith("TOKEN:")) {
tokenList.add(line.substring("TOKEN:".length()));
- }
- else
- {
- // It probably says something about the state of the authority(s) involved, so log it
- LOG.info("Saw authority response "+line);
+ } else {
+ // It probably says something about the state of the authority(s) involved, so log it
+ LOG.info("Saw authority response " + line);
}
}
return tokenList;
- }
- finally
- {
- br.close();
- }
}
- finally
- {
- r.close();
- }
- }
- finally
- {
- is.close();
}
}
finally
diff --git a/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java b/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
index 2a8d733..526fcc7 100644
--- a/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
+++ b/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
@@ -16,6 +16,14 @@
*/
package org.apache.solr.mcf;
+import org.apache.http.ParseException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.entity.ContentType;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.lucene.index.*;
import org.apache.lucene.search.*;
import org.apache.solr.common.SolrException;
@@ -30,15 +38,13 @@
import org.apache.solr.core.SolrCore;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.HttpResponse;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.util.EntityUtils;
-import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.DefaultRedirectStrategy;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.slf4j.*;
import java.io.*;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.net.*;
@@ -83,8 +89,8 @@
String fieldDenyParent = null;
int connectionTimeOut;
int socketTimeOut;
- ThreadSafeClientConnManager httpConnectionManager = null;
- DefaultHttpClient client = null;
+ PoolingHttpClientConnectionManager httpConnectionManager = null;
+ HttpClient client = null;
int poolSize;
public ManifoldCFSearchComponent()
@@ -119,19 +125,34 @@
fieldAllowParent = allowAttributePrefix+"parent";
fieldDenyParent = denyAttributePrefix+"parent";
Integer connectionPoolSize = (Integer)args.get("ConnectionPoolSize");
- poolSize = (connectionPoolSize==null)?50:connectionPoolSize.intValue();
+ poolSize = (connectionPoolSize==null)?50:connectionPoolSize;
// Initialize the connection pool
- httpConnectionManager = new ThreadSafeClientConnManager();
+ httpConnectionManager = new PoolingHttpClientConnectionManager();
httpConnectionManager.setMaxTotal(poolSize);
httpConnectionManager.setDefaultMaxPerRoute(poolSize);
- BasicHttpParams params = new BasicHttpParams();
- params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,true);
- params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,false);
- params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,socketTimeOut);
- params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,connectionTimeOut);
- client = new DefaultHttpClient(httpConnectionManager,params);
- client.setRedirectStrategy(new DefaultRedirectStrategy());
+
+ RequestConfig.Builder requestBuilder = RequestConfig.custom()
+ .setCircularRedirectsAllowed(true)
+ .setSocketTimeout(socketTimeOut)
+ .setStaleConnectionCheckEnabled(false)
+ .setExpectContinueEnabled(true)
+ .setConnectTimeout(connectionTimeOut)
+ .setConnectionRequestTimeout(socketTimeOut);
+
+ HttpClientBuilder clientBuilder = HttpClients.custom()
+ .setConnectionManager(httpConnectionManager)
+ .setMaxConnTotal(1)
+ .disableAutomaticRetries()
+ .setDefaultRequestConfig(requestBuilder.build())
+ .setRedirectStrategy(new DefaultRedirectStrategy())
+ .setDefaultSocketConfig(SocketConfig.custom()
+ .setTcpNoDelay(true)
+ .setSoTimeout(socketTimeOut)
+ .build());
+
+ client = clientBuilder.build();
+
}
@Override
@@ -144,7 +165,7 @@
// Log that we got here
//LOG.info("prepare() entry params:\n" + params + "\ncontext: " + rb.req.getContext());
- String qry = (String)params.get(CommonParams.Q);
+ String qry = params.get(CommonParams.Q);
if (qry != null)
{
//Check global allowed searches
@@ -159,7 +180,7 @@
List<String> userAccessTokens;
// Map from domain to user
- Map<String,String> domainMap = new HashMap<String,String>();
+ Map<String,String> domainMap = new HashMap<>();
// Get the authenticated user name from the parameters
String authenticatedUserName = params.get(AUTHENTICATED_USER_NAME);
@@ -192,7 +213,7 @@
{
// No authenticated user name.
// mod_authz_annotate may be in use upstream, so look for tokens from it.
- userAccessTokens = new ArrayList<String>();
+ userAccessTokens = new ArrayList<>();
String[] passedTokens = params.getParams(USER_TOKENS);
if (passedTokens == null)
{
@@ -270,7 +291,7 @@
List<Query> list = rb.getFilters();
if (list == null)
{
- list = new ArrayList<Query>();
+ list = new ArrayList<>();
rb.setFilters(list);
}
list.add(new ConstantScoreQuery(bq));
@@ -289,7 +310,7 @@
protected Query calculateCompleteSubquery(String allowField, String denyField, Query allowOpen, Query denyOpen, List<String> userAccessTokens)
{
BooleanQuery bq = new BooleanQuery();
- bq.setMaxClauseCount(1000000);
+ BooleanQuery.setMaxClauseCount(1000000);
// Add the empty-acl case
BooleanQuery subUnprotectedClause = new BooleanQuery();
@@ -374,23 +395,29 @@
int rval = httpResponse.getStatusLine().getStatusCode();
if (rval != 200)
{
- String response = EntityUtils.toString(httpResponse.getEntity(),"utf-8");
+ String response = EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Couldn't fetch user's access tokens from ManifoldCF authority service: "+Integer.toString(rval)+"; "+response);
}
- InputStream is = httpResponse.getEntity().getContent();
- try
+
+ try(InputStream is = httpResponse.getEntity().getContent())
{
- String charSet = EntityUtils.getContentCharSet(httpResponse.getEntity());
- if (charSet == null)
- charSet = "utf-8";
- Reader r = new InputStreamReader(is,charSet);
+ Charset charSet;
try
{
- BufferedReader br = new BufferedReader(r);
- try
- {
+ ContentType ct = ContentType.get(httpResponse.getEntity());
+ if (ct == null)
+ charSet = StandardCharsets.UTF_8;
+ else
+ charSet = ct.getCharset();
+ }catch (ParseException e){
+ charSet = StandardCharsets.UTF_8;
+ }
+
+
+ try(Reader r = new InputStreamReader(is,charSet); BufferedReader br = new BufferedReader(r))
+ {
// Read the tokens, one line at a time. If any authorities are down, we have no current way to note that, but someday we will.
- List<String> tokenList = new ArrayList<String>();
+ List<String> tokenList = new ArrayList<>();
while (true)
{
String line = br.readLine();
@@ -408,19 +435,6 @@
}
return tokenList;
}
- finally
- {
- br.close();
- }
- }
- finally
- {
- r.close();
- }
- }
- finally
- {
- is.close();
}
}
finally
diff --git a/src/test/java/org/apache/solr/mcf/ManifoldCFSearchComponentTest.java b/src/test/java/org/apache/solr/mcf/ManifoldCFSearchComponentTest.java
index 13f09a0..b0e14aa 100644
--- a/src/test/java/org/apache/solr/mcf/ManifoldCFSearchComponentTest.java
+++ b/src/test/java/org/apache/solr/mcf/ManifoldCFSearchComponentTest.java
@@ -30,7 +30,6 @@
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;