MRM-781 Removal of Archiva-Webdav implementation in favor of Jackrabbit-webdav

* I broke MRM-440, so this restores that functionality
* Locked down the enforcer plugin version so that Maven does not go looking for it everytime we build


git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@653817 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James William Dumay 2008-05-06 15:40:22 +00:00
parent f889364a39
commit 584bd356c2
7 changed files with 77 additions and 18 deletions

View File

@ -23,10 +23,7 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationEvent; import org.apache.maven.archiva.configuration.ConfigurationEvent;
import org.apache.maven.archiva.configuration.ConfigurationListener; import org.apache.maven.archiva.configuration.ConfigurationListener;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.webdav.ArchivaDavLocatorFactory; import org.apache.maven.archiva.webdav.*;
import org.apache.maven.archiva.webdav.ArchivaDavResourceFactory;
import org.apache.maven.archiva.webdav.ArchivaDavSessionProvider;
import org.apache.maven.archiva.webdav.UnauthorizedDavException;
import org.apache.jackrabbit.webdav.server.AbstractWebdavServlet; import org.apache.jackrabbit.webdav.server.AbstractWebdavServlet;
import org.apache.jackrabbit.webdav.*; import org.apache.jackrabbit.webdav.*;
import org.codehaus.plexus.redback.system.SecuritySystem; import org.codehaus.plexus.redback.system.SecuritySystem;
@ -121,7 +118,12 @@ public class RepositoryServlet
webdavResponse.setHeader("WWW-Authenticate", getAuthenticateHeaderValue(e.getRepositoryName())); webdavResponse.setHeader("WWW-Authenticate", getAuthenticateHeaderValue(e.getRepositoryName()));
webdavResponse.sendError(e.getErrorCode(), e.getStatusPhrase()); webdavResponse.sendError(e.getErrorCode(), e.getStatusPhrase());
} }
catch (DavException e) { catch (BrowserRedirectException e)
{
response.sendRedirect(e.getLocation());
}
catch (DavException e)
{
if (e.getErrorCode() == HttpServletResponse.SC_UNAUTHORIZED) { if (e.getErrorCode() == HttpServletResponse.SC_UNAUTHORIZED) {
final String msg = "Should throw " + UnauthorizedDavException.class.getName(); final String msg = "Should throw " + UnauthorizedDavException.class.getName();
log.error(msg); log.error(msg);

View File

@ -66,6 +66,4 @@ public class ArchivaDavLocatorFactory implements DavLocatorFactory
final String repository = RepositoryPathUtil.getRepositoryName(path); final String repository = RepositoryPathUtil.getRepositoryName(path);
return new ArchivaDavResourceLocator(prefix, path, repository, this); return new ArchivaDavResourceLocator(prefix, path, repository, this);
} }
} }

View File

@ -129,7 +129,14 @@ public class ArchivaDavResourceFactory implements DavResourceFactory, Auditable
{ {
throw new DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not get resource for method " + request.getMethod()); throw new DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not get resource for method " + request.getMethod());
} }
setHeaders(locator, response); setHeaders(locator, response);
//compatibility with MRM-440 to ensure browsing the repository works ok
if (resource.isCollection() && !resource.getLocator().getResourcePath().endsWith("/"))
{
throw new BrowserRedirectException(resource.getHref());
}
} }
return resource; return resource;
} }

View File

@ -43,14 +43,18 @@ public class ArchivaDavResourceLocator implements DavResourceLocator, Repository
this.prefix = prefix; this.prefix = prefix;
this.repositoryId = repositoryId; this.repositoryId = repositoryId;
this.davLocatorFactory = davLocatorFactory; this.davLocatorFactory = davLocatorFactory;
// remove trailing '/' that is not part of the resourcePath except for the root item.
if (resourcePath.endsWith("/") && !"/".equals(resourcePath)) {
resourcePath = resourcePath.substring(0, resourcePath.length()-1);
}
this.resourcePath = resourcePath; this.resourcePath = resourcePath;
href = prefix + Text.escapePath(resourcePath); String escapedPath = Text.escapePath(resourcePath);
String hrefPrefix = prefix;
//Ensure no extra slashes when href is joined
if (hrefPrefix.endsWith("/") && escapedPath.startsWith("/"))
{
hrefPrefix = hrefPrefix.substring(0, hrefPrefix.length()-1);
}
href = hrefPrefix + escapedPath;
} }
public String getRepositoryId() public String getRepositoryId()

View File

@ -0,0 +1,43 @@
package org.apache.maven.archiva.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.
*/
import org.apache.jackrabbit.webdav.DavException;
import javax.servlet.http.HttpServletResponse;
/**
* @author <a href="mailto:james@atlassian.com">James William Dumay</a>
*/
public class BrowserRedirectException extends DavException
{
final String location;
public BrowserRedirectException(String location)
{
super(HttpServletResponse.SC_MOVED_PERMANENTLY);
this.location = location;
}
public String getLocation()
{
return location;
}
}

View File

@ -40,7 +40,7 @@ public class ArchivaDavResourceLocatorTest extends TestCase
throws Exception throws Exception
{ {
String prefix = "http://myproxy/"; String prefix = "http://myproxy/";
String href = "repository/internal"; String href = "/repository/internal";
ArchivaDavResourceLocator locator = (ArchivaDavResourceLocator)factory.createResourceLocator(prefix, href); ArchivaDavResourceLocator locator = (ArchivaDavResourceLocator)factory.createResourceLocator(prefix, href);
assertEquals("internal", locator.getRepositoryId()); assertEquals("internal", locator.getRepositoryId());
@ -49,8 +49,8 @@ public class ArchivaDavResourceLocatorTest extends TestCase
assertEquals("http://myproxy/", locator.getPrefix()); assertEquals("http://myproxy/", locator.getPrefix());
assertEquals("http://myproxy/repository/internal", locator.getHref(false)); assertEquals("http://myproxy/repository/internal", locator.getHref(false));
assertEquals("http://myproxy/repository/internal/", locator.getHref(true)); assertEquals("http://myproxy/repository/internal/", locator.getHref(true));
assertEquals("repository/internal", locator.getResourcePath()); assertEquals("/repository/internal", locator.getResourcePath());
assertEquals("repository/internal", locator.getRepositoryPath()); assertEquals("/repository/internal", locator.getRepositoryPath());
} }
public void testLocatorWithHrefThatContainsPrefix() public void testLocatorWithHrefThatContainsPrefix()
@ -81,8 +81,8 @@ public class ArchivaDavResourceLocatorTest extends TestCase
assertEquals("", locator.getWorkspaceName()); assertEquals("", locator.getWorkspaceName());
assertEquals("", locator.getWorkspacePath()); assertEquals("", locator.getWorkspacePath());
assertEquals("http://myproxy/", locator.getPrefix()); assertEquals("http://myproxy/", locator.getPrefix());
assertEquals("http://myproxy//", locator.getHref(false)); assertEquals("http://myproxy/", locator.getHref(false));
assertEquals("http://myproxy//", locator.getHref(true)); assertEquals("http://myproxy/", locator.getHref(true));
assertEquals("/", locator.getResourcePath()); assertEquals("/", locator.getResourcePath());
assertEquals("/", locator.getRepositoryPath()); assertEquals("/", locator.getRepositoryPath());
} }

View File

@ -162,6 +162,11 @@
<jdkLevel>1.5</jdkLevel> <jdkLevel>1.5</jdkLevel>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0-alpha-3</version>
</plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>