maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dant...@apache.org
Subject svn commit: r731091 - in /maven/wagon/trunk: ./ wagon-providers/wagon-webdav-jackrabbit/ wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/ wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/mav...
Date Sat, 03 Jan 2009 21:25:34 GMT
Author: dantran
Date: Sat Jan  3 13:25:34 2009
New Revision: 731091

URL: http://svn.apache.org/viewvc?rev=731091&view=rev
Log:
WAGON-246, WAGON-255: use jackrabbit-webdav-1.5.0, fix getFileList to retrieve directory entries
as well, and add getWagonWebDavTest.

Modified:
    maven/wagon/trunk/   (props changed)
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/pom.xml
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
    maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java

Propchange: maven/wagon/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sat Jan  3 13:25:34 2009
@@ -9,3 +9,4 @@
 *.iml
 *.ipr
 *.iws
+.metadata

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/pom.xml
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/pom.xml?rev=731091&r1=731090&r2=731091&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/pom.xml (original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/pom.xml Sat Jan  3 13:25:34
2009
@@ -53,22 +53,18 @@
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-webdav</artifactId>
-      <version>1.4</version>
+      <version>1.5.0</version>
       <exclusions>
         <exclusion>
-          <groupId>xerces</groupId>
-          <artifactId>xercesImpl</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>commons-collections</groupId>
-          <artifactId>commons-collections</artifactId>
+          <artifactId>commons-logging</artifactId>
+          <groupId>commons-logging</groupId>
         </exclusion>
       </exclusions>
     </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-nop</artifactId>
-      <version>1.5.0</version>
+      <version>1.5.3</version>
       <scope>runtime</scope>
     </dependency>
 

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java?rev=731091&r1=731090&r2=731091&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
Sat Jan  3 13:25:34 2009
@@ -218,11 +218,12 @@
                 method.releaseConnection();
         }
     }
-
+    
     public List getFileList( String destinationDirectory )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
-        final String url = getRepository().getUrl() + '/' + destinationDirectory;
+        String url = getRepository().getUrl() + '/' + destinationDirectory;
+        
         PropFindMethod method = null;
         try
         {
@@ -240,8 +241,26 @@
 
                     for ( int i = 0; i < multiStatus.getResponses().length; i++ )
                     {
+                        
                         MultiStatusResponse response = multiStatus.getResponses()[i];
-                        String fileName = PathUtils.filename( URLDecoder.decode( response.getHref()
) );
+                        
+                        String entryUrl =  response.getHref();
+                        String fileName = PathUtils.filename( URLDecoder.decode( entryUrl
) );
+                        if ( entryUrl.endsWith( "/" ) )
+                        {
+                            if ( i == 0 )
+                            {
+                                //by design jackrabbit webdav sticks parent directory as
the first entry 
+                                // so we need to ignore this entry
+                                // http://www.nabble.com/Extra-entry-in-get-file-list-with-jackrabbit-webdav-td21262786.html
+                                // http://www.webdav.org/specs/rfc4918.html#rfc.section.9.1
+                                continue;
+                            }
+                            
+                            //extract "dir/" part of "path.to.dir/"
+                            fileName = PathUtils.filename( PathUtils.dirname( URLDecoder.decode(
entryUrl ) ) ) + "/";
+                        }
+                        
                         if ( !StringUtils.isEmpty( fileName ) )
                         {
                             dirs.add( fileName );

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java?rev=731091&r1=731090&r2=731091&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
Sat Jan  3 13:25:34 2009
@@ -1,43 +1,42 @@
 package org.apache.maven.wagon.providers.webdav;
 
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information
regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version
2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain
a
+ * copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under
the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
+ * or implied. See the License for the specific language governing permissions and limitations
under
+ * the License.
  */
 
 import it.could.webdav.DAVServlet;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.List;
 import java.util.Properties;
 
+import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.StreamingWagon;
+import org.apache.maven.wagon.Wagon;
 import org.apache.maven.wagon.http.HttpWagonTestCase;
 import org.apache.maven.wagon.repository.Repository;
 import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.servlet.Context;
 import org.mortbay.jetty.servlet.ServletHolder;
 
-/**
+/*
  * WebDAV Wagon Test
  * 
  * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * 
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  */
 public class WebDavWagonTest
@@ -70,6 +69,7 @@
         return ( file.lastModified() / 1000 ) * 1000;
     }
 
+    
     private File getDavRepository()
     {
         return getTestFile( "target/test-output/http-repository/newfolder/folder2" );
@@ -134,4 +134,83 @@
     {
         ( (WebDavWagon) wagon ).setHttpHeaders( properties );
     }
+
+    /**
+     * Make sure wagon webdav can detect remote directory
+     * @throws Exception
+     */
+    public void testWagonWebDavGetFileList()
+        throws Exception
+    {
+        setupRepositories();
+
+        setupWagonTestingFixtures();
+
+        String dirName = "file-list";
+
+        String filenames[] = new String[] {
+            "test-resource.txt",
+            "test-resource.pom",
+            "test-resource b.txt",
+            "more-resources.dat" };
+
+        for ( int i = 0; i < filenames.length; i++ )
+        {
+            putFile( dirName + "/" + filenames[i], dirName + "/" + filenames[i], filenames[i]
+ "\n" );
+        }
+
+        String dirnames[] = new String[] {
+            "test-dir1",
+            "test-dir2"};
+
+        for ( int i = 0; i < dirnames.length; i++ )
+        {
+            new File( getDavRepository(), dirName + "/" + dirnames[i] ).mkdirs();
+        }
+
+        Wagon wagon = getWagon();
+
+        wagon.connect( testRepository, getAuthInfo() );
+
+        List list = wagon.getFileList( dirName );
+
+        assertNotNull( "file list should not be null.", list );
+        assertEquals( "file list should contain 6 items", 6, list.size() );
+
+        for ( int i = 0; i < filenames.length; i++ )
+        {
+            assertTrue( "Filename '" + filenames[i] + "' should be in list.", list.contains(
filenames[i] ) );
+        }
+
+        for ( int i = 0; i < dirnames.length; i++ )
+        {
+            assertTrue( "Directory '" + dirnames[i] + "' should be in list.", list.contains(
dirnames[i] + "/" ) );
+        }
+
+        ///////////////////////////////////////////////////////////////////////////
+        list = wagon.getFileList( "" );
+        assertNotNull( "file list should not be null.", list );
+        assertEquals( "file list should contain 1 items", 1, list.size() );
+
+        ///////////////////////////////////////////////////////////////////////////
+        list = wagon.getFileList( dirName + "/test-dir1" );
+        assertNotNull( "file list should not be null.", list );
+        assertEquals( "file list should contain 0 items", 0, list.size() );
+
+        /////////////////////////////////////////////////////////////////////////////
+        try
+        {
+            list = wagon.getFileList( dirName + "/test-dir-bogus" );
+            fail( "Exception expected" );
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+        
+        }
+        
+        wagon.disconnect();
+        
+
+        tearDownWagonTestingFixtures();
+    }
 }



---------------------------------------------------------------------
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