Author: rharo
Date: Fri Aug 14 14:14:43 2015
New Revision: 1695922
URL: http://svn.apache.org/r1695922
Log:
CONNECTORS-1161: Fixing HttpClient initialization with deprecated methods
Modified:
manifoldcf/trunk/connectors/confluence/build.xml
manifoldcf/trunk/connectors/confluence/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/confluence/client/ConfluenceClient.java
manifoldcf/trunk/connectors/confluence/pom.xml
Modified: manifoldcf/trunk/connectors/confluence/build.xml
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/confluence/build.xml?rev=1695922&r1=1695921&r2=1695922&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/confluence/build.xml (original)
+++ manifoldcf/trunk/connectors/confluence/build.xml Fri Aug 14 14:14:43 2015
@@ -34,6 +34,8 @@
<path refid="mcf-connector-build.connector-classpath" />
<fileset dir="../../lib">
<include name="guava-*.jar" />
+ <include name="httpcore*.jar" />
+ <include name="httpclient*.jar" />
</fileset>
</path>
Modified:
manifoldcf/trunk/connectors/confluence/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/confluence/client/ConfluenceClient.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/confluence/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/confluence/client/ConfluenceClient.java?rev=1695922&r1=1695921&r2=1695922&view=diff
==============================================================================
---
manifoldcf/trunk/connectors/confluence/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/confluence/client/ConfluenceClient.java
(original)
+++
manifoldcf/trunk/connectors/confluence/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/confluence/client/ConfluenceClient.java
Fri Aug 14 14:14:43 2015
@@ -14,8 +14,11 @@ import org.apache.http.client.methods.Ht
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.config.RegistryBuilder;
import org.apache.http.config.SocketConfig;
-import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
@@ -114,50 +117,37 @@ public class ConfluenceClient {
*/
private void connect() throws ManifoldCFException {
- int socketTimeout = 900000;
+ int socketTimeout = 900000;
int connectionTimeout = 60000;
javax.net.ssl.SSLSocketFactory httpsSocketFactory =
KeystoreManagerFactory.getTrustingSecureSocketFactory();
SSLConnectionSocketFactory myFactory = new
SSLConnectionSocketFactory(new
InterruptibleSocketFactory(httpsSocketFactory,connectionTimeout),
- SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ NoopHostnameVerifier.INSTANCE);
- HttpClientConnectionManager connectionManager = new
PoolingHttpClientConnectionManager();
+ PoolingHttpClientConnectionManager poolingConnectionManager = new
PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create()
+ .register("http",
PlainConnectionSocketFactory.getSocketFactory())
+ .register("https", myFactory)
+ .build());
+ poolingConnectionManager.setDefaultMaxPerRoute(1);
+ poolingConnectionManager.setValidateAfterInactivity(60000);
+
poolingConnectionManager.setDefaultSocketConfig(SocketConfig.custom()
+ .setTcpNoDelay(true)
+ .setSoTimeout(socketTimeout)
+ .build());
- // If authentication needed, set that
- // Preemptive authentication not working
- /*if (username != null)
- {
- CredentialsProvider credentialsProvider = new
BasicCredentialsProvider();
- credentialsProvider.setCredentials(
- AuthScope.ANY,
- new
UsernamePasswordCredentials(username,password));
-
- AuthCache authCache = new BasicAuthCache();
- authCache.put(new HttpHost(host, port), new BasicScheme());
- httpContext = HttpClientContext.create();
- httpContext.setCredentialsProvider(credentialsProvider);
- httpContext.setAuthCache(authCache);
- }*/
RequestConfig.Builder requestBuilder = RequestConfig.custom()
.setCircularRedirectsAllowed(true)
.setSocketTimeout(socketTimeout)
- .setStaleConnectionCheckEnabled(true)
.setExpectContinueEnabled(true)
.setConnectTimeout(connectionTimeout)
.setConnectionRequestTimeout(socketTimeout);
httpClient = HttpClients.custom()
- .setConnectionManager(connectionManager)
- .setMaxConnTotal(1)
+ .setConnectionManager(poolingConnectionManager)
.disableAutomaticRetries()
.setDefaultRequestConfig(requestBuilder.build())
- .setDefaultSocketConfig(SocketConfig.custom()
- .setTcpNoDelay(true)
- .setSoTimeout(socketTimeout)
- .build())
- .setSSLSocketFactory(myFactory)
.setRequestExecutor(new HttpRequestExecutor(socketTimeout))
.setRedirectStrategy(new DefaultRedirectStrategy())
.build();
Modified: manifoldcf/trunk/connectors/confluence/pom.xml
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/confluence/pom.xml?rev=1695922&r1=1695921&r2=1695922&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/confluence/pom.xml (original)
+++ manifoldcf/trunk/connectors/confluence/pom.xml Fri Aug 14 14:14:43 2015
@@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>mcf-confluence-connector</artifactId>
<packaging>jar</packaging>
-
+
<url>http://maven.apache.org</url>
<developers>
@@ -169,7 +169,8 @@
</plugins>
<pluginManagement>
<plugins>
- <!--This plugin's configuration is used to
store Eclipse m2e settings only. It has no influence on the Maven build
itself.-->
+ <!--This plugin's configuration is used to
store Eclipse m2e settings
+ only. It has no influence on the Maven
build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
@@ -246,107 +247,106 @@
<dependencies>
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mcf-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mcf-connector-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mcf-pull-agent</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mcf-agents</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mcf-ui-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>${commons-lang.version}</version>
- <type>jar</type>
- </dependency>
-
- <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-connector-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-pull-agent</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-agents</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-ui-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>${commons-lang.version}</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
</dependency>
-
+
<!-- Testing dependencies -->
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>${mockito.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>com.github.tomakehurst</groupId>
- <artifactId>wiremock</artifactId>
- <version>${wiremock.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mcf-core</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.16</version>
- <scope>provided</scope>
- <type>jar</type>
- </dependency>
- <dependency>
- <groupId>com.googlecode.json-simple</groupId>
- <artifactId>json-simple</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.8</version>
- </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.github.tomakehurst</groupId>
+ <artifactId>wiremock</artifactId>
+ <version>${wiremock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ <scope>provided</scope>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>com.googlecode.json-simple</groupId>
+ <artifactId>json-simple</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.8</version>
+ </dependency>
</dependencies>
</project>