Author: jdumay
Date: Tue May 6 06:32:28 2008
New Revision: 653769
URL: http://svn.apache.org/viewvc?rev=653769&view=rev
Log:
MRM-781 - Removal of Archiva-Webdav implementation in favor of Jackrabbit-webdav
* Implemented Webdav properties, including copy/move/delete operations
* Unit tested the DavResourceLocator and DavLocatorFactory implementations
(More tests on the way)
* Introduced joda-time dependency todo ISO8601 dates for the dav servlet
Added:
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryLocator.java
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocatorTest.java
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/pom.xml
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavLocatorFactory.java
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocator.java
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java
archiva/trunk/pom.xml
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml?rev=653769&r1=653768&r2=653769&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml Tue May 6
06:32:28 2008
@@ -209,6 +209,11 @@
<artifactId>archiva-webdav</artifactId>
</dependency>
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>2.5.1</version>
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java?rev=653769&r1=653768&r2=653769&view=diff
==============================================================================
---
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java
(original)
+++
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java
Tue May 6 06:32:28 2008
@@ -82,6 +82,8 @@
/**
* Service the given request.
+ * This method has been overridden and copy/pasted to allow better
exception handling
+ * and to support different realms
*
* @param request
* @param response
@@ -241,7 +243,7 @@
public String getAuthenticateHeaderValue()
{
- throw new UnsupportedOperationException("");
+ throw new UnsupportedOperationException();
}
public String getAuthenticateHeaderValue(String repository)
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webdav/pom.xml
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/pom.xml?rev=653769&r1=653768&r2=653769&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webdav/pom.xml (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webdav/pom.xml Tue May 6
06:32:28 2008
@@ -107,6 +107,10 @@
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ </dependency>
</dependencies>
<!-- Required by it.could classes -->
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavLocatorFactory.java
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavLocatorFactory.java?rev=653769&r1=653768&r2=653769&view=diff
==============================================================================
---
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavLocatorFactory.java
(original)
+++
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavLocatorFactory.java
Tue May 6 06:32:28 2008
@@ -51,9 +51,8 @@
href = "/";
}
- final String workspaceName =
RepositoryPathUtil.getRepositoryName(href);
-
- return new ArchivaDavResourceLocator(b.toString(),
Text.unescape(href), workspaceName, this);
+ final String repository = RepositoryPathUtil.getRepositoryName(href);
+ return new ArchivaDavResourceLocator(b.toString(),
Text.unescape(href), repository, this);
}
public DavResourceLocator createResourceLocator(String prefix, String
workspacePath, String resourcePath)
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java?rev=653769&r1=653768&r2=653769&view=diff
==============================================================================
---
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
(original)
+++
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
Tue May 6 06:32:28 2008
@@ -20,10 +20,7 @@
*/
import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.property.DavPropertySet;
-import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
-import org.apache.jackrabbit.webdav.property.DavProperty;
-import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.*;
import org.apache.jackrabbit.webdav.io.InputContext;
import org.apache.jackrabbit.webdav.io.OutputContext;
import org.apache.jackrabbit.webdav.lock.*;
@@ -32,25 +29,29 @@
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.webdav.util.MimeTypes;
import org.apache.maven.archiva.webdav.util.IndexWriter;
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.ISODateTimeFormat;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
-import java.util.Date;
+import java.util.ArrayList;
import java.io.*;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">James William Dumay</a>
+ * Portions from the Apache Jackrabbit Project
*/
public class ArchivaDavResource implements DavResource
{
+ public static final String HIDDEN_PATH_PREFIX = ".";
+
private final MimeTypes mimeTypes;
- private final DavResourceLocator locator;
+ private final ArchivaDavResourceLocator locator;
private final DavResourceFactory factory;
- private final DavSession session;
-
private final File localResource;
private final String logicalResource;
@@ -61,14 +62,15 @@
private DavPropertySet properties;
- public ArchivaDavResource(String localResource, String logicalResource,
MimeTypes mimeTypes, DavResourceLocator locator, DavResourceFactory factory,
DavSession session)
+ private boolean propsInitialized = false;
+
+ public ArchivaDavResource(String localResource, String logicalResource,
MimeTypes mimeTypes, ArchivaDavResourceLocator locator, DavResourceFactory
factory)
{
this.mimeTypes = mimeTypes;
this.localResource = new File(localResource);
this.logicalResource = logicalResource;
this.locator = locator;
this.factory = factory;
- this.session = session;
this.properties = new DavPropertySet();
}
@@ -108,6 +110,11 @@
return locator;
}
+ public File getLocalResource()
+ {
+ return localResource;
+ }
+
public String getResourcePath()
{
return locator.getResourcePath();
@@ -120,11 +127,13 @@
public long getModificationTime()
{
+ initProperties();
return localResource.lastModified();
}
public long getContentLength()
{
+ initProperties();
return localResource.length();
}
@@ -132,20 +141,20 @@
{
if (!isCollection())
{
- FileInputStream is = null;
- try
- {
- outputContext.setContentLength(getContentLength());
- outputContext.setContentType(getContentType());
+ FileInputStream is = null;
+ try
+ {
+ outputContext.setContentLength(getContentLength());
+ outputContext.setContentType(getContentType());
- //Write content to stream
- is = new FileInputStream(localResource);
- IOUtils.copy(is, outputContext.getOutputStream());
- }
- finally
- {
- IOUtils.closeQuietly(is);
- }
+ //Write content to stream
+ is = new FileInputStream(localResource);
+ IOUtils.copy(is,
outputContext.getOutputStream());
+ }
+ finally
+ {
+ IOUtils.closeQuietly(is);
+ }
}
else
{
@@ -156,16 +165,18 @@
public DavPropertyName[] getPropertyNames()
{
- return new DavPropertyName[0];
+ return getProperties().getPropertyNames();
}
public DavProperty getProperty(DavPropertyName name)
{
- return null;
+ initProperties();
+ return properties.get(name);
}
public DavPropertySet getProperties()
{
+ initProperties();
return properties;
}
@@ -195,9 +206,9 @@
if (parentPath.equals("")) {
parentPath = "/";
}
- DavResourceLocator parentloc =
locator.getFactory().createResourceLocator(locator.getPrefix(),
locator.getWorkspacePath(), parentPath);
+ DavResourceLocator parentloc =
locator.getFactory().createResourceLocator(locator.getPrefix(), parentPath);
try {
- parent = factory.createResource(parentloc, session);
+ parent = factory.createResource(parentloc, null);
} catch (DavException e) {
// should not occur
}
@@ -208,7 +219,7 @@
public void addMember(DavResource resource, InputContext inputContext)
throws DavException
{
File localFile = new File(localResource, resource.getDisplayName());
- if (!resource.isCollection() && isCollection() &&
inputContext.hasStream()) //New File
+ if (isCollection() && inputContext.hasStream()) //New File
{
boolean deleteFile = false;
FileOutputStream stream = null;
@@ -236,7 +247,7 @@
}
}
}
- else if (resource.isCollection() && isCollection()) //New directory
+ else if (!inputContext.hasStream() && isCollection()) //New directory
{
localFile.mkdir();
}
@@ -249,19 +260,118 @@
public DavResourceIterator getMembers()
{
- return null;
+ ArrayList list = new ArrayList();
+ if (exists() && isCollection())
+ {
+ for (String item : localResource.list())
+ {
+ try
+ {
+ if (!item.startsWith(HIDDEN_PATH_PREFIX))
+ {
+ String path = locator.getResourcePath() + '/' + item;
+ DavResourceLocator resourceLocator =
locator.getFactory().createResourceLocator(locator.getPrefix(), path);
+ DavResource resource =
factory.createResource(resourceLocator, null);
+ if (resource != null) list.add(resource);
+ }
+ }
+ catch (DavException e)
+ {
+ //Should not occur
+ }
+ }
+ }
+ return new DavResourceIteratorImpl(list);
}
public void removeMember(DavResource member) throws DavException
{
+ File localResource =
checkDavResourceIsArchivaDavResource(member).getLocalResource();
+
+ if (!localResource.exists())
+ {
+ throw new DavException(HttpServletResponse.SC_NOT_FOUND,
member.getResourcePath());
+ }
+
+ boolean suceeded = false;
+
+ if (localResource.isDirectory())
+ {
+ try
+ {
+ FileUtils.deleteDirectory(localResource);
+ suceeded = true;
+ }
+ catch (IOException e)
+ {
+ throw new
DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
+ }
+ }
+
+ if (!suceeded && localResource.isFile())
+ {
+ suceeded = localResource.delete();
+ }
+
+ if (!suceeded)
+ {
+ throw new
DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not delete
resource " + member.getResourcePath());
+ }
}
public void move(DavResource destination) throws DavException
{
+ if (!exists())
+ {
+ throw new DavException(HttpServletResponse.SC_NOT_FOUND, "Resource
to copy does not exist.");
+ }
+
+ try
+ {
+ ArchivaDavResource localResource =
checkDavResourceIsArchivaDavResource(destination);
+ if (isCollection())
+ {
+ FileUtils.moveDirectory(getLocalResource(),
localResource.getLocalResource());
+ }
+ else
+ {
+ FileUtils.moveFile(getLocalResource(),
localResource.getLocalResource());
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new
DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
+ }
}
public void copy(DavResource destination, boolean shallow) throws
DavException
{
+ if (!exists())
+ {
+ throw new DavException(HttpServletResponse.SC_NOT_FOUND, "Resource
to copy does not exist.");
+ }
+
+ if (shallow && isCollection())
+ {
+ throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to
perform shallow copy for collection");
+ }
+
+ try
+ {
+ ArchivaDavResource localResource =
checkDavResourceIsArchivaDavResource(destination);
+ if (isCollection())
+ {
+ FileUtils.copyDirectory(getLocalResource(),
localResource.getLocalResource());
+ }
+ else
+ {
+ FileUtils.copyFile(getLocalResource(),
localResource.getLocalResource());
+ }
+ }
+ catch ( IOException e)
+ {
+ throw new
DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
+ }
}
public boolean isLockable(Type type, Scope scope)
@@ -309,6 +419,52 @@
public DavSession getSession()
{
- return session;
+ return null;
+ }
+
+ /**
+ * Fill the set of properties
+ */
+ protected void initProperties() {
+ if (!exists() || propsInitialized) {
+ return;
+ }
+
+ // set (or reset) fundamental properties
+ if (getDisplayName() != null) {
+ properties.add(new DefaultDavProperty(DavPropertyName.DISPLAYNAME,
getDisplayName()));
+ }
+ if (isCollection()) {
+ properties.add(new ResourceType(ResourceType.COLLECTION));
+ // Windows XP support
+ properties.add(new
DefaultDavProperty(DavPropertyName.ISCOLLECTION, "1"));
+ } else {
+ properties.add(new ResourceType(ResourceType.DEFAULT_RESOURCE));
+
+ // Windows XP support
+ properties.add(new
DefaultDavProperty(DavPropertyName.ISCOLLECTION, "0"));
+ }
+
+ //Need to get the ISO8601 date for properties
+ DateTime dt = new DateTime(localResource.lastModified());
+ DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
+ String modifiedDate = fmt.print(dt);
+
+ properties.add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED,
modifiedDate));
+
+ properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE,
modifiedDate));
+
+ properties.add(new
DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, localResource.length()));
+
+ propsInitialized = true;
+ }
+
+ private ArchivaDavResource
checkDavResourceIsArchivaDavResource(DavResource resource) throws DavException
+ {
+ if (!(resource instanceof ArchivaDavResource))
+ {
+ throw new
DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "DavResource is not
instance of ArchivaDavResource");
+ }
+ return (ArchivaDavResource)resource;
}
}
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java?rev=653769&r1=653768&r2=653769&view=diff
==============================================================================
---
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
(original)
+++
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
Tue May 6 06:32:28 2008
@@ -51,7 +51,6 @@
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletException;
import java.util.ArrayList;
import java.util.List;
import java.io.*;
@@ -96,53 +95,65 @@
public DavResource createResource(final DavResourceLocator locator, final
DavServletRequest request, final DavServletResponse response) throws
DavException
{
- final ManagedRepositoryContent managedRepository =
getManagedRepository(locator.getWorkspaceName());
- final LogicalResource logicalResource = new
LogicalResource(RepositoryPathUtil.getLogicalResource(locator.getResourcePath()));
+ checkLocatorIsInstanceOfRepositoryLocator(locator);
+ ArchivaDavResourceLocator archivaLocator =
(ArchivaDavResourceLocator)locator;
DavResource resource = null;
- if (managedRepository != null)
+ if
(!locator.getResourcePath().startsWith(ArchivaDavResource.HIDDEN_PATH_PREFIX))
{
- final boolean isGet = WebdavMethodUtil.isReadMethod(
request.getMethod() );
- final boolean isPut = WebdavMethodUtil.isWriteMethod(
request.getMethod() );
+ final ManagedRepositoryContent managedRepository =
getManagedRepository(((RepositoryLocator)locator).getRepositoryId());
- if (isGet)
+ if (managedRepository != null)
{
- resource = doGet(managedRepository, request, locator,
logicalResource);
- }
+ LogicalResource logicalResource = new
LogicalResource(RepositoryPathUtil.getLogicalResource(locator.getResourcePath()));
+ boolean isGet = WebdavMethodUtil.isReadMethod(
request.getMethod() );
+ boolean isPut = WebdavMethodUtil.isWriteMethod(
request.getMethod() );
+
+ if (isGet)
+ {
+ resource = doGet(managedRepository, request,
archivaLocator, logicalResource);
+ }
- if (isPut)
+ if (isPut)
+ {
+ resource = doPut(managedRepository, request,
archivaLocator, logicalResource);
+ }
+ }
+ else
{
- resource = doPut(managedRepository, request, locator,
logicalResource);
+ throw new DavException(HttpServletResponse.SC_NOT_FOUND,
"Repository does not exist");
}
- }
- else
- {
- throw new DavException(HttpServletResponse.SC_NOT_FOUND,
"Repository does not exist");
- }
- if (resource != null)
- {
+ if (resource == null)
+ {
+ throw new
DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not get
resource for method " + request.getMethod());
+ }
setHeaders(locator, response);
- return resource;
}
-
- throw new DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"Could not get resource for method " + request.getMethod());
+ return resource;
}
public DavResource createResource(final DavResourceLocator locator, final
DavSession davSession) throws DavException
{
- final ManagedRepositoryContent managedRepository =
getManagedRepository(locator.getWorkspaceName());
- final String logicalResource =
RepositoryPathUtil.getLogicalResource(locator.getResourcePath());
- final File resourceFile = new File ( managedRepository.getRepoRoot(),
logicalResource);
-
- return new ArchivaDavResource(resourceFile.getAbsolutePath(),
logicalResource, mimeTypes, locator, this, null);
+ checkLocatorIsInstanceOfRepositoryLocator(locator);
+ ArchivaDavResourceLocator archivaLocator =
(ArchivaDavResourceLocator)locator;
+
+ DavResource resource = null;
+ if
(!locator.getResourcePath().startsWith(ArchivaDavResource.HIDDEN_PATH_PREFIX))
+ {
+ ManagedRepositoryContent managedRepository =
getManagedRepository(archivaLocator.getRepositoryId());
+ String logicalResource =
RepositoryPathUtil.getLogicalResource(locator.getResourcePath());
+ File resourceFile = new File ( managedRepository.getRepoRoot(),
logicalResource);
+ resource = new ArchivaDavResource(resourceFile.getAbsolutePath(),
logicalResource, mimeTypes, archivaLocator, this);
+ }
+ return resource;
}
- private DavResource doGet(ManagedRepositoryContent managedRepository,
DavServletRequest request, DavResourceLocator locator, LogicalResource
logicalResource) throws DavException
+ private DavResource doGet(ManagedRepositoryContent managedRepository,
DavServletRequest request, ArchivaDavResourceLocator locator, LogicalResource
logicalResource) throws DavException
{
File resourceFile = new File ( managedRepository.getRepoRoot(),
logicalResource.getPath());
- ArchivaDavResource resource = new
ArchivaDavResource(resourceFile.getAbsolutePath(), logicalResource.getPath(),
mimeTypes, locator, this, null);
+ ArchivaDavResource resource = new
ArchivaDavResource(resourceFile.getAbsolutePath(), logicalResource.getPath(),
mimeTypes, locator, this);
if ( !resource.isCollection() )
{
@@ -173,12 +184,12 @@
{
processAuditEvents(request, locator.getWorkspaceName(),
logicalResource.getPath(), previouslyExisted, resourceFile, " (proxied)");
}
- resource = new ArchivaDavResource(resourceFile.getAbsolutePath(),
logicalResource.getPath(), mimeTypes, locator, this, null);
+ resource = new ArchivaDavResource(resourceFile.getAbsolutePath(),
logicalResource.getPath(), mimeTypes, locator, this);
}
return resource;
}
- private DavResource doPut(ManagedRepositoryContent managedRepository,
DavServletRequest request, DavResourceLocator locator, LogicalResource
logicalResource) throws DavException
+ private DavResource doPut(ManagedRepositoryContent managedRepository,
DavServletRequest request, ArchivaDavResourceLocator locator, LogicalResource
logicalResource) throws DavException
{
/*
* Create parent directories that don't exist when writing a file
@@ -194,8 +205,7 @@
if ( !destDir.exists() )
{
destDir.mkdirs();
- String relPath =
- PathUtil.getRelative( rootDirectory.getAbsolutePath(), destDir
);
+ String relPath = PathUtil.getRelative(
rootDirectory.getAbsolutePath(), destDir );
triggerAuditEvent(request, logicalResource.getPath(), relPath,
AuditEvent.CREATE_DIR );
}
@@ -203,9 +213,9 @@
boolean previouslyExisted = resourceFile.exists();
- processAuditEvents(request, locator.getWorkspaceName(),
logicalResource.getPath(), previouslyExisted, resourceFile, null );
+ processAuditEvents(request, locator.getRepositoryId(),
logicalResource.getPath(), previouslyExisted, resourceFile, null );
- return new ArchivaDavResource(resourceFile.getAbsolutePath(),
logicalResource.getPath(), mimeTypes, locator, this, null);
+ return new ArchivaDavResource(resourceFile.getAbsolutePath(),
logicalResource.getPath(), mimeTypes, locator, this);
}
private boolean fetchContentFromProxies( ManagedRepositoryContent
managedRepository, DavServletRequest request, LogicalResource resource )
@@ -478,6 +488,14 @@
return null;
}
+ private void checkLocatorIsInstanceOfRepositoryLocator(DavResourceLocator
locator) throws DavException
+ {
+ if (!(locator instanceof RepositoryLocator))
+ {
+ throw new
DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Locator does not
implement RepositoryLocator");
+ }
+ }
+
class LogicalResource
{
private String path;
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocator.java
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocator.java?rev=653769&r1=653768&r2=653769&view=diff
==============================================================================
---
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocator.java
(original)
+++
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocator.java
Tue May 6 06:32:28 2008
@@ -26,7 +26,7 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">James William Dumay</a>
*/
-public class ArchivaDavResourceLocator implements DavResourceLocator
+public class ArchivaDavResourceLocator implements DavResourceLocator,
RepositoryLocator
{
private String prefix;
@@ -34,14 +34,14 @@
private String href;
- private String workspaceName;
+ private String repositoryId;
private DavLocatorFactory davLocatorFactory;
- public ArchivaDavResourceLocator(String prefix, String resourcePath,
String workspaceName, DavLocatorFactory davLocatorFactory)
+ public ArchivaDavResourceLocator(String prefix, String resourcePath,
String repositoryId, DavLocatorFactory davLocatorFactory)
{
this.prefix = prefix;
- this.workspaceName = workspaceName;
+ this.repositoryId = repositoryId;
this.davLocatorFactory = davLocatorFactory;
// remove trailing '/' that is not part of the resourcePath except for
the root item.
@@ -53,6 +53,11 @@
href = prefix + Text.escapePath(resourcePath);
}
+ public String getRepositoryId()
+ {
+ return repositoryId;
+ }
+
public String getPrefix()
{
return prefix;
@@ -70,7 +75,7 @@
public String getWorkspaceName()
{
- return workspaceName;
+ return "";
}
public boolean isSameWorkspace(DavResourceLocator locator)
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java?rev=653769&r1=653768&r2=653769&view=diff
==============================================================================
---
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java
(original)
+++
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java
Tue May 6 06:32:28 2008
@@ -134,7 +134,6 @@
}
catch ( AuthorizationException e )
{
- log.error(e.getMessage(), e);
throw new
DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Fatal Authorization
Subsystem Error." );
}
Added:
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryLocator.java
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryLocator.java?rev=653769&view=auto
==============================================================================
---
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryLocator.java
(added)
+++
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryLocator.java
Tue May 6 06:32:28 2008
@@ -0,0 +1,28 @@
+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.
+ */
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]">James William Dumay</a>
+ */
+public interface RepositoryLocator
+{
+ String getRepositoryId();
+}
Added:
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocatorTest.java
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocatorTest.java?rev=653769&view=auto
==============================================================================
---
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocatorTest.java
(added)
+++
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocatorTest.java
Tue May 6 06:32:28 2008
@@ -0,0 +1,89 @@
+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 junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]">James William Dumay</a>
+ */
+public class ArchivaDavResourceLocatorTest extends TestCase
+{
+ ArchivaDavLocatorFactory factory;
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ factory = new ArchivaDavLocatorFactory();
+ }
+
+ public void testLocatorWithPrefixHref()
+ throws Exception
+ {
+ String prefix = "http://myproxy/";
+ String href = "repository/internal";
+ ArchivaDavResourceLocator locator =
(ArchivaDavResourceLocator)factory.createResourceLocator(prefix, href);
+
+ assertEquals("internal", locator.getRepositoryId());
+ assertEquals("", locator.getWorkspaceName());
+ assertEquals("", locator.getWorkspacePath());
+ assertEquals("http://myproxy/", locator.getPrefix());
+ assertEquals("http://myproxy/repository/internal",
locator.getHref(false));
+ assertEquals("http://myproxy/repository/internal/",
locator.getHref(true));
+ assertEquals("repository/internal", locator.getResourcePath());
+ assertEquals("repository/internal", locator.getRepositoryPath());
+ }
+
+ public void testLocatorWithHrefThatContainsPrefix()
+ throws Exception
+ {
+ String prefix = "http://myproxy/";
+ String href = "http://myproxy/repository/internal";
+ ArchivaDavResourceLocator locator =
(ArchivaDavResourceLocator)factory.createResourceLocator(prefix, href);
+
+ assertEquals("internal", locator.getRepositoryId());
+ assertEquals("", locator.getWorkspaceName());
+ assertEquals("", locator.getWorkspacePath());
+ assertEquals("http://myproxy/", locator.getPrefix());
+ assertEquals("http://myproxy/repository/internal",
locator.getHref(false));
+ assertEquals("http://myproxy/repository/internal/",
locator.getHref(true));
+ assertEquals("repository/internal", locator.getResourcePath());
+ assertEquals("repository/internal", locator.getRepositoryPath());
+ }
+
+ public void testLocatorWithRootHref()
+ throws Exception
+ {
+ String prefix = "http://myproxy/";
+ String href = "/";
+ ArchivaDavResourceLocator locator =
(ArchivaDavResourceLocator)factory.createResourceLocator(prefix, href);
+
+ assertEquals("", locator.getRepositoryId());
+ assertEquals("", locator.getWorkspaceName());
+ assertEquals("", locator.getWorkspacePath());
+ assertEquals("http://myproxy/", locator.getPrefix());
+ assertEquals("http://myproxy//", locator.getHref(false));
+ assertEquals("http://myproxy//", locator.getHref(true));
+ assertEquals("/", locator.getResourcePath());
+ assertEquals("/", locator.getRepositoryPath());
+ }
+}
Modified: archiva/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/archiva/trunk/pom.xml?rev=653769&r1=653768&r2=653769&view=diff
==============================================================================
--- archiva/trunk/pom.xml (original)
+++ archiva/trunk/pom.xml Tue May 6 06:32:28 2008
@@ -756,6 +756,11 @@
<artifactId>xmlunit</artifactId>
<version>1.0</version>
</dependency>
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <version>1.5.2</version>
+ </dependency>
</dependencies>
</dependencyManagement>
<properties>