* 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
public class ArchivaDavResourceFactory
implements DavResourceFactory, Auditable
{
+ private static final String HTTP_PUT_METHOD = "PUT";
+
private Logger log = LoggerFactory.getLogger( ArchivaDavResourceFactory.class );
/**
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 );
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;
/**
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 );
--- /dev/null
+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";
+ }
+}