manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1407977 [2/2] - in /manifoldcf/trunk: ./ connectors/ connectors/sharepoint/ connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/ framework/ framework/pull-agent/ framework/pull-agent/src/test/j...
Date Sun, 11 Nov 2012 13:33:11 GMT
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=1407977&r1=1407976&r2=1407977&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 Sun Nov 11 13:33:09 2012
@@ -34,13 +34,26 @@ import java.util.Locale;
 import java.util.List;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.concurrent.TimeUnit;
 import java.net.*;
 
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
-import org.apache.commons.httpclient.auth.*;
-import org.apache.commons.httpclient.params.*;
-import org.apache.commons.httpclient.protocol.*;
+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;
 
 
 /** This is the "repository connector" for Microsoft SharePoint.
@@ -87,9 +100,9 @@ public class SharePointRepository extend
   // SSL support
   private String keystoreData = null;
   private IKeystoreManager keystoreManager = null;
-  private SharepointSecureSocketFactory secureSocketFactory = null;
-  private ProtocolFactory myFactory = null;
-  private MultiThreadedHttpConnectionManager connectionManager = null;
+  
+  private ClientConnectionManager connectionManager = null;
+  private HttpClient httpClient = null;
 
   // Current host name
   private static String currentHost = null;
@@ -187,24 +200,39 @@ public class SharePointRepository extend
 
       // Set up ssl if indicated
       keystoreData = params.getParameter( "keystore" );
-      myFactory = new ProtocolFactory();
+
+      PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
+      localConnectionManager.setMaxTotal(1);
+      connectionManager = localConnectionManager;
 
       if (keystoreData != null)
       {
         keystoreManager = KeystoreManagerFactory.make("",keystoreData);
-        secureSocketFactory = new SharepointSecureSocketFactory(keystoreManager.getSecureSocketFactory());
-        Protocol myHttpsProtocol = new Protocol("https", (ProtocolSocketFactory)secureSocketFactory, 443);
-        myFactory.registerProtocol("https",myHttpsProtocol);
+        SSLSocketFactory myFactory = new SSLSocketFactory(keystoreManager.getSecureSocketFactory(), new BrowserCompatHostnameVerifier());
+        Scheme myHttpsProtocol = new Scheme("https", 443, myFactory);
+        connectionManager.getSchemeRegistry().register(myHttpsProtocol);
       }
 
-      connectionManager = new MultiThreadedHttpConnectionManager();
-      connectionManager.getParams().setMaxTotalConnections(1);
-
       fileBaseUrl = serverUrl + encodedServerLocation;
 
+      BasicHttpParams params = new BasicHttpParams();
+      params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,true);
+      params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,false);
+      params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,60000);
+      DefaultHttpClient localHttpClient = new DefaultHttpClient(connectionManager,params);
+      localHttpClient.setRedirectStrategy(new DefaultRedirectStrategy());
+      if (strippedUserName != null)
+      {
+        localHttpClient.getCredentialsProvider().setCredentials(
+          new AuthScope(serverName,serverPort),
+          new NTCredentials(strippedUserName, password, currentHost, ntlmDomain));
+      }
+
+      httpClient = localHttpClient;
+      
       proxy = new SPSProxyHelper( serverUrl, encodedServerLocation, serverLocation, userName, password,
-        myFactory, getClass(), "sharepoint-client-config.wsdd",
-        connectionManager );
+        getClass(), "sharepoint-client-config.wsdd",
+        httpClient );
       
     }
     sessionTimeout = System.currentTimeMillis() + sessionExpirationInterval;
@@ -225,10 +253,9 @@ public class SharePointRepository extend
 
     keystoreData = null;
     keystoreManager = null;
-    secureSocketFactory = null;
-    myFactory = null;
 
     proxy = null;
+    httpClient = null;
     if (connectionManager != null)
       connectionManager.shutdown();
     connectionManager = null;
@@ -275,10 +302,9 @@ public class SharePointRepository extend
 
     keystoreData = null;
     keystoreManager = null;
-    secureSocketFactory = null;
-    myFactory = null;
 
     proxy = null;
+    httpClient = null;
     if (connectionManager != null)
       connectionManager.shutdown();
     connectionManager = null;
@@ -354,7 +380,7 @@ public class SharePointRepository extend
     if (proxy != null && System.currentTimeMillis() >= sessionTimeout)
       expireSession();
     if (connectionManager != null)
-      connectionManager.closeIdleConnections(60000L);
+      connectionManager.closeIdleConnections(60000L,TimeUnit.MILLISECONDS);
   }
 
   /** Request arbitrary connector information.
@@ -1357,6 +1383,7 @@ public class SharePointRepository extend
               if (Logging.connectors.isDebugEnabled())
                 Logging.connectors.debug( "SharePoint: Processing file '"+documentIdentifier+"'; url: '" + fileUrl + "'" );
 
+
               // Set stuff up for fetch activity logging
               long startFetchTime = System.currentTimeMillis();
               try
@@ -1369,119 +1396,49 @@ public class SharePointRepository extend
                   OutputStream os = new FileOutputStream(tempFile);
                   try
                   {
-                    // Read the document.
+                    // Catch all exceptions having to do with reading the document
                     try
                     {
-                      HttpClient httpClient = new HttpClient(connectionManager);
-                      HostConfiguration clientConf = new HostConfiguration();
-                      clientConf.setParams(new HostParams());
-                      clientConf.setHost(serverName,serverPort,myFactory.getProtocol(serverProtocol));
-
-                      Credentials credentials;
-                      if (strippedUserName != null)
-                        credentials =  new NTCredentials(strippedUserName, password, currentHost, ntlmDomain);
-                      else
-                        credentials = null;
-
-                      if (credentials != null)
-                        httpClient.getState().setCredentials(new AuthScope(serverName,serverPort,null),
-                          credentials);
-
-                      HttpMethodBase method = new GetMethod( encodedServerLocation + encodedDocumentPath );
-                      try
+                      ExecuteMethodThread emt = new ExecuteMethodThread(httpClient,
+                        serverUrl + encodedServerLocation + encodedDocumentPath, os);
+                      emt.start();
+                      emt.join();
+                      Throwable t = emt.getException();
+                      if (t instanceof InterruptedException)
+                        throw (InterruptedException)t;
+                      if (t instanceof IOException)
+                        throw (IOException)t;
+                      else if (t instanceof Error)
+                        throw (Error)t;
+                      else if (t instanceof org.apache.http.HttpException)
+                        throw (org.apache.http.HttpException)t;
+                      else if (t instanceof RuntimeException)
+                        throw (RuntimeException)t;
+                      
+                      int returnCode = emt.getResponse();
+                        
+                      if (returnCode == 404 || returnCode == 401 || returnCode == 400)
                       {
-                        // Set up SSL using our keystore
-                        method.getParams().setParameter("http.socket.timeout", new Integer(60000));
-
-                        int returnCode;
-                        ExecuteMethodThread t = new ExecuteMethodThread(httpClient,clientConf,method);
-                        try
-                        {
-                          t.start();
-                          t.join();
-                          Throwable thr = t.getException();
-                          if (thr != null)
-                          {
-                            if (thr instanceof IOException)
-                              throw (IOException)thr;
-                            if (thr instanceof RuntimeException)
-                              throw (RuntimeException)thr;
-                            else
-                              throw (Error)thr;
-                          }
-                          returnCode = t.getResponse();
-                        }
-                        catch (InterruptedException e)
-                        {
-                          t.interrupt();
-                          // We need the caller to abandon any connections left around, so rethrow in a way that forces them to process the event properly.
-                          method = null;
-                          throw e;
-                        }
-                        if (returnCode == HttpStatus.SC_NOT_FOUND || returnCode == HttpStatus.SC_UNAUTHORIZED || returnCode == HttpStatus.SC_BAD_REQUEST)
-                        {
-                          // Well, sharepoint thought the document was there, but it really isn't, so delete it.
-                          if (Logging.connectors.isDebugEnabled())
-                            Logging.connectors.debug("SharePoint: Document at '"+encodedServerLocation+encodedDocumentPath+"' failed to fetch with code "+Integer.toString(returnCode)+", deleting");
-                          activities.recordActivity(new Long(startFetchTime),ACTIVITY_FETCH,
-                            null,documentIdentifier,"Not found",Integer.toString(returnCode),null);
-                          activities.deleteDocument(documentIdentifier,version);
-                          i++;
-                          continue;
-                        }
-                        if (returnCode != HttpStatus.SC_OK)
-                        {
-                          activities.recordActivity(new Long(startFetchTime),ACTIVITY_FETCH,
-                            null,documentIdentifier,"Error","Http status "+Integer.toString(returnCode),null);
-                          throw new ManifoldCFException("Error fetching document '"+fileUrl+"': "+Integer.toString(returnCode));
-                        }
-
-                        // int contentSize = (int)method.getResponseContentLength();
-                        InputStream is = method.getResponseBodyAsStream();
-                        try
-                        {
-                          byte[] transferBuffer = new byte[65536];
-                          while (true)
-                          {
-                            int amt = is.read(transferBuffer);
-                            if (amt == -1)
-                              break;
-                            os.write(transferBuffer,0,amt);
-                          }
-                        }
-                        finally
-                        {
-                          try
-                          {
-                            is.close();
-                          }
-                          catch (java.net.SocketTimeoutException e)
-                          {
-                            Logging.connectors.warn("SharePoint: Socket timeout error closing connection to file '"+fileUrl+"': "+e.getMessage(),e);
-                          }
-                          catch (org.apache.commons.httpclient.ConnectTimeoutException e)
-                          {
-                            Logging.connectors.warn("SharePoint: Connect timeout error closing connection to file '"+fileUrl+"': "+e.getMessage(),e);
-                          }
-                          catch (InterruptedIOException e)
-                          {
-                            throw new ManifoldCFException("Interrupted: "+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
-                          }
-                          catch (IOException e)
-                          {
-                            Logging.connectors.warn("SharePoint: Error closing connection to file '"+fileUrl+"': "+e.getMessage(),e);
-                          }
-                        }
+                        // Well, sharepoint thought the document was there, but it really isn't, so delete it.
+                        if (Logging.connectors.isDebugEnabled())
+                          Logging.connectors.debug("SharePoint: Document at '"+encodedServerLocation+encodedDocumentPath+"' failed to fetch with code "+Integer.toString(returnCode)+", deleting");
+                        activities.recordActivity(new Long(startFetchTime),ACTIVITY_FETCH,
+                          null,documentIdentifier,"Not found",Integer.toString(returnCode),null);
+                        activities.deleteDocument(documentIdentifier,version);
+                        i++;
+                        continue;
                       }
-                      finally
+                      else if (returnCode != 200)
                       {
-                        if (method != null)
-                          method.releaseConnection();
+                        activities.recordActivity(new Long(startFetchTime),ACTIVITY_FETCH,
+                          null,documentIdentifier,"Error","Http status "+Integer.toString(returnCode),null);
+                        throw new ManifoldCFException("Error fetching document '"+fileUrl+"': "+Integer.toString(returnCode));
                       }
 
                       // Log the normal fetch activity
                       activities.recordActivity(new Long(startFetchTime),ACTIVITY_FETCH,
                         new Long(tempFile.length()),documentIdentifier,"Success",null,null);
+
                     }
                     catch (InterruptedException e)
                     {
@@ -1496,7 +1453,7 @@ public class SharePointRepository extend
                       throw new ServiceInterruption("SharePoint is down attempting to read '"+fileUrl+"', retrying: "+e.getMessage(),e,currentTime + 300000L,
                         currentTime + 12 * 60 * 60000L,-1,true);
                     }
-                    catch (org.apache.commons.httpclient.ConnectTimeoutException e)
+                    catch (org.apache.http.conn.ConnectTimeoutException e)
                     {
                       activities.recordActivity(new Long(startFetchTime),ACTIVITY_FETCH,
                         new Long(tempFile.length()),documentIdentifier,"Error",e.getMessage(),null);
@@ -1516,7 +1473,7 @@ public class SharePointRepository extend
                         new Long(tempFile.length()),documentIdentifier,"Error",e.getMessage(),null);
                       throw new ManifoldCFException("SharePoint: Illegal argument: "+e.getMessage(),e);
                     }
-                    catch (HttpException e)
+                    catch (org.apache.http.HttpException e)
                     {
                       Logging.connectors.warn("SharePoint: HttpException thrown",e);
                       activities.recordActivity(new Long(startFetchTime),ACTIVITY_FETCH,
@@ -1540,6 +1497,7 @@ public class SharePointRepository extend
                     os.close();
                   }
                   
+                  // Ingest the document
                   long documentLength = tempFile.length();
                   if (activities.checkLengthIndexable(documentLength))
                   {
@@ -1610,7 +1568,7 @@ public class SharePointRepository extend
                         // This is not fatal
                         Logging.connectors.debug("SharePoint: Timeout before read could finish for '"+fileUrl+"': "+e.getMessage(),e);
                       }
-                      catch (org.apache.commons.httpclient.ConnectTimeoutException e)
+                      catch (org.apache.http.conn.ConnectTimeoutException e)
                       {
                         // This is not fatal
                         Logging.connectors.debug("SharePoint: Connect timeout before read could finish for '"+fileUrl+"': "+e.getMessage(),e);
@@ -1639,7 +1597,7 @@ public class SharePointRepository extend
               {
                 throw new ManifoldCFException("Socket timeout error writing '"+fileUrl+"' to temporary file: "+e.getMessage(),e);
               }
-              catch (org.apache.commons.httpclient.ConnectTimeoutException e)
+              catch (org.apache.http.conn.ConnectTimeoutException e)
               {
                 throw new ManifoldCFException("Connect timeout error writing '"+fileUrl+"' to temporary file: "+e.getMessage(),e);
               }
@@ -4828,27 +4786,59 @@ public class SharePointRepository extend
 
   protected static class ExecuteMethodThread extends Thread
   {
-    protected HttpClient client;
-    protected HostConfiguration hostConfiguration;
-    protected HttpMethodBase executeMethod;
+    protected final HttpClient httpClient;
+    protected final String url;
+    protected final OutputStream os;
+
     protected Throwable exception = null;
-    protected int rval = 0;
+    protected int returnCode = 0;
 
-    public ExecuteMethodThread(HttpClient client, HostConfiguration hostConfiguration, HttpMethodBase executeMethod)
+    public ExecuteMethodThread( HttpClient httpClient, String url, OutputStream os )
     {
       super();
       setDaemon(true);
-      this.client = client;
-      this.hostConfiguration = hostConfiguration;
-      this.executeMethod = executeMethod;
+      this.httpClient = httpClient;
+      this.url = url;
+      this.os = os;
     }
 
     public void run()
     {
       try
       {
-        // Call the execute method appropriately
-        rval = client.executeMethod(hostConfiguration,executeMethod,null);
+        HttpGet method = new HttpGet( url );
+        // Try block to insure that the connection gets cleaned up
+        try
+        {
+          // Begin the fetch
+          HttpResponse response = httpClient.execute(method);
+          returnCode = response.getStatusLine().getStatusCode();
+          
+          if (returnCode == 200)
+          {
+            // Process the data
+            HttpEntity entity = response.getEntity();
+            if (entity != null)
+            {
+              InputStream is = entity.getContent();
+              // Figure out what to do with the data. 
+              byte[] transferBuffer = new byte[65536];
+              while (true)
+              {
+                int amt = is.read(transferBuffer);
+                if (amt == -1)
+                  break;
+                os.write(transferBuffer,0,amt);
+              }
+            }
+          }
+        }
+        finally
+        {
+          // Consumes and closes the stream, releasing the connection
+          method.abort();
+        }
+
       }
       catch (Throwable e)
       {
@@ -4863,7 +4853,7 @@ public class SharePointRepository extend
 
     public int getResponse()
     {
-      return rval;
+      return returnCode;
     }
   }
 
@@ -5776,205 +5766,5 @@ public class SharePointRepository extend
     }
   }
 
-  /** Socket factory for our https implementation.
-  */
-  protected static class MySSLSocketFactory implements org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory
-  {
-    protected javax.net.ssl.SSLSocketFactory thisSocketFactory = null;
-    protected IKeystoreManager keystore;
-
-    /** Constructor.  Pass the keystore.
-    */
-    public MySSLSocketFactory(IKeystoreManager keystore)
-      throws ManifoldCFException
-    {
-      this.keystore = keystore;
-      thisSocketFactory = keystore.getSecureSocketFactory();
-    }
-
-
-    public Socket createSocket(String host,
-      int port,
-      InetAddress clientHost,
-      int clientPort)
-      throws IOException, UnknownHostException
-    {
-      return thisSocketFactory.createSocket(host,
-        port,
-        clientHost,
-        clientPort);
-    }
-
-
-    public Socket createSocket(final String host,
-      final int port,
-      final InetAddress localAddress,
-      final int localPort,
-      final HttpConnectionParams params)
-      throws IOException, UnknownHostException, ConnectTimeoutException
-    {
-      if (params == null)
-      {
-        throw new IllegalArgumentException("Parameters may not be null");
-      }
-      int timeout = params.getConnectionTimeout();
-      if (timeout == 0)
-      {
-        return createSocket(host, port, localAddress, localPort);
-      }
-      else
-      {
-        return createSocket(host, port, localAddress, localPort);
-
-        /*
-        return thisSocketFactory.createSocket(host,
-          port,
-          localAddress,
-          localPort,
-          timeout);
-        */
-      }
-    }
-
-    public Socket createSocket(String host, int port)
-      throws IOException, UnknownHostException
-    {
-      return thisSocketFactory.createSocket(host,port);
-    }
-
-    public Socket createSocket(Socket socket,
-      String host,
-      int port,
-      boolean autoClose)
-      throws IOException, UnknownHostException
-    {
-      return thisSocketFactory.createSocket(socket,
-        host,
-        port,
-        autoClose);
-    }
-
-
-    /** There's a socket factory per keystore;
-    * look at the keystore to do the comparison.
-    */
-    public boolean equals(Object obj)
-    {
-      if (obj == null || !(obj instanceof MySSLSocketFactory))
-        return false;
-      MySSLSocketFactory other = (MySSLSocketFactory)obj;
-      try
-      {
-        return keystore.getString().equals(other.keystore.getString());
-      }
-      catch (ManifoldCFException e)
-      {
-        return false;
-      }
-    }
-
-    public int hashCode()
-    {
-      try
-      {
-        return keystore.getString().hashCode();
-      }
-      catch (ManifoldCFException e)
-      {
-        return 0;
-      }
-    }
-
-
-  }
-
-  /** HTTPClient secure socket factory, which implements SecureProtocolSocketFactory
-  */
-  protected static class SharepointSecureSocketFactory implements SecureProtocolSocketFactory
-  {
-    /** This is the javax.net socket factory.
-    */
-    protected javax.net.ssl.SSLSocketFactory socketFactory;
-
-    /** Constructor */
-    public SharepointSecureSocketFactory(javax.net.ssl.SSLSocketFactory socketFactory)
-    {
-      this.socketFactory = socketFactory;
-    }
-
-    public Socket createSocket(
-      String host,
-      int port,
-      InetAddress clientHost,
-      int clientPort)
-      throws IOException, UnknownHostException
-    {
-      return socketFactory.createSocket(
-        host,
-        port,
-        clientHost,
-        clientPort
-      );
-    }
-
-    public Socket createSocket(
-      final String host,
-      final int port,
-      final InetAddress localAddress,
-      final int localPort,
-      final HttpConnectionParams params
-    ) throws IOException, UnknownHostException, ConnectTimeoutException
-    {
-      if (params == null)
-      {
-        throw new IllegalArgumentException("Parameters may not be null");
-      }
-      int timeout = params.getConnectionTimeout();
-      if (timeout == 0)
-      {
-        return createSocket(host, port, localAddress, localPort);
-      }
-      else
-        throw new IllegalArgumentException("This implementation does not handle non-zero connection timeouts");
-    }
-
-    public Socket createSocket(String host, int port)
-      throws IOException, UnknownHostException
-    {
-      return socketFactory.createSocket(
-        host,
-        port
-      );
-    }
-
-    public Socket createSocket(
-      Socket socket,
-      String host,
-      int port,
-      boolean autoClose)
-      throws IOException, UnknownHostException
-    {
-      return socketFactory.createSocket(
-        socket,
-        host,
-        port,
-        autoClose
-      );
-    }
-
-    public boolean equals(Object obj)
-    {
-      if (obj == null || !(obj instanceof SharepointSecureSocketFactory))
-        return false;
-      // Each object is unique
-      return super.equals(obj);
-    }
-
-    public int hashCode()
-    {
-      return super.hashCode();
-    }
-
-  }
 
 }

