Author: kwright
Date: Wed Mar 19 21:40:19 2014
New Revision: 1579413

URL: http://svn.apache.org/r1579413
Log:
Fix deprecation warnings.  Note that this commit means that CommonsHttpSender 
no longer tries to handle expect/continue or http 1.0/1.1 by itself; httpclient 
actually must do this work now.  Part of CONNECTORS-911

Modified:
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointADAuthority.java
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointAuthority.java
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/sharepoint/CommonsHTTPSender.java

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointADAuthority.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointADAuthority.java?rev=1579413&r1=1579412&r2=1579413&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointADAuthority.java
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointADAuthority.java
 Wed Mar 19 21:40:19 2014
@@ -32,27 +32,6 @@ import javax.naming.*;
 import javax.naming.ldap.*;
 import javax.naming.directory.*;
 
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.client.HttpClient;
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.NTCredentials;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.client.DefaultRedirectStrategy;
-import org.apache.http.util.EntityUtils;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.client.HttpRequestRetryHandler;
-import org.apache.http.protocol.HttpContext;
-
 
 /** This is the Active Directory implementation of the IAuthorityConnector 
interface, as used
 * by SharePoint in Claim Space.  It is meant to be used in conjunction with 
other SharePoint authorities,

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointAuthority.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointAuthority.java?rev=1579413&r1=1579412&r2=1579413&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointAuthority.java
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointAuthority.java
 Wed Mar 19 21:40:19 2014
@@ -32,24 +32,25 @@ import javax.naming.*;
 import javax.naming.ldap.*;
 import javax.naming.directory.*;
 
-import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.client.HttpClient;
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.protocol.HttpRequestExecutor;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
 import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.NTCredentials;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.client.DefaultRedirectStrategy;
 import org.apache.http.util.EntityUtils;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.client.params.ClientPNames;
 import org.apache.http.client.HttpRequestRetryHandler;
 import org.apache.http.protocol.HttpContext;
 
@@ -99,7 +100,7 @@ public class SharePointAuthority extends
   
   private IKeystoreManager keystoreManager = null;
   
-  private ClientConnectionManager connectionManager = null;
+  private HttpClientConnectionManager connectionManager = null;
   private HttpClient httpClient = null;
 
 
@@ -701,50 +702,54 @@ public class SharePointAuthority extends
           serverUrl += ":" + Integer.toString(serverPort);
       }
 
+      fileBaseUrl = serverUrl + encodedServerLocation;
+
+      int connectionTimeout = 60000;
+      int socketTimeout = 900000;
+      
       // Set up ssl if indicated
 
-      PoolingClientConnectionManager localConnectionManager = new 
PoolingClientConnectionManager();
-      localConnectionManager.setMaxTotal(1);
-      connectionManager = localConnectionManager;
+      connectionManager = new PoolingHttpClientConnectionManager();
 
+      CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+
+      SSLConnectionSocketFactory myFactory = null;
       if (keystoreData != null)
       {
         keystoreManager = KeystoreManagerFactory.make("",keystoreData);
-        SSLSocketFactory myFactory = new 
SSLSocketFactory(keystoreManager.getSecureSocketFactory(), new 
BrowserCompatHostnameVerifier());
-        Scheme myHttpsProtocol = new Scheme("https", 443, myFactory);
-        connectionManager.getSchemeRegistry().register(myHttpsProtocol);
+        myFactory = new 
SSLConnectionSocketFactory(keystoreManager.getSecureSocketFactory(), new 
BrowserCompatHostnameVerifier());
       }
 
-      fileBaseUrl = serverUrl + encodedServerLocation;
-
-      BasicHttpParams params = new BasicHttpParams();
-      params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,true);
-      
params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,true);
-      params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,60000);
-      params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,900000);
-      params.setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS,true);
-      DefaultHttpClient localHttpClient = new 
DefaultHttpClient(connectionManager,params);
-      // No retries
-      localHttpClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler()
-        {
-          public boolean retryRequest(
-            IOException exception,
-            int executionCount,
-            HttpContext context)
-          {
-            return false;
-          }
-       
-        });
-      localHttpClient.setRedirectStrategy(new DefaultRedirectStrategy());
       if (strippedUserName != null)
       {
-        localHttpClient.getCredentialsProvider().setCredentials(
+        credentialsProvider.setCredentials(
           new AuthScope(serverName,serverPort),
           new NTCredentials(strippedUserName, password, currentHost, 
ntlmDomain));
       }
 
-      httpClient = localHttpClient;
+      RequestConfig.Builder requestBuilder = RequestConfig.custom()
+          .setCircularRedirectsAllowed(true)
+          .setSocketTimeout(socketTimeout)
+          .setStaleConnectionCheckEnabled(true)
+          .setExpectContinueEnabled(true)
+          .setConnectTimeout(connectionTimeout)
+          .setConnectionRequestTimeout(socketTimeout);
+
+      HttpClientBuilder builder = HttpClients.custom()
+        .setConnectionManager(connectionManager)
+        .setMaxConnTotal(1)
+        .disableAutomaticRetries()
+        .setDefaultRequestConfig(requestBuilder.build())
+        .setDefaultSocketConfig(SocketConfig.custom()
+          .setTcpNoDelay(true)
+          .setSoTimeout(socketTimeout)
+          .build())
+        .setDefaultCredentialsProvider(credentialsProvider);
+      if (myFactory != null)
+        builder.setSSLSocketFactory(myFactory);
+      builder.setRequestExecutor(new HttpRequestExecutor(socketTimeout))
+        .setRedirectStrategy(new DefaultRedirectStrategy());
+      httpClient = builder.build();
       
       proxy = new SPSProxyHelper( serverUrl, encodedServerLocation, 
serverLocation, serverUserName, password,
         org.apache.manifoldcf.sharepoint.CommonsHTTPSender.class, 
"sharepoint-client-config.wsdd",

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java?rev=1579413&r1=1579412&r2=1579413&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java
 Wed Mar 19 21:40:19 2014
@@ -42,24 +42,25 @@ import java.net.*;
 import org.apache.log4j.Logger;
 import org.apache.log4j.Level;
 
-import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.client.HttpClient;
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.protocol.HttpRequestExecutor;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
 import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.NTCredentials;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.client.DefaultRedirectStrategy;
 import org.apache.http.util.EntityUtils;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.client.params.ClientPNames;
 import org.apache.http.client.HttpRequestRetryHandler;
 import org.apache.http.protocol.HttpContext;
 
@@ -113,7 +114,7 @@ public class SharePointRepository extend
   private String keystoreData = null;
   private IKeystoreManager keystoreManager = null;
   
-  private ClientConnectionManager connectionManager = null;
+  private HttpClientConnectionManager connectionManager = null;
   private HttpClient httpClient = null;
 
   // Current host name
@@ -223,53 +224,57 @@ public class SharePointRepository extend
         if (serverPort != 80)
           serverUrl += ":" + Integer.toString(serverPort);
       }
+      
+      fileBaseUrl = serverUrl + encodedServerLocation;
 
       // Set up ssl if indicated
       keystoreData = 
params.getParameter(SharePointConfig.PARAM_SERVERKEYSTORE);
 
-      PoolingClientConnectionManager localConnectionManager = new 
PoolingClientConnectionManager();
-      localConnectionManager.setMaxTotal(1);
-      connectionManager = localConnectionManager;
+      int connectionTimeout = 60000;
+      int socketTimeout = 900000;
+
+      connectionManager = new PoolingHttpClientConnectionManager();
 
+      CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+
+      SSLConnectionSocketFactory myFactory = null;
       if (keystoreData != null)
       {
         keystoreManager = KeystoreManagerFactory.make("",keystoreData);
-        SSLSocketFactory myFactory = new 
SSLSocketFactory(keystoreManager.getSecureSocketFactory(), new 
BrowserCompatHostnameVerifier());
-        Scheme myHttpsProtocol = new Scheme("https", 443, myFactory);
-        connectionManager.getSchemeRegistry().register(myHttpsProtocol);
+        myFactory = new 
SSLConnectionSocketFactory(keystoreManager.getSecureSocketFactory(), new 
BrowserCompatHostnameVerifier());
       }
 
-      fileBaseUrl = serverUrl + encodedServerLocation;
-
-      BasicHttpParams params = new BasicHttpParams();
-      params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,true);
-      
params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,true);
-      params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,60000);
-      params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,900000);
-      params.setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS,true);
-      DefaultHttpClient localHttpClient = new 
DefaultHttpClient(connectionManager,params);
-      // No retries
-      localHttpClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler()
-        {
-          public boolean retryRequest(
-            IOException exception,
-            int executionCount,
-            HttpContext context)
-          {
-            return false;
-          }
-       
-        });
-      localHttpClient.setRedirectStrategy(new DefaultRedirectStrategy());
       if (strippedUserName != null)
       {
-        localHttpClient.getCredentialsProvider().setCredentials(
+        credentialsProvider.setCredentials(
           new AuthScope(serverName,serverPort),
           new NTCredentials(strippedUserName, password, currentHost, 
ntlmDomain));
       }
 
-      httpClient = localHttpClient;
-      
+      RequestConfig.Builder requestBuilder = RequestConfig.custom()
+          .setCircularRedirectsAllowed(true)
+          .setSocketTimeout(socketTimeout)
+          .setStaleConnectionCheckEnabled(true)
+          .setExpectContinueEnabled(true)
+          .setConnectTimeout(connectionTimeout)
+          .setConnectionRequestTimeout(socketTimeout);
+
+      HttpClientBuilder builder = HttpClients.custom()
+        .setConnectionManager(connectionManager)
+        .setMaxConnTotal(1)
+        .disableAutomaticRetries()
+        .setDefaultRequestConfig(requestBuilder.build())
+        .setDefaultSocketConfig(SocketConfig.custom()
+          .setTcpNoDelay(true)
+          .setSoTimeout(socketTimeout)
+          .build())
+        .setDefaultCredentialsProvider(credentialsProvider);
+      if (myFactory != null)
+        builder.setSSLSocketFactory(myFactory);
+      builder.setRequestExecutor(new HttpRequestExecutor(socketTimeout))
+        .setRedirectStrategy(new DefaultRedirectStrategy());
+      httpClient = builder.build();
+
       proxy = new SPSProxyHelper( serverUrl, encodedServerLocation, 
serverLocation, userName, password,
         org.apache.manifoldcf.sharepoint.CommonsHTTPSender.class, 
"sharepoint-client-config.wsdd",
         httpClient );

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/sharepoint/CommonsHTTPSender.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/sharepoint/CommonsHTTPSender.java?rev=1579413&r1=1579412&r2=1579413&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/sharepoint/CommonsHTTPSender.java
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/sharepoint/CommonsHTTPSender.java
 Wed Mar 19 21:40:19 2014
@@ -43,8 +43,6 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.Header;
-import org.apache.http.params.CoreProtocolPNames;
-import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.util.EntityUtils;
 import org.apache.http.message.BasicHeader;
@@ -157,7 +155,7 @@ public class CommonsHTTPSender extends B
         HttpPost postMethod = new HttpPost(targetURL.toString());
           
         // set false as default, addContetInfo can overwrite
-        HttpProtocolParams.setUseExpectContinue(postMethod.getParams(),false);
+        
//HttpProtocolParams.setUseExpectContinue(postMethod.getParams(),false);
 
         Message reqMessage = msgContext.getRequestMessage();
           
@@ -172,8 +170,8 @@ public class CommonsHTTPSender extends B
         method = new HttpGet(targetURL.toString());
       }
         
-      if (http10)
-        HttpProtocolParams.setVersion(method.getParams(),new 
ProtocolVersion("HTTP",1,0));
+      //if (http10)
+      //  HttpProtocolParams.setVersion(method.getParams(),new 
ProtocolVersion("HTTP",1,0));
 
       BackgroundHTTPThread methodThread = new 
BackgroundHTTPThread(httpClient,method);
       methodThread.start();
@@ -335,10 +333,11 @@ public class CommonsHTTPSender extends B
         String key = keyObj.toString().trim();
         String value = me.getValue().toString().trim();
 
-        if (key.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT) &&
-          value.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT_100_Continue)) {
-          HttpProtocolParams.setUseExpectContinue(method.getParams(),true);
-        } else if 
(key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
+        //if (key.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT) &&
+        //  value.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT_100_Continue)) {
+        //  HttpProtocolParams.setUseExpectContinue(method.getParams(),true);
+        //} else 
+        if 
(key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
           String val = me.getValue().toString();
           if (null != val)  {
             httpChunkStream = JavaUtils.isTrue(val);


Reply via email to