mirror of https://github.com/apache/archiva.git
[MRM-408] make sure parent directories exist when making a PUT request
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@564508 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b674b6b9dc
commit
c6767af195
|
@ -18,7 +18,8 @@
|
||||||
~ under the License.
|
~ under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.apache.maven.archiva</groupId>
|
<groupId>org.apache.maven.archiva</groupId>
|
||||||
|
@ -211,6 +212,12 @@
|
||||||
<artifactId>activation</artifactId>
|
<artifactId>activation</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>httpunit</groupId>
|
||||||
|
<artifactId>httpunit</artifactId>
|
||||||
|
<version>1.6.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -392,7 +399,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<tasks>
|
<tasks>
|
||||||
<copy todir="${project.build.directory}/appserver-base">
|
<copy todir="${project.build.directory}/appserver-base">
|
||||||
<fileset dir="src/appserver-base" />
|
<fileset dir="src/appserver-base"/>
|
||||||
</copy>
|
</copy>
|
||||||
</tasks>
|
</tasks>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -133,6 +133,14 @@ public class ProxiedDavServer
|
||||||
fetchContentFromProxies( request );
|
fetchContentFromProxies( request );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File rootDirectory = getRootDirectory();
|
||||||
|
if ( rootDirectory != null )
|
||||||
|
{
|
||||||
|
new File( rootDirectory, request.getLogicalResource() ).getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
davServer.process( request, response );
|
davServer.process( request, response );
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package org.apache.maven.archiva.web.repository;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 com.meterware.httpunit.PutMethodWebRequest;
|
||||||
|
import com.meterware.httpunit.WebRequest;
|
||||||
|
import com.meterware.httpunit.WebResponse;
|
||||||
|
import com.meterware.servletunit.ServletRunner;
|
||||||
|
import com.meterware.servletunit.ServletUnitClient;
|
||||||
|
import org.codehaus.plexus.PlexusConstants;
|
||||||
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class RepositoryServletTest
|
||||||
|
extends PlexusTestCase
|
||||||
|
{
|
||||||
|
private ServletUnitClient sc;
|
||||||
|
|
||||||
|
private String appserverBase;
|
||||||
|
|
||||||
|
protected void setUp()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
super.setUp();
|
||||||
|
|
||||||
|
appserverBase = getTestFile( "target/appserver-base" ).getAbsolutePath();
|
||||||
|
System.setProperty( "appserver.base", appserverBase );
|
||||||
|
System.setProperty( "derby.system.home", appserverBase );
|
||||||
|
|
||||||
|
ServletRunner sr = new ServletRunner();
|
||||||
|
sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() );
|
||||||
|
sc = sr.newClient();
|
||||||
|
sc.getSession( true ).getServletContext().setAttribute( PlexusConstants.PLEXUS_KEY, getContainer() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPutWithMissingParentCollection()
|
||||||
|
throws IOException, SAXException
|
||||||
|
{
|
||||||
|
File repository = new File( appserverBase, "data/repositories/internal" );
|
||||||
|
FileUtils.deleteDirectory( repository );
|
||||||
|
|
||||||
|
WebRequest request = new PutMethodWebRequest( "http://localhost/repository/internal/path/to/artifact.jar",
|
||||||
|
getClass().getResourceAsStream( "/artifact.jar" ),
|
||||||
|
"application/octet-stream" );
|
||||||
|
WebResponse response = sc.getResponse( request );
|
||||||
|
assertNotNull( "No response received", response );
|
||||||
|
assertEquals( "file contents", "artifact.jar\n",
|
||||||
|
FileUtils.fileRead( new File( repository, "path/to/artifact.jar" ) ) );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.apache.maven.archiva.web.repository;
|
||||||
|
|
||||||
|
import org.codehaus.plexus.webdav.servlet.DavServerRequest;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class UnauthenticatedRepositoryServlet
|
||||||
|
extends RepositoryServlet
|
||||||
|
{
|
||||||
|
public boolean isAuthorized( DavServerRequest davRequest, HttpServletResponse response )
|
||||||
|
throws ServletException, IOException
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
artifact.jar
|
|
@ -8,7 +8,7 @@
|
||||||
~ "License"); you may not use this file except in compliance
|
~ "License"); you may not use this file except in compliance
|
||||||
~ with the License. You may obtain a copy of the License at
|
~ with the License. You may obtain a copy of the License at
|
||||||
~
|
~
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
~
|
~
|
||||||
~ Unless required by applicable law or agreed to in writing,
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
~ software distributed under the License is distributed on an
|
~ software distributed under the License is distributed on an
|
||||||
|
@ -25,72 +25,19 @@
|
||||||
-->
|
-->
|
||||||
<component>
|
<component>
|
||||||
<role>org.codehaus.plexus.logging.LoggerManager</role>
|
<role>org.codehaus.plexus.logging.LoggerManager</role>
|
||||||
<implementation>org.codehaus.plexus.logging.log4j.Log4JLoggerManager</implementation>
|
<implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation>
|
||||||
<lifecycle-handler>basic</lifecycle-handler>
|
<lifecycle-handler>basic</lifecycle-handler>
|
||||||
|
|
||||||
<configuration>
|
|
||||||
<threshold>DEBUG</threshold>
|
|
||||||
<default-appender>console</default-appender>
|
|
||||||
<appenders>
|
|
||||||
<appender>
|
|
||||||
<id>console</id>
|
|
||||||
<threshold>DEBUG</threshold>
|
|
||||||
<type>org.apache.log4j.ConsoleAppender</type>
|
|
||||||
<!-- <conversion-pattern>%d [%t] %-5p %-30c{1} - %m%n</conversion-pattern> -->
|
|
||||||
<conversion-pattern>%r [%t] %-5p %c %x - %m%n</conversion-pattern>
|
|
||||||
</appender>
|
|
||||||
</appenders>
|
|
||||||
<levels>
|
|
||||||
<!-- Help identify bugs during testing -->
|
|
||||||
<level>
|
|
||||||
<hierarchy>org.apache.maven</hierarchy>
|
|
||||||
<level>DEBUG</level>
|
|
||||||
</level>
|
|
||||||
<level>
|
|
||||||
<hierarchy>org.codehaus.plexus.security</hierarchy>
|
|
||||||
<level>DEBUG</level>
|
|
||||||
</level>
|
|
||||||
<!-- squelch noisy objects (for now) -->
|
|
||||||
<level>
|
|
||||||
<hierarchy>org.codehaus.plexus.mailsender.MailSender</hierarchy>
|
|
||||||
<level>INFO</level>
|
|
||||||
</level>
|
|
||||||
<level>
|
|
||||||
<hierarchy>org.quartz</hierarchy>
|
|
||||||
<level>INFO</level>
|
|
||||||
</level>
|
|
||||||
<level>
|
|
||||||
<hierarchy>org.apache.jasper</hierarchy>
|
|
||||||
<level>INFO</level>
|
|
||||||
</level>
|
|
||||||
<level>
|
|
||||||
<hierarchy>com.opensymphony.xwork</hierarchy>
|
|
||||||
<level>DEBUG</level>
|
|
||||||
</level>
|
|
||||||
<level>
|
|
||||||
<hierarchy>com.opensymphony.webwork</hierarchy>
|
|
||||||
<level>DEBUG</level>
|
|
||||||
</level>
|
|
||||||
<level>
|
|
||||||
<hierarchy>org.codehaus.plexus.PlexusContainer</hierarchy>
|
|
||||||
<level>INFO</level>
|
|
||||||
</level>
|
|
||||||
<level>
|
|
||||||
<hierarchy>JPOX</hierarchy>
|
|
||||||
<level>WARN</level>
|
|
||||||
</level>
|
|
||||||
<level>
|
|
||||||
<hierarchy>freemarker</hierarchy>
|
|
||||||
<level>WARN</level>
|
|
||||||
</level>
|
|
||||||
<level>
|
|
||||||
<hierarchy>freemarker</hierarchy>
|
|
||||||
<level>WARN</level>
|
|
||||||
</level>
|
|
||||||
</levels>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
<component>
|
||||||
|
<role>org.codehaus.plexus.webdav.DavServerManager</role>
|
||||||
|
<role-hint>default</role-hint>
|
||||||
|
<implementation>org.codehaus.plexus.webdav.DefaultDavServerManager</implementation>
|
||||||
|
<description>DefaultDavServerManager</description>
|
||||||
|
<configuration>
|
||||||
|
<provider-hint>proxied</provider-hint>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
|
|
||||||
<component>
|
<component>
|
||||||
<role>org.codehaus.plexus.jdo.JdoFactory</role>
|
<role>org.codehaus.plexus.jdo.JdoFactory</role>
|
||||||
|
@ -116,7 +63,7 @@
|
||||||
|
|
||||||
<!-- Apache Derby Configuration -->
|
<!-- Apache Derby Configuration -->
|
||||||
<driverName>org.apache.derby.jdbc.EmbeddedDriver</driverName>
|
<driverName>org.apache.derby.jdbc.EmbeddedDriver</driverName>
|
||||||
<url>jdbc:derby:${basedir}/target/repoaccess/database;create=true</url>
|
<url>jdbc:derby:${basedir}/target/appserver-base/database;create=true</url>
|
||||||
<userName>sa</userName>
|
<userName>sa</userName>
|
||||||
<password></password>
|
<password></password>
|
||||||
|
|
Loading…
Reference in New Issue