]> source.dussan.org Git - archiva.git/commitdiff
MRM-781 - Removal of Archiva-Webdav implementation in favor of Jackrabbit-webdav
authorJames William Dumay <jdumay@apache.org>
Wed, 4 Jun 2008 00:29:27 +0000 (00:29 +0000)
committerJames William Dumay <jdumay@apache.org>
Wed, 4 Jun 2008 00:29:27 +0000 (00:29 +0000)
* Changed so that non-existant parent directories are only created on PUT and not on MKCOL. This allows better litmus compliance.
* Added MkColMethodWebRequest which implements the MkCol method for HttpUnit
* Unit tests

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@662933 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletDeployTest.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/httpunit/MkColMethodWebRequest.java [new file with mode: 0644]

index 71ae2c27c93d58ca637b9fbb773f17ea88044a44..d73f4f1945be2d1f8bed9a03750b272bc3ab7dad 100644 (file)
@@ -78,6 +78,8 @@ import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
 public class ArchivaDavResourceFactory
     implements DavResourceFactory, Auditable
 {
+    private static final String HTTP_PUT_METHOD = "PUT";
+    
     private Logger log = LoggerFactory.getLogger( ArchivaDavResourceFactory.class );
 
     /**
@@ -321,7 +323,7 @@ public class ArchivaDavResourceFactory
 
         File rootDirectory = new File( managedRepository.getRepoRoot() );
         File destDir = new File( rootDirectory, logicalResource.getPath() ).getParentFile();
-        if ( !destDir.exists() )
+        if ( request.getMethod().equals(HTTP_PUT_METHOD) && !destDir.exists() )
         {
             destDir.mkdirs();
             String relPath = PathUtil.getRelative( rootDirectory.getAbsolutePath(), destDir );
index 32ef17d20366359b8fb4ac161da5401fcdb845ab..05c0db18db1c0129dac9c8364ea61eb9031baf21 100644 (file)
@@ -23,9 +23,11 @@ import com.meterware.httpunit.PutMethodWebRequest;
 import com.meterware.httpunit.WebRequest;
 import com.meterware.httpunit.WebResponse;
 
+import java.io.File;
 import java.io.InputStream;
 
 import javax.servlet.http.HttpServletResponse;
+import org.apache.maven.archiva.webdav.httpunit.MkColMethodWebRequest;
 
 
 /**
@@ -53,6 +55,23 @@ public class RepositoryServletDeployTest
         assertFileContents( "artifact.jar\n", repoRootInternal, "path/to/artifact.jar" );
     }
     
+    public void testMkColWithMissingParentCollectionFails()
+        throws Exception
+    {
+        setupCleanRepo( repoRootInternal );
+
+        String putUrl = "http://machine.com/repository/internal/path/to/";
+
+        WebRequest request = new MkColMethodWebRequest( putUrl );
+
+        WebResponse response = sc.getResponse( request );
+        
+        assertEquals(HttpServletResponse.SC_CONFLICT, response.getResponseCode());
+        
+        File mkColLocalPath = new File(repoRootInternal, "path/to/");
+        assertFalse(mkColLocalPath.exists());
+    }
+    
     protected void assertResponseCreated( WebResponse response )
     {
         assertNotNull( "Should have recieved a response", response );
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/httpunit/MkColMethodWebRequest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/httpunit/MkColMethodWebRequest.java
new file mode 100644 (file)
index 0000000..c2353a6
--- /dev/null
@@ -0,0 +1,39 @@
+package org.apache.maven.archiva.webdav.httpunit;
+
+/*
+ *  Copyright 2008 jdumay.
+ * 
+ *  Licensed 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.
+ *  under the License.
+ */
+
+import com.meterware.httpunit.HeaderOnlyWebRequest;
+import java.net.URL;
+
+/**
+ * MkColMethodWebRequest
+ * See RFC-2518 Section 8.3
+ * @author <a href="mailto:james@atlassian.com">James William Dumay</a>
+ */
+public class MkColMethodWebRequest extends HeaderOnlyWebRequest
+{
+    public MkColMethodWebRequest( String urlString )
+    {
+        super(urlString);
+    }
+
+    @Override
+    public String getMethod() {
+        return "MKCOL";
+    }
+}