Modified: manifoldcf/trunk/connectors/sharepoint/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/sharepoint/pom.xml (original)
+++ manifoldcf/trunk/connectors/sharepoint/pom.xml Sun Nov 11 13:33:09 2012
@@ -93,33 +93,33 @@
         <artifactId>axistools-maven-plugin</artifactId>
         <version>1.4</version>
         
-				<dependencies>
-					<dependency>
-						<groupId>org.apache.axis</groupId>
-						<artifactId>axis</artifactId>
-						<version>1.4</version>
-					</dependency>
-					<dependency>
-						<groupId>commons-logging</groupId>
-						<artifactId>commons-logging</artifactId>
-						<version>${commons-logging.version}</version>
-					</dependency>
-					<dependency>
-						<groupId>commons-discovery</groupId>
-						<artifactId>commons-discovery</artifactId>
-						<version>0.2</version>
-					</dependency>
-					<dependency>
-						<groupId>javax.xml</groupId>
-						<artifactId>jaxrpc-api</artifactId>
-						<version>1.1</version>
-					</dependency>
-					<dependency>
-						<groupId>wsdl4j</groupId>
-						<artifactId>wsdl4j</artifactId>
-						<version>1.6.2</version>
-					</dependency>
-				</dependencies>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.axis</groupId>
+            <artifactId>axis</artifactId>
+            <version>1.4</version>
+          </dependency>
+          <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons-logging.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>commons-discovery</groupId>
+            <artifactId>commons-discovery</artifactId>
+            <version>0.2</version>
+          </dependency>
+          <dependency>
+            <groupId>javax.xml</groupId>
+            <artifactId>jaxrpc-api</artifactId>
+            <version>1.1</version>
+          </dependency>
+          <dependency>
+            <groupId>wsdl4j</groupId>
+            <artifactId>wsdl4j</artifactId>
+            <version>1.6.2</version>
+          </dependency>
+        </dependencies>
         
         <configuration>
           <sourceDirectory>wsdls</sourceDirectory>
