portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r771652 - /portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java
Date Tue, 05 May 2009 10:10:41 GMT
Author: woonsan
Date: Tue May  5 10:10:41 2009
New Revision: 771652

URL: http://svn.apache.org/viewvc?rev=771652&view=rev
Log:
JS2-946: Fixing tomcat application manager to not fail on authentication by using preemptive
authentication.
It must have worked before, but no more with Tomcat 5.5.27 and httpclient-3.x.
So, I changed it to use preemptive authentication and to use non-deprecated methods and confirmed
it working again.
(For httpclient's preemptive authentication, see http://hc.apache.org/httpclient-3.x/authentication.html.)

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java?rev=771652&r1=771651&r2=771652&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java
Tue May  5 10:10:41 2009
@@ -23,12 +23,15 @@
 import java.net.Socket;
 import java.net.UnknownHostException;
 
+import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.HostConfiguration;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.NameValuePair;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -101,8 +104,9 @@
 
         client.setHostConfiguration(hostConfig);
         // Fix for non-buffereing large WAR files during deploy
-        client.getState().setAuthenticationPreemptive(true);
-        client.getState().setCredentials(null, hostUrl, new UsernamePasswordCredentials(userName,
password));
+        client.getParams().setAuthenticationPreemptive(true);
+        Credentials defaultcreds = new UsernamePasswordCredentials(userName, password);
+        client.getState().setCredentials(new AuthScope(hostUrl, hostPort, AuthScope.ANY_REALM),
defaultcreds);
 
         start = new GetMethod(startPath);
         stop = new GetMethod(stopPath);
@@ -120,7 +124,7 @@
         }
         finally
         {
-            start.recycle();
+            start.releaseConnection();
             start.setPath(startPath);
         }
     }
@@ -135,7 +139,7 @@
         }
         finally
         {
-            stop.recycle();
+            stop.releaseConnection();
             stop.setPath(stopPath);
         }
     }
@@ -157,9 +161,9 @@
         }
         finally
         {
-            stop.recycle();
+            stop.releaseConnection();
             stop.setPath(stopPath);
-            start.recycle();
+            start.releaseConnection();
             start.setPath(startPath);
         }
     }
@@ -174,7 +178,7 @@
         }
         finally
         {
-            undeploy.recycle();
+            undeploy.releaseConnection();
             undeploy.setPath(undeployPath);
         }
     }
@@ -184,21 +188,16 @@
         try
         {
             deploy.setQueryString(buildPathQueryArgs(appPath));
-
-            //deploy.setRequestContentLength(PutMethod.CONTENT_LENGTH_CHUNKED);
-
-            if (size != -1)
-            {
-                deploy.setRequestContentLength(size);
-            }
-            deploy.setRequestBody(is);
+            deploy.setContentChunked(true);
+            deploy.setRequestEntity(new InputStreamRequestEntity(is));
 
             client.executeMethod(deploy);
+            
             return parseResult(deploy.getResponseBodyAsString());
         }
         finally
         {
-            deploy.recycle();
+            deploy.releaseConnection();
             deploy.setPath(deployPath);
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message