Moved repository servlet and tests

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@660786 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James William Dumay 2008-05-28 02:12:38 +00:00
parent dab0847560
commit a33faee5e0
34 changed files with 141 additions and 232 deletions

View File

@ -233,23 +233,6 @@
<artifactId>activation</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test Scoped -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>httpunit</groupId>
<artifactId>httpunit</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-quartz</artifactId>
@ -264,42 +247,6 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-taskqueue</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus.redback</groupId>
<artifactId>redback-keys-memory</artifactId>
<version>${redback.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus.redback</groupId>
<artifactId>redback-rbac-memory</artifactId>
<version>${redback.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus.redback</groupId>
<artifactId>redback-users-memory</artifactId>
<version>${redback.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>

View File

@ -1,72 +0,0 @@
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 org.apache.maven.archiva.webdav.util.MimeTypes;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import java.io.IOException;
import java.net.URL;
/**
* Custom Archiva MimeTypes loader for plexus-webdav's {@link MimeTypes}
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
* @todo Support custom mime types from archiva-configuration.
*
* @plexus.component role="org.apache.maven.archiva.web.repository.ArchivaMimeTypeLoader"
*/
public class ArchivaMimeTypeLoader
implements Initializable
{
/**
* @plexus.requirement
*/
private MimeTypes mimeTypes;
public void initialize()
throws InitializationException
{
// TODO: Make mime types loading configurable.
// Load the mime types from archiva location.
if ( mimeTypes.getMimeType( "sha1" ) == null )
{
URL url = this.getClass().getClassLoader().getResource( "/archiva-mime-types.txt" );
if ( url == null )
{
url = this.getClass().getClassLoader().getResource( "archiva-mime-types.txt" );
}
if ( url != null )
{
try
{
mimeTypes.load( url.openStream() );
}
catch ( IOException e )
{
throw new InitializationException( "Unable to load archiva-mime-types.txt : " + e.getMessage(), e );
}
}
}
}
}

View File

@ -1,75 +0,0 @@
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 org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
/**
* PolicingServletRequest is for policing the incoming request for naughty bits, such as a double slashes,
* or paths that include "/../" type syntax, or query string. Stripping out all things that are
* not appropriate.
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
*/
public class PolicingServletRequest
extends HttpServletRequestWrapper
implements HttpServletRequest
{
private String fixedPathInfo;
public PolicingServletRequest( HttpServletRequest originalRequest )
{
super( originalRequest );
fixedPathInfo = originalRequest.getPathInfo();
if ( StringUtils.isNotBlank( fixedPathInfo ) )
{
/* Perform a simple security normalization of the requested pathinfo.
* This is to cleanup requests that use "/../" or "///" type hacks.
*/
fixedPathInfo = FilenameUtils.normalize( fixedPathInfo );
if ( SystemUtils.IS_OS_WINDOWS )
{
// Adjust paths back to unix & url format expectations (when on windows)
fixedPathInfo = FilenameUtils.separatorsToUnix( fixedPathInfo );
}
}
}
@Override
public String getPathInfo()
{
return fixedPathInfo;
}
@Override
public String getQueryString()
{
// No query string allowed.
return null;
}
}

View File

@ -81,7 +81,7 @@
<servlet>
<servlet-name>RepositoryServlet</servlet-name>
<servlet-class>org.apache.maven.archiva.web.repository.RepositoryServlet</servlet-class>
<servlet-class>org.apache.maven.archiva.webdav.RepositoryServlet</servlet-class>
<!-- Loading this on startup so as to take advantage of configuration listeners -->
<load-on-startup>1</load-on-startup>
</servlet>

View File

@ -111,6 +111,52 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus.redback</groupId>
<artifactId>redback-keys-memory</artifactId>
<version>${redback.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus.redback</groupId>
<artifactId>redback-rbac-memory</artifactId>
<version>${redback.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus.redback</groupId>
<artifactId>redback-users-memory</artifactId>
<version>${redback.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<!-- Required by it.could classes -->

View File

@ -1,4 +1,4 @@
package org.apache.maven.archiva.web.repository;
package org.apache.maven.archiva.webdav;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -23,7 +23,6 @@
import org.apache.maven.archiva.configuration.ConfigurationEvent;
import org.apache.maven.archiva.configuration.ConfigurationListener;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.webdav.*;
import org.apache.jackrabbit.webdav.server.AbstractWebdavServlet;
import org.apache.jackrabbit.webdav.*;
import org.codehaus.plexus.spring.PlexusToSpringUtils;

View File

@ -1,4 +1,4 @@
package org.apache.maven.archiva.web.repository;
package org.apache.maven.archiva.webdav;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -29,12 +29,15 @@
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.maven.archiva.webdav.RepositoryServlet;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import junit.framework.Assert;
/**
* AbstractRepositoryServletTestCase
*
@ -85,13 +88,13 @@ protected void assertRepositoryValid( RepositoryServlet servlet, String repoId )
protected void assertResponseOK( WebResponse response )
{
assertNotNull( "Should have recieved a response", response );
assertEquals( "Should have been an OK response code.", HttpServletResponse.SC_OK, response.getResponseCode() );
Assert.assertEquals( "Should have been an OK response code.", HttpServletResponse.SC_OK, response.getResponseCode() );
}
protected void assertResponseNotFound( WebResponse response )
{
assertNotNull( "Should have recieved a response", response );
assertEquals( "Should have been an 404/Not Found response code.", HttpServletResponse.SC_NOT_FOUND, response
Assert.assertEquals( "Should have been an 404/Not Found response code.", HttpServletResponse.SC_NOT_FOUND, response
.getResponseCode() );
}
@ -173,7 +176,7 @@ protected void setUp()
@Override
protected String getPlexusConfigLocation()
{
return "org/apache/maven/archiva/web/repository/RepositoryServletTest.xml";
return "org/apache/maven/archiva/webdav/RepositoryServletTest.xml";
}
@Override

View File

@ -1,4 +1,4 @@
package org.apache.maven.archiva.web.repository;
package org.apache.maven.archiva.webdav;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -22,10 +22,9 @@
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.webdav.RepositoryServlet;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.HttpNotFoundException;
import com.meterware.httpunit.HttpUnitOptions;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;

View File

@ -1,4 +1,4 @@
package org.apache.maven.archiva.web.repository;
package org.apache.maven.archiva.webdav;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;

View File

@ -1,4 +1,4 @@
package org.apache.maven.archiva.web.repository;
package org.apache.maven.archiva.webdav;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -21,6 +21,7 @@
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.apache.maven.archiva.webdav.RepositoryServlet;
import javax.servlet.ServletConfig;

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%5p|%t|%5r|%-30c{1} - %m%n"/>
</layout>
</appender>
<!-- Help identify bugs during testing -->
<logger name="org.apache.maven.archiva">
<level value="info"/>
</logger>
<logger name="net.sf.ehcache">
<level value="warn"/>
</logger>
<logger name="org.codehaus.plexus.security">
<level value="info"/>
</logger>
<logger name="org.springframework">
<level value="error"/>
</logger>
<logger name="org.codehaus.plexus.spring">
<level value="error"/>
</logger>
<logger name="JPOX">
<level value="warn"/>
</logger>
<logger name="JPOX.MetaData">
<level value="error"/>
</logger>
<logger name="JPOX.RDBMS.SQL">
<level value="error"/>
</logger>
<logger name="SQL">
<level value="error"/>
</logger>
<root>
<priority value ="info" />
<appender-ref ref="console" />
</root>
</log4j:configuration>

View File

@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-parent</artifactId>
<version>3-SNAPSHOT</version>
<version>4-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<name>Archiva</name>
@ -184,6 +184,12 @@
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>httpunit</groupId>
<artifactId>httpunit</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>easymock</groupId>
<artifactId>easymock</artifactId>