@@ -181,9 +181,9 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>

Modified: manifoldcf/trunk/framework/build.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/build.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/framework/build.xml (original)
+++ manifoldcf/trunk/framework/build.xml Sun Nov 11 13:33:09 2012
@@ -38,6 +38,8 @@
             <include name="commons-el*.jar"/>
             <include name="commons-fileupload*.jar"/>
             <include name="commons-httpclient*.jar"/>
+            <include name="httpcore*.jar"/>
+            <include name="httpclient*.jar"/>
             <include name="commons-io*.jar"/>
             <include name="commons-lang*.jar"/>
             <include name="commons-logging*.jar"/>
@@ -313,6 +315,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -349,6 +353,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -390,6 +396,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -427,6 +435,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -470,6 +480,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -515,6 +527,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -567,6 +581,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -614,6 +630,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -729,6 +747,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -767,6 +787,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -888,6 +910,8 @@
                 <include name="commons-codec*.jar"/>
                 <include name="commons-collections*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -916,6 +940,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -1020,7 +1046,9 @@
         <property name="manifest-cp-57" value="${manifest-cp-56} lib/jetty-xml.jar"/>
         <property name="manifest-cp-58" value="${manifest-cp-57} lib/slf4j-api.jar"/>
         <property name="manifest-cp-59" value="${manifest-cp-58} lib/slf4j-simple.jar"/>
-        <property name="manifest-cp" value="${manifest-cp-59}"/>
+        <property name="manifest-cp-60" value="${manifest-cp-59} lib/httpcore.jar"/>
+        <property name="manifest-cp-61" value="${manifest-cp-60} lib/httpclient.jar"/>
+        <property name="manifest-cp" value="${manifest-cp-61}"/>
         <mkdir dir="build/example"/>
         <manifest file="build/example/manifest">
             <attribute name="Main-Class" value="org.apache.manifoldcf.jettyrunner.ManifoldCFJettyRunner"/>
@@ -1041,6 +1069,8 @@
                 <include name="commons-el*.jar"/>
                 <include name="commons-fileupload*.jar"/>
                 <include name="commons-httpclient*.jar"/>
+                <include name="httpcore*.jar"/>
+                <include name="httpclient*.jar"/>
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
@@ -1153,7 +1183,9 @@
         <property name="manifest-cp-proprietary-59" value="${manifest-cp-proprietary-58} lib/jetty-xml.jar"/>
         <property name="manifest-cp-proprietary-60" value="${manifest-cp-proprietary-59} lib/slf4j-api.jar"/>
         <property name="manifest-cp-proprietary-61" value="${manifest-cp-proprietary-60} lib/slf4j-simple.jar"/>
-        <property name="manifest-cp-proprietary" value="${manifest-cp-proprietary-61}"/>
+        <property name="manifest-cp-proprietary-62" value="${manifest-cp-proprietary-61} lib/httpcore.jar"/>
+        <property name="manifest-cp-proprietary-63" value="${manifest-cp-proprietary-62} lib/httpclient.jar"/>
+        <property name="manifest-cp-proprietary" value="${manifest-cp-proprietary-63}"/>
         <mkdir dir="build/example-proprietary"/>
         <manifest file="build/example-proprietary/manifest">
             <attribute name="Main-Class" value="org.apache.manifoldcf.jettyrunner.ManifoldCFJettyRunner"/>

Modified: manifoldcf/trunk/framework/pull-agent/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/pom.xml (original)
+++ manifoldcf/trunk/framework/pull-agent/pom.xml Sun Nov 11 13:33:09 2012
@@ -134,9 +134,9 @@
     </dependency>
 
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java Sun Nov 11 13:33:09 2012
@@ -33,8 +33,25 @@ import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.webapp.WebAppContext;
 
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
+import org.apache.http.client.HttpClient;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpException;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpEntity;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+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.entity.StringEntity;
+import org.apache.http.entity.ContentType;
+
 
 /** Tests that run the "agents daemon" should be derived from this */
 public class ManifoldCFInstance
@@ -253,7 +270,46 @@ public class ManifoldCFInstance
   {
     return "http://localhost:"+Integer.toString(testPort)+"/mcf-api-service/json/"+command;
   }
-  
+
+  public static String convertToString(HttpResponse httpResponse)
+    throws IOException
+  {
+    HttpEntity entity = httpResponse.getEntity();
+    if (entity != null)
+    {
+      InputStream is = entity.getContent();
+      try
+      {
+        String charSet = EntityUtils.getContentCharSet(entity);
+        if (charSet == null)
+          charSet = "utf-8";
+        char[] buffer = new char[65536];
+        Reader r = new InputStreamReader(is,charSet);
+        Writer w = new StringWriter();
+        try
+        {
+          while (true)
+          {
+            int amt = r.read(buffer);
+            if (amt == -1)
+              break;
+            w.write(buffer,0,amt);
+          }
+        }
+        finally
+        {
+          w.flush();
+        }
+        return w.toString();
+      }
+      finally
+      {
+        is.close();
+      }
+    }
+    return "";
+  }
+
   /** Perform an json API GET operation.
   *@param apiURL is the operation.
   *@param expectedResponse is the expected response code.
@@ -262,15 +318,21 @@ public class ManifoldCFInstance
   public String performAPIGetOperation(String apiURL, int expectedResponse)
     throws Exception
   {
-    HttpClient client = new HttpClient();
-    GetMethod method = new GetMethod(apiURL);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
+    DefaultHttpClient client = new DefaultHttpClient();
+    HttpGet method = new HttpGet(apiURL);
+    try
+    {
+      HttpResponse response = client.execute(method);
+      int responseCode = response.getStatusLine().getStatusCode();
+      String responseString = convertToString(response);
+      if (responseCode != expectedResponse)
+        throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(responseCode)+": "+responseString);
+      return responseString;
+    }
+    finally
+    {
+      method.abort();
+    }
   }
 
   /** Perform an json API DELETE operation.
@@ -281,15 +343,22 @@ public class ManifoldCFInstance
   public String performAPIDeleteOperation(String apiURL, int expectedResponse)
     throws Exception
   {
-    HttpClient client = new HttpClient();
-    DeleteMethod method = new DeleteMethod(apiURL);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
+    DefaultHttpClient client = new DefaultHttpClient();
+    HttpDelete method = new HttpDelete(apiURL);
+    try
+    {
+      HttpResponse response = client.execute(method);
+      int responseCode = response.getStatusLine().getStatusCode();
+      String responseString = convertToString(response);
+      if (responseCode != expectedResponse)
+        throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(responseCode)+": "+responseString);
+      // We presume that the data is utf-8, since that's what the API uses throughout.
+      return responseString;
+    }
+    finally
+    {
+      method.abort();
+    }
   }
 
   /** Perform an json API PUT operation.
@@ -301,17 +370,23 @@ public class ManifoldCFInstance
   public String performAPIPutOperation(String apiURL, int expectedResponse, String input)
     throws Exception
   {
-    HttpClient client = new HttpClient();
-    PutMethod method = new PutMethod(apiURL);
-    method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
-    method.setRequestBody(input);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
+    DefaultHttpClient client = new DefaultHttpClient();
+    HttpPut method = new HttpPut(apiURL);
+    try
+    {
+      method.setEntity(new StringEntity(input,ContentType.create("text/plain","UTF-8")));
+      HttpResponse response = client.execute(method);
+      int responseCode = response.getStatusLine().getStatusCode();
+      String responseString = convertToString(response);
+      if (responseCode != expectedResponse)
+        throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(responseCode)+": "+responseString);
+      // We presume that the data is utf-8, since that's what the API uses throughout.
+      return responseString;
+    }
+    finally
+    {
+      method.abort();
+    }
   }
 
   /** Perform an json API POST operation.
@@ -323,17 +398,23 @@ public class ManifoldCFInstance
   public String performAPIPostOperation(String apiURL, int expectedResponse, String input)
     throws Exception
   {
-    HttpClient client = new HttpClient();
-    PostMethod method = new PostMethod(apiURL);
-    method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
-    method.setRequestBody(input);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
+    DefaultHttpClient client = new DefaultHttpClient();
+    HttpPost method = new HttpPost(apiURL);
+    try
+    {
+      method.setEntity(new StringEntity(input,ContentType.create("text/plain","UTF-8")));
+      HttpResponse response = client.execute(method);
+      int responseCode = response.getStatusLine().getStatusCode();
+      String responseString = convertToString(response);
+      if (responseCode != expectedResponse)
+        throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(responseCode)+": "+responseString);
+      // We presume that the data is utf-8, since that's what the API uses throughout.
+      return responseString;
+    }
+    finally
+    {
+      method.abort();
+    }
   }
 
   /** Perform a json GET API operation, using Configuration structures to represent the json.  This is for testing convenience,

Modified: manifoldcf/trunk/framework/script-engine/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/pom.xml (original)
+++ manifoldcf/trunk/framework/script-engine/pom.xml Sun Nov 11 13:33:09 2012
@@ -74,9 +74,9 @@
       <scope>runtime</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-collections</groupId>

Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/DELETECommand.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/DELETECommand.java?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/DELETECommand.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/DELETECommand.java Sun Nov 11 13:33:09 2012
@@ -18,8 +18,19 @@
 */
 package org.apache.manifoldcf.scriptengine;
 
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.http.client.HttpClient;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpException;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.HttpResponse;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+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 java.io.*;
 
 /** DELETE command.  This performs a REST-style DELETE operation, designed to work
@@ -51,22 +62,19 @@ public class DELETECommand implements Co
     try
     {
       HttpClient client = sp.getHttpClient();
-      DeleteMethod method = new DeleteMethod(urlString);
+      HttpDelete method = new HttpDelete(urlString);
       try
       {
-        int resultCode = client.executeMethod(method);
-        byte[] responseData = method.getResponseBody();
-        // We presume that the data is utf-8, since that's what the API
-        // uses throughout.
-        String resultJSON = new String(responseData,"utf-8");
-
+        HttpResponse httpResponse = client.execute(method);
+        int resultCode = httpResponse.getStatusLine().getStatusCode();
+        String resultJSON = sp.convertToString(httpResponse);
         result.setReference(new VariableResult(resultCode,resultJSON));
       
         return false;
       }
       finally
       {
-        method.releaseConnection();
+        //method.releaseConnection();
       }
     }
     catch (IOException e)

Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/GETCommand.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/GETCommand.java?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/GETCommand.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/GETCommand.java Sun Nov 11 13:33:09 2012
@@ -18,8 +18,19 @@
 */
 package org.apache.manifoldcf.scriptengine;
 
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.http.client.HttpClient;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpException;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.HttpResponse;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+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 java.io.*;
 
 /** GET command.  This performs a REST-style GET operation, designed to work
@@ -51,22 +62,19 @@ public class GETCommand implements Comma
     try
     {
       HttpClient client = sp.getHttpClient();
-      GetMethod method = new GetMethod(urlString);
+      HttpGet method = new HttpGet(urlString);
       try
       {
-        int resultCode = client.executeMethod(method);
-        byte[] responseData = method.getResponseBody();
-        // We presume that the data is utf-8, since that's what the API
-        // uses throughout.
-        String resultJSON = new String(responseData,"utf-8");
-
+        HttpResponse httpResponse = client.execute(method);
+        int resultCode = httpResponse.getStatusLine().getStatusCode();
+        String resultJSON = sp.convertToString(httpResponse);
         result.setReference(new VariableResult(resultCode,resultJSON));
       
         return false;
       }
       finally
       {
-        method.releaseConnection();
+        //method.releaseConnection();
       }
     }
     catch (IOException e)

Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java Sun Nov 11 13:33:09 2012
@@ -19,8 +19,20 @@
 package org.apache.manifoldcf.scriptengine;
 
 import org.apache.manifoldcf.core.interfaces.*;
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.client.HttpClient;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpException;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.HttpResponse;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+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 java.io.*;
 
 /** POST command.  This performs a REST-style POST operation, designed to work
@@ -61,24 +73,20 @@ public class POSTCommand implements Comm
     {
       String json = configuration.toJSON();
       HttpClient client = sp.getHttpClient();
-      PostMethod method = new PostMethod(urlString);
+      HttpPost method = new HttpPost(urlString);
       try
       {
-        method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
-        method.setRequestBody(json);
-        int resultCode = client.executeMethod(method);
-        byte[] responseData = method.getResponseBody();
-        // We presume that the data is utf-8, since that's what the API
-        // uses throughout.
-        String resultJSON = new String(responseData,"utf-8");
-
+        method.setEntity(new StringEntity(json,ContentType.create("text/plain","UTF-8")));
+        HttpResponse httpResponse = client.execute(method);
+        int resultCode = httpResponse.getStatusLine().getStatusCode();
+        String resultJSON = sp.convertToString(httpResponse);
         result.setReference(new VariableResult(resultCode,resultJSON));
       
         return false;
       }
       finally
       {
-        method.releaseConnection();
+        //method.releaseConnection();
       }
     }
     catch (ManifoldCFException e)

Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java Sun Nov 11 13:33:09 2012
@@ -19,8 +19,20 @@
 package org.apache.manifoldcf.scriptengine;
 
 import org.apache.manifoldcf.core.interfaces.*;
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.client.HttpClient;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpException;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.HttpResponse;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+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 java.io.*;
 
 /** PUT command.  This performs a REST-style PUT operation, designed to work
@@ -61,24 +73,20 @@ public class PUTCommand implements Comma
     {
       String json = configuration.toJSON();
       HttpClient client = sp.getHttpClient();
-      PutMethod method = new PutMethod(urlString);
+      HttpPut method = new HttpPut(urlString);
       try
       {
-        method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
-        method.setRequestBody(json);
-        int resultCode = client.executeMethod(method);
-        byte[] responseData = method.getResponseBody();
-        // We presume that the data is utf-8, since that's what the API
-        // uses throughout.
-        String resultJSON = new String(responseData,"utf-8");
-
+        method.setEntity(new StringEntity(json,ContentType.create("text/plain","UTF-8")));
+        HttpResponse httpResponse = client.execute(method);
+        int resultCode = httpResponse.getStatusLine().getStatusCode();
+        String resultJSON = sp.convertToString(httpResponse);
         result.setReference(new VariableResult(resultCode,resultJSON));
       
         return false;
       }
       finally
       {
-        method.releaseConnection();
+        //method.releaseConnection();
       }
     }
     catch (ManifoldCFException e)

Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java Sun Nov 11 13:33:09 2012
@@ -19,7 +19,21 @@
 
 package org.apache.manifoldcf.scriptengine;
 
-import org.apache.commons.httpclient.*;
+import org.apache.http.client.HttpClient;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpException;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpEntity;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+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.conn.ClientConnectionManager;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
 import java.util.*;
 import java.io.*;
 
@@ -28,7 +42,7 @@ import java.io.*;
 public class ScriptParser
 {
   /** The connection manager. */
-  protected HttpConnectionManager connectionManager = null;
+  protected ClientConnectionManager connectionManager = null;
   
   /** The client instance */
   protected HttpClient httpClient = null;
@@ -1141,14 +1155,59 @@ public class ScriptParser
       t.throwException(message + ": "+t);
   }
   
+  public static String convertToString(HttpResponse httpResponse)
+    throws IOException
+  {
+    HttpEntity entity = httpResponse.getEntity();
+    if (entity != null)
+    {
+      InputStream is = entity.getContent();
+      try
+      {
+        String charSet = EntityUtils.getContentCharSet(entity);
+        if (charSet == null)
+          charSet = "utf-8";
+        char[] buffer = new char[65536];
+        Reader r = new InputStreamReader(is,charSet);
+        Writer w = new StringWriter();
+        try
+        {
+          while (true)
+          {
+            int amt = r.read(buffer);
+            if (amt == -1)
+              break;
+            w.write(buffer,0,amt);
+          }
+        }
+        finally
+        {
+          w.flush();
+        }
+        return w.toString();
+      }
+      finally
+      {
+        is.close();
+      }
+    }
+    return "";
+  }
+  
   public HttpClient getHttpClient()
   {
     synchronized (httpClientLock)
     {
       if (httpClient == null)
       {
-        connectionManager = new MultiThreadedHttpConnectionManager();
-        httpClient = new HttpClient(connectionManager);
+        connectionManager = new PoolingClientConnectionManager();
+        BasicHttpParams params = new BasicHttpParams();
+        params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,true);
+        params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,false);
+        //params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,socketTimeOut);
+        DefaultHttpClient localHttpClient = new DefaultHttpClient(connectionManager,params);
+        localHttpClient.setRedirectStrategy(new DefaultRedirectStrategy());
+        httpClient = localHttpClient;
       }
     }
     return httpClient;

Modified: manifoldcf/trunk/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/pom.xml (original)
+++ manifoldcf/trunk/pom.xml Sun Nov 11 13:33:09 2012
@@ -49,6 +49,7 @@
     <commons-collections.version>3.2.1</commons-collections.version>
     <commons-fileupload.version>1.2.2</commons-fileupload.version>
     <commons-httpclient.version>3.1-mcf-1</commons-httpclient.version>
+    <httpcomponent.version>4.2.2</httpcomponent.version>
     <commons-el.version>1.0</commons-el.version>
     <commons-lang.version>2.6</commons-lang.version>
     <xalan.version>2.7.1</xalan.version>

Modified: manifoldcf/trunk/tests/alfresco/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/tests/alfresco/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/tests/alfresco/pom.xml (original)
+++ manifoldcf/trunk/tests/alfresco/pom.xml Sun Nov 11 13:33:09 2012
@@ -320,9 +320,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>

Modified: manifoldcf/trunk/tests/cmis/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/tests/cmis/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/tests/cmis/pom.xml (original)
+++ manifoldcf/trunk/tests/cmis/pom.xml Sun Nov 11 13:33:09 2012
@@ -309,9 +309,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>

Modified: manifoldcf/trunk/tests/elasticsearch/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/tests/elasticsearch/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/tests/elasticsearch/pom.xml (original)
+++ manifoldcf/trunk/tests/elasticsearch/pom.xml Sun Nov 11 13:33:09 2012
@@ -324,9 +324,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>

Modified: manifoldcf/trunk/tests/filesystem/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/tests/filesystem/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/tests/filesystem/pom.xml (original)
+++ manifoldcf/trunk/tests/filesystem/pom.xml Sun Nov 11 13:33:09 2012
@@ -280,9 +280,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>

Modified: manifoldcf/trunk/tests/rss/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/tests/rss/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/tests/rss/pom.xml (original)
+++ manifoldcf/trunk/tests/rss/pom.xml Sun Nov 11 13:33:09 2012
@@ -274,9 +274,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>

Modified: manifoldcf/trunk/tests/sharepoint/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/tests/sharepoint/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/tests/sharepoint/pom.xml (original)
+++ manifoldcf/trunk/tests/sharepoint/pom.xml Sun Nov 11 13:33:09 2012
@@ -92,9 +92,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>

Modified: manifoldcf/trunk/tests/test-build.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/tests/test-build.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/tests/test-build.xml (original)
+++ manifoldcf/trunk/tests/test-build.xml Sun Nov 11 13:33:09 2012
@@ -36,6 +36,8 @@
             <include name="commons-el*.jar"/>
             <include name="commons-fileupload*.jar"/>
             <include name="commons-httpclient*.jar"/>
+            <include name="httpcore*.jar"/>
+            <include name="httpclient*.jar"/>
             <include name="commons-io*.jar"/>
             <include name="commons-lang*.jar"/>
             <include name="commons-logging*.jar"/>

Modified: manifoldcf/trunk/tests/wiki/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/tests/wiki/pom.xml?rev=1407977&r1=1407976&r2=1407977&view=diff
==============================================================================
--- manifoldcf/trunk/tests/wiki/pom.xml (original)
+++ manifoldcf/trunk/tests/wiki/pom.xml Sun Nov 11 13:33:09 2012
@@ -280,9 +280,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>



Mime
View raw message