You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by im...@apache.org on 2005/07/04 22:11:52 UTC

svn commit: r209122 - in /jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav: WebdavClientFactory.java WebdavFileObject.java

Author: imario
Date: Mon Jul  4 13:11:51 2005
New Revision: 209122

URL: http://svn.apache.org/viewcvs?rev=209122&view=rev
Log:
use "MultiThreadedHttpConnectionManager" for webdav. Thanks to httpclient this works without forcing webdavlib to call releaseConnection() 

Modified:
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavClientFactory.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavClientFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavClientFactory.java?rev=209122&r1=209121&r2=209122&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavClientFactory.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavClientFactory.java Mon Jul  4 13:11:51 2005
@@ -17,6 +17,7 @@
 
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpURL;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemOptions;
 import org.apache.webdav.lib.WebdavResource;
@@ -77,6 +78,7 @@
             resource.setHttpURL(url, WebdavResource.NOACTION, 1);
 
             client = resource.retrieveSessionInstance();
+            client.setHttpConnectionManager(new MultiThreadedHttpConnectionManager());
         }
         catch (final IOException e)
         {

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java?rev=209122&r1=209121&r2=209122&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java Mon Jul  4 13:11:51 2005
@@ -31,7 +31,6 @@
 import org.apache.commons.vfs.util.RandomAccessMode;
 import org.apache.webdav.lib.BaseProperty;
 import org.apache.webdav.lib.WebdavResource;
-import org.apache.webdav.lib.WebdavResources;
 import org.apache.webdav.lib.methods.DepthSupport;
 import org.apache.webdav.lib.methods.OptionsMethod;
 import org.apache.webdav.lib.methods.XMLResponseMethodBase;
@@ -134,54 +133,61 @@
             /* now fill the dav properties */
             String pathEncoded = name.getPathQueryEncoded(urlCharset);
             final OptionsMethod optionsMethod = new OptionsMethod(pathEncoded);
-            optionsMethod.setFollowRedirects(true);
-            final int status = fileSystem.getClient().executeMethod(optionsMethod);
-            if (status < 200 || status > 299)
+            try
             {
-                if (status == 401 || status == 403)
+                optionsMethod.setFollowRedirects(true);
+                final int status = fileSystem.getClient().executeMethod(optionsMethod);
+                if (status < 200 || status > 299)
                 {
-                    setAllowedMethods(null);
-
-                    // permission denied on this object, but we might get some informations from the parent
-                    processParentDavResource();
+                    if (status == 401 || status == 403)
+                    {
+                        setAllowedMethods(null);
+
+                        // permission denied on this object, but we might get some informations from the parent
+                        processParentDavResource();
+                        return;
+                    }
+                    else
+                    {
+                        injectType(FileType.IMAGINARY);
+                    }
                     return;
                 }
-                else
+                // handle the (maybe) redirected url
+                redirectionResolved = true;
+                resource.getHttpURL().setEscapedPath(optionsMethod.getURI().getPath());
+
+                setAllowedMethods(optionsMethod.getAllowedMethods());
+                boolean exists = false;
+                for (Enumeration enumeration = optionsMethod.getAllowedMethods(); enumeration.hasMoreElements();)
+                {
+                    final String method = (String) enumeration.nextElement();
+                    // IIS allows GET even if the file is non existend - so changed to COPY
+                    // if (method.equals("GET"))
+                    if (method.equals("COPY"))
+                    {
+                        exists = true;
+                        break;
+                    }
+                }
+                if (!exists)
                 {
                     injectType(FileType.IMAGINARY);
+                    return;
                 }
-                return;
-            }
-            // handle the (maybe) redirected url
-            redirectionResolved = true;
-            resource.getHttpURL().setEscapedPath(optionsMethod.getURI().getPath());
 
-            setAllowedMethods(optionsMethod.getAllowedMethods());
-            boolean exists = false;
-            for (Enumeration enumeration = optionsMethod.getAllowedMethods(); enumeration.hasMoreElements();)
-            {
-                final String method = (String) enumeration.nextElement();
-                // IIS allows GET even if the file is non existend - so changed to COPY
-                // if (method.equals("GET"))
-                if (method.equals("COPY"))
+                try
                 {
-                    exists = true;
-                    break;
+                    resource.setProperties(WebdavResource.DEFAULT, 1);
+                }
+                catch (IOException e)
+                {
+                    throw new FileSystemException(e);
                 }
             }
-            if (!exists)
-            {
-                injectType(FileType.IMAGINARY);
-                return;
-            }
-
-            try
-            {
-                resource.setProperties(WebdavResource.DEFAULT, 1);
-            }
-            catch (IOException e)
+            finally
             {
-                throw new FileSystemException(e);
+                optionsMethod.releaseConnection();
             }
         }
 
@@ -229,13 +235,20 @@
         }
 
         final OptionsMethod optionsMethod = new OptionsMethod(getName().getPath());
-        optionsMethod.setFollowRedirects(true);
-        final int status = fileSystem.getClient().executeMethod(optionsMethod);
-        if (status >= 200 && status <= 299)
+        try
         {
-            setAllowedMethods(optionsMethod.getAllowedMethods());
-            resource.getHttpURL().setEscapedPath(optionsMethod.getPath());
-            redirectionResolved = true;
+            optionsMethod.setFollowRedirects(true);
+            final int status = fileSystem.getClient().executeMethod(optionsMethod);
+            if (status >= 200 && status <= 299)
+            {
+                setAllowedMethods(optionsMethod.getAllowedMethods());
+                resource.getHttpURL().setEscapedPath(optionsMethod.getPath());
+                redirectionResolved = true;
+            }
+        }
+        finally
+        {
+            optionsMethod.releaseConnection();
         }
     }
 
@@ -535,18 +548,25 @@
         }
 
         final OptionsMethod optionsMethod = new OptionsMethod(getName().getPath());
-        optionsMethod.setFollowRedirects(true);
-        final int status = fileSystem.getClient().executeMethod(optionsMethod);
-        if (status < 200 || status > 299)
+        try
         {
-            if (status == 401 || status == 403)
+            optionsMethod.setFollowRedirects(true);
+            final int status = fileSystem.getClient().executeMethod(optionsMethod);
+            if (status < 200 || status > 299)
             {
-                setAllowedMethods(null);
-                return;
+                if (status == 401 || status == 403)
+                {
+                    setAllowedMethods(null);
+                    return;
+                }
             }
-        }
 
-        setAllowedMethods(optionsMethod.getAllowedMethods());
+            setAllowedMethods(optionsMethod.getAllowedMethods());
+        }
+        finally
+        {
+            optionsMethod.releaseConnection();
+        }
 
         return;
     }



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