maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r658055 - /maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
Date Tue, 20 May 2008 00:19:21 GMT
Author: brett
Date: Mon May 19 17:19:21 2008
New Revision: 658055

URL: http://svn.apache.org/viewvc?rev=658055&view=rev
Log:
[WAGON-109] improve exception handling for inability to create directories, and ensure we
try even if we traverse to the top

Modified:
    maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java

Modified: maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java?rev=658055&r1=658054&r2=658055&view=diff
==============================================================================
--- maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
(original)
+++ maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
Mon May 19 17:19:21 2008
@@ -123,26 +123,31 @@
         String relpath = FileUtils.normalize( getPath( basedir, dir ) + "/" );
 
         PathNavigator navigator = new PathNavigator(relpath);
-        while (navigator.backward())
-        {
-            int status = SC_NULL;
-            String url = getUrl(navigator);
-            status = doMkCol(url);
-
-            //If collection has been created or exists
-            if (status == HttpStatus.SC_OK
-                    || status == HttpStatus.SC_CREATED
-                    || status == HttpStatus.SC_METHOD_NOT_ALLOWED)
+        
+        // traverse backwards until we hit a directory that already exists (OK/NOT_ALLOWED),
or that we were able to 
+        // create (CREATED), or until we get to the top of the path
+        int status = SC_NULL;        
+        while ( navigator.backward() )
+        {
+            String url = getUrl( navigator );
+            status = doMkCol( url );
+            if ( status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED
+                || status == HttpStatus.SC_METHOD_NOT_ALLOWED )
             {
-                while (navigator.forward())
-                {
-                    status = SC_NULL;
-                    url = getUrl(navigator);
-                    status = doMkCol(url);
-                }
                 break;
             }
         }
+
+        // traverse forward creating missing directories
+        while ( navigator.forward() )
+        {
+            String url = getUrl( navigator );
+            status = doMkCol( url );
+            if ( status != HttpStatus.SC_OK && status != HttpStatus.SC_CREATED )
+            {
+                throw new TransferFailedException( "Unable to create collection: " + url
+ "; status code = " + status );
+            }
+        }
     }
 
     private int doMkCol(String url) throws TransferFailedException



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message