public static final String REMOVE_FILE = "Removed File";
- public static final String MODIFY_FILE = "Modify File";
+ public static final String MODIFY_FILE = "Modified File";
+
+ public static final String MOVE_FILE = "Moved File";
+
+ public static final String MOVE_DIRECTORY = "Moved Directory";
+
+ public static final String COPY_DIRECTORY = "Copied Directory";
+
+ public static final String COPY_FILE = "Copied File";
public static final String UPLOAD_FILE = "Uploaded File";
* under the License.
*/
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.property.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.util.Text;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceIterator;
+import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
import org.apache.jackrabbit.webdav.io.InputContext;
import org.apache.jackrabbit.webdav.io.OutputContext;
-import org.apache.jackrabbit.webdav.lock.*;
-import org.apache.jackrabbit.util.Text;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.archiva.webdav.util.MimeTypes;
+import org.apache.jackrabbit.webdav.lock.ActiveLock;
+import org.apache.jackrabbit.webdav.lock.LockInfo;
+import org.apache.jackrabbit.webdav.lock.LockManager;
+import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.lock.Type;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.ResourceType;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+import org.apache.maven.archiva.repository.audit.AuditListener;
+import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers;
+import org.apache.maven.archiva.security.ArchivaXworkUser;
import org.apache.maven.archiva.webdav.util.IndexWriter;
+import org.apache.maven.archiva.webdav.util.MimeTypes;
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.ArrayList;
-import java.io.*;
+import com.opensymphony.xwork.ActionContext;
/**
* @author <a href="mailto:james@atlassian.com">James William Dumay</a> Portions from the Apache Jackrabbit Project
{
public static final String HIDDEN_PATH_PREFIX = ".";
- private final MimeTypes mimeTypes;
-
private final ArchivaDavResourceLocator locator;
private final DavResourceFactory factory;
private final String logicalResource;
- private DavPropertySet properties;
+ private DavPropertySet properties = null;
- private boolean propsInitialized = false;
-
private LockManager lockManager;
private final DavSession session;
+
+ private String remoteAddr;
+
+ private final ManagedRepositoryConfiguration repository;
+
+ private final RepositoryContentConsumers consumers;
+
+ private final MimeTypes mimeTypes;
+
+ private List<AuditListener> auditListeners;
- public ArchivaDavResource( String localResource,
- String logicalResource,
- MimeTypes mimeTypes,
- DavSession session,
- ArchivaDavResourceLocator locator,
- DavResourceFactory factory )
+ public ArchivaDavResource( String localResource, String logicalResource, ManagedRepositoryConfiguration repository,
+ DavSession session, ArchivaDavResourceLocator locator, DavResourceFactory factory,
+ MimeTypes mimeTypes, List<AuditListener> auditListeners,
+ RepositoryContentConsumers consumers )
{
- this.mimeTypes = mimeTypes;
- this.localResource = new File( localResource );
+ this.localResource = new File( localResource );
this.logicalResource = logicalResource;
this.locator = locator;
this.factory = factory;
this.session = session;
- this.properties = new DavPropertySet();
+
+ // TODO: push into locator as well as moving any references out of the resource factory
+ this.repository = repository;
+
+ // TODO: these should be pushed into the repository layer, along with the physical file operations in this class
+ this.mimeTypes = mimeTypes;
+ this.consumers = consumers;
+ this.auditListeners = auditListeners;
}
- public String getContentType()
+ public ArchivaDavResource( String localResource, String logicalResource, ManagedRepositoryConfiguration repository,
+ String remoteAddr, DavSession session, ArchivaDavResourceLocator locator,
+ DavResourceFactory factory, MimeTypes mimeTypes, List<AuditListener> auditListeners,
+ RepositoryContentConsumers consumers )
{
- return mimeTypes.getMimeType( localResource.getName() );
+ this( localResource, logicalResource, repository, session, locator, factory, mimeTypes, auditListeners,
+ consumers );
+
+ this.remoteAddr = remoteAddr;
}
public String getComplianceClass()
public long getModificationTime()
{
- initProperties();
return localResource.lastModified();
}
- public long getContentLength()
- {
- initProperties();
- return localResource.length();
- }
-
public void spool( OutputContext outputContext )
throws IOException
{
FileInputStream is = null;
try
{
- outputContext.setContentLength( getContentLength() );
- outputContext.setContentType( getContentType() );
+ outputContext.setContentLength( localResource.length() );
+ outputContext.setContentType( mimeTypes.getMimeType( localResource.getName() ) );
// Write content to stream
is = new FileInputStream( localResource );
public DavProperty getProperty( DavPropertyName name )
{
- initProperties();
- return properties.get( name );
+ return getProperties().get( name );
}
public DavPropertySet getProperties()
{
- initProperties();
- return properties;
+ return initProperties();
}
public void setProperty( DavProperty property )
return null;
}
+ @SuppressWarnings("unchecked")
public MultiStatusResponse alterProperties( List changeList )
throws DavException
{
throws DavException
{
File localFile = new File( localResource, resource.getDisplayName() );
+ boolean exists = localFile.exists();
+
if ( isCollection() && inputContext.hasStream() ) // New File
{
- boolean deleteFile = false;
FileOutputStream stream = null;
try
{
stream = new FileOutputStream( localFile );
IOUtils.copy( inputContext.getInputStream(), stream );
- if ( inputContext.getContentLength() != localFile.length() )
- {
- deleteFile = true;
- throw new DavException( HttpServletResponse.SC_BAD_REQUEST, "Content Header length was " +
- inputContext.getContentLength() + " but was " + localFile.length() );
- }
}
catch ( IOException e )
{
finally
{
IOUtils.closeQuietly( stream );
- if ( deleteFile )
- {
- FileUtils.deleteQuietly( localFile );
- }
}
+
+ if ( inputContext.getContentLength() != localFile.length() )
+ {
+ FileUtils.deleteQuietly( localFile );
+
+ throw new DavException( HttpServletResponse.SC_BAD_REQUEST, "Content Header length was " +
+ inputContext.getContentLength() + " but was " + localFile.length() );
+ }
+
+ // Just-in-time update of the index and database by executing the consumers for this artifact
+ consumers.executeConsumers( repository, localFile );
+
+ triggerAuditEvent( resource, exists ? AuditEvent.MODIFY_FILE : AuditEvent.CREATE_FILE );
}
else if ( !inputContext.hasStream() && isCollection() ) // New directory
{
localFile.mkdir();
+
+ triggerAuditEvent( resource, AuditEvent.CREATE_DIR );
}
else
{
public DavResourceIterator getMembers()
{
- ArrayList list = new ArrayList();
+ List<DavResource> list = new ArrayList<DavResource>();
if ( exists() && isCollection() )
{
for ( String item : localResource.list() )
locator.getFactory().createResourceLocator( locator.getPrefix(), path );
DavResource resource = factory.createResource( resourceLocator, session );
if ( resource != null )
+ {
list.add( resource );
+ }
}
}
catch ( DavException e )
{
if ( resource.isDirectory() )
{
- FileUtils.deleteDirectory(resource);
+ FileUtils.deleteDirectory( resource );
+
+ triggerAuditEvent( member, AuditEvent.REMOVE_DIR );
}
else
{
- if (!resource.delete())
+ if ( !resource.delete() )
{
- throw new IOException("Could not remove file");
+ throw new IOException( "Could not remove file" );
}
+
+ triggerAuditEvent( member, AuditEvent.REMOVE_FILE );
}
}
catch ( IOException e )
}
}
+ private void triggerAuditEvent( DavResource member, String event ) throws DavException
+ {
+ String path = logicalResource + "/" + member.getDisplayName();
+
+ triggerAuditEvent( checkDavResourceIsArchivaDavResource( member ).remoteAddr, locator.getRepositoryId(), path,
+ event );
+ }
+
public void move( DavResource destination )
throws DavException
{
if ( isCollection() )
{
FileUtils.moveDirectory( getLocalResource(), resource.getLocalResource() );
+
+ triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.MOVE_DIRECTORY );
}
else
{
FileUtils.moveFile( getLocalResource(), resource.getLocalResource() );
+
+ triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.MOVE_FILE );
}
}
catch ( IOException e )
if ( isCollection() )
{
FileUtils.copyDirectory( getLocalResource(), resource.getLocalResource() );
+
+ triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.COPY_DIRECTORY );
}
else
{
FileUtils.copyFile( getLocalResource(), resource.getLocalResource() );
+
+ triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.COPY_FILE );
}
}
catch ( IOException e )
/**
* Fill the set of properties
*/
- protected void initProperties()
+ protected DavPropertySet initProperties()
{
- if ( !exists() || propsInitialized )
+ if ( !exists() )
+ {
+ properties = new DavPropertySet();
+ }
+
+ if ( properties != null )
{
- return;
+ return properties;
}
+ DavPropertySet properties = new DavPropertySet();
+
// set (or reset) fundamental properties
if ( getDisplayName() != null )
{
properties.add( new DefaultDavProperty( DavPropertyName.CREATIONDATE, modifiedDate ) );
properties.add( new DefaultDavProperty( DavPropertyName.GETCONTENTLENGTH, localResource.length() ) );
-
- propsInitialized = true;
+
+ this.properties = properties;
+
+ return properties;
}
private ArchivaDavResource checkDavResourceIsArchivaDavResource( DavResource resource )
}
return (ArchivaDavResource) resource;
}
+
+ private void triggerAuditEvent( String remoteIP, String repositoryId, String resource, String action )
+ {
+ String activePrincipal = ArchivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() );
+ AuditEvent event = new AuditEvent( repositoryId, activePrincipal, resource, action );
+ event.setRemoteIP( remoteIP );
+
+ for ( AuditListener listener : auditListeners )
+ {
+ listener.auditEvent( event );
+ }
+ }
}
* under the License.
*/
-import com.opensymphony.xwork.ActionContext;
-import org.apache.jackrabbit.webdav.*;
-import org.apache.maven.archiva.repository.ManagedRepositoryContent;
-import org.apache.maven.archiva.repository.RepositoryNotFoundException;
-import org.apache.maven.archiva.repository.RepositoryException;
-import org.apache.maven.archiva.repository.RepositoryContentFactory;
-import org.apache.maven.archiva.repository.layout.LayoutException;
-import org.apache.maven.archiva.repository.content.RepositoryRequest;
-import org.apache.maven.archiva.repository.audit.AuditListener;
-import org.apache.maven.archiva.repository.audit.Auditable;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.metadata.MetadataTools;
-import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
-import org.apache.maven.archiva.webdav.util.WebdavMethodUtil;
-import org.apache.maven.archiva.webdav.util.MimeTypes;
-import org.apache.maven.archiva.webdav.util.RepositoryPathUtil;
-import org.apache.maven.archiva.proxy.RepositoryProxyConnectors;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.lock.LockManager;
+import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
import org.apache.maven.archiva.common.utils.PathUtil;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.maven.archiva.model.ProjectReference;
import org.apache.maven.archiva.model.VersionedReference;
import org.apache.maven.archiva.policies.ProxyDownloadException;
+import org.apache.maven.archiva.proxy.RepositoryProxyConnectors;
+import org.apache.maven.archiva.repository.ManagedRepositoryContent;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
+import org.apache.maven.archiva.repository.RepositoryException;
+import org.apache.maven.archiva.repository.RepositoryNotFoundException;
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+import org.apache.maven.archiva.repository.audit.AuditListener;
+import org.apache.maven.archiva.repository.audit.Auditable;
+import org.apache.maven.archiva.repository.content.RepositoryRequest;
+import org.apache.maven.archiva.repository.layout.LayoutException;
+import org.apache.maven.archiva.repository.metadata.MetadataTools;
+import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
+import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers;
import org.apache.maven.archiva.security.ArchivaXworkUser;
import org.apache.maven.archiva.security.ServletAuthenticator;
+import org.apache.maven.archiva.webdav.util.MimeTypes;
+import org.apache.maven.archiva.webdav.util.RepositoryPathUtil;
+import org.apache.maven.archiva.webdav.util.WebdavMethodUtil;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.Relocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.io.*;
-import org.apache.commons.lang.StringUtils;
-import org.apache.jackrabbit.webdav.lock.LockManager;
-import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
+import com.opensymphony.xwork.ActionContext;
/**
* @author <a href="mailto:james@atlassian.com">James William Dumay</a>
public class ArchivaDavResourceFactory
implements DavResourceFactory, Auditable
{
+ private static final String PROXIED_SUFFIX = " (proxied)";
+
private static final String HTTP_PUT_METHOD = "PUT";
private Logger log = LoggerFactory.getLogger( ArchivaDavResourceFactory.class );
* Lock Manager - use simple implementation from JackRabbit
*/
private final LockManager lockManager = new SimpleLockManager();
+
+ /** @plexus.requirement */
+ private RepositoryContentConsumers consumers;
public DavResource createResource( final DavResourceLocator locator, final DavServletRequest request,
final DavServletResponse response )
ArchivaDavResourceLocator archivaLocator = (ArchivaDavResourceLocator) locator;
RepositoryGroupConfiguration repoGroupConfig =
- archivaConfiguration.getConfiguration().getRepositoryGroupsAsMap().get(
- ( (RepositoryLocator) locator ).getRepositoryId() );
+ archivaConfiguration.getConfiguration().getRepositoryGroupsAsMap().get( archivaLocator.getRepositoryId() );
List<String> repositories = new ArrayList<String>();
boolean isGet = WebdavMethodUtil.isReadMethod( request.getMethod() );
}
else
{
- repositories.add( ( (RepositoryLocator) locator ).getRepositoryId() );
+ repositories.add( archivaLocator.getRepositoryId() );
}
//MRM-419 - Windows Webdav support. Should not 404 if there is no content.
String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource );
resource =
- new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource, mimeTypes, davSession, archivaLocator,
- this );
+ new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource,
+ managedRepository.getRepository(), davSession, archivaLocator, this, mimeTypes,
+ auditListeners, consumers );
}
resource.addLockManager(lockManager);
return resource;
{
File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource.getPath() );
ArchivaDavResource resource =
- new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(), mimeTypes, request.getDavSession(), locator, this );
+ new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(),
+ managedRepository.getRepository(), request.getRemoteAddr(),
+ request.getDavSession(), locator, this, mimeTypes, auditListeners, consumers );
if ( !resource.isCollection() )
{
+ boolean previouslyExisted = resourceFile.exists();
+
// At this point the incoming request can either be in default or
// legacy layout format.
boolean fromProxy = fetchContentFromProxies( managedRepository, request, logicalResource );
- boolean previouslyExisted = resourceFile.exists();
-
try
{
// Perform an adjustment of the resource to the managed
// Attempt to fetch the resource from any defined proxy.
if ( fromProxy )
{
- processAuditEvents( request, locator.getWorkspaceName(), logicalResource.getPath(), previouslyExisted,
- resourceFile, " (proxied)" );
+ String repositoryId = locator.getRepositoryId();
+ String event = ( previouslyExisted ? AuditEvent.MODIFY_FILE : AuditEvent.CREATE_FILE ) + PROXIED_SUFFIX;
+ triggerAuditEvent( request.getRemoteAddr(), repositoryId, logicalResource.getPath(), event );
}
- resource =
- new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(), mimeTypes, request.getDavSession(), locator,
- this );
if ( !resourceFile.exists() )
{
resource = null;
}
+ else
+ {
+ resource =
+ new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(),
+ managedRepository.getRepository(), request.getRemoteAddr(),
+ request.getDavSession(), locator, this, mimeTypes, auditListeners,
+ consumers );
+ }
}
return resource;
}
{
destDir.mkdirs();
String relPath = PathUtil.getRelative( rootDirectory.getAbsolutePath(), destDir );
- triggerAuditEvent( request, logicalResource.getPath(), relPath, AuditEvent.CREATE_DIR );
+ triggerAuditEvent( request.getRemoteAddr(), logicalResource.getPath(), relPath, AuditEvent.CREATE_DIR );
}
File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource.getPath() );
- boolean previouslyExisted = resourceFile.exists();
-
- processAuditEvents( request, locator.getRepositoryId(), logicalResource.getPath(), previouslyExisted,
- resourceFile, null );
-
- return new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(), mimeTypes, request.getDavSession(), locator,
- this );
+ return new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(),
+ managedRepository.getRepository(), request.getRemoteAddr(),
+ request.getDavSession(), locator, this, mimeTypes, auditListeners, consumers );
}
private boolean fetchContentFromProxies( ManagedRepositoryContent managedRepository, DavServletRequest request,
}
}
- private void processAuditEvents( DavServletRequest request, String repositoryId, String resource,
- boolean previouslyExisted, File resourceFile, String suffix )
+ // TODO: remove?
+ private void triggerAuditEvent( String remoteIP, String repositoryId, String resource, String action )
{
- if ( suffix == null )
- {
- suffix = "";
- }
-
- // Process Create Audit Events.
- if ( !previouslyExisted && resourceFile.exists() )
- {
- if ( resourceFile.isFile() )
- {
- triggerAuditEvent( request, repositoryId, resource, AuditEvent.CREATE_FILE + suffix );
- }
- else if ( resourceFile.isDirectory() )
- {
- triggerAuditEvent( request, repositoryId, resource, AuditEvent.CREATE_DIR + suffix );
- }
- }
- // Process Remove Audit Events.
- else if ( previouslyExisted && !resourceFile.exists() )
- {
- if ( resourceFile.isFile() )
- {
- triggerAuditEvent( request, repositoryId, resource, AuditEvent.REMOVE_FILE + suffix );
- }
- else if ( resourceFile.isDirectory() )
- {
- triggerAuditEvent( request, repositoryId, resource, AuditEvent.REMOVE_DIR + suffix );
- }
- }
- // Process modify events.
- else
- {
- if ( resourceFile.isFile() )
- {
- triggerAuditEvent( request, repositoryId, resource, AuditEvent.MODIFY_FILE + suffix );
- }
- }
- }
-
- private void triggerAuditEvent( String user, String remoteIP, String repositoryId, String resource, String action )
- {
- AuditEvent event = new AuditEvent( repositoryId, user, resource, action );
+ String activePrincipal = ArchivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() );
+ AuditEvent event = new AuditEvent( repositoryId, activePrincipal, resource, action );
event.setRemoteIP( remoteIP );
for ( AuditListener listener : auditListeners )
}
}
- private void triggerAuditEvent( DavServletRequest request, String repositoryId, String resource, String action )
- {
- triggerAuditEvent( ArchivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() ),
- getRemoteIP( request ), repositoryId, resource, action );
- }
-
- private String getRemoteIP( DavServletRequest request )
- {
- return request.getRemoteAddr();
- }
-
public void addAuditListener( AuditListener listener )
{
this.auditListeners.add( listener );
public class ArchivaDavResourceLocator
implements DavResourceLocator, RepositoryLocator
{
- private String prefix;
+ private final String prefix;
- private String resourcePath;
+ private final String resourcePath;
- private String href;
+ private final String href;
- private String repositoryId;
+ private final String repositoryId;
- private DavLocatorFactory davLocatorFactory;
+ private final DavLocatorFactory davLocatorFactory;
public ArchivaDavResourceLocator( String prefix, String resourcePath, String repositoryId,
DavLocatorFactory davLocatorFactory )
this.prefix = prefix;
this.repositoryId = repositoryId;
this.davLocatorFactory = davLocatorFactory;
- this.resourcePath = resourcePath;
+
+ String path = resourcePath;
if (!resourcePath.startsWith("/"))
{
- this.resourcePath = "/" + resourcePath;
+ path = "/" + resourcePath;
}
String escapedPath = Text.escapePath( resourcePath );
//Remove trailing slashes otherwise Text.getRelativeParent fails
if (resourcePath.endsWith("/") && resourcePath.length() > 1)
{
- this.resourcePath = resourcePath.substring( 0, resourcePath.length() - 1 );
+ path = resourcePath.substring( 0, resourcePath.length() - 1 );
}
+
+ this.resourcePath = path;
}
public String getRepositoryId()
* under the License.
*/
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavLocatorFactory;
+import org.apache.jackrabbit.webdav.DavMethods;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSessionProvider;
+import org.apache.jackrabbit.webdav.WebdavRequest;
+import org.apache.jackrabbit.webdav.WebdavRequestImpl;
+import org.apache.jackrabbit.webdav.WebdavResponse;
+import org.apache.jackrabbit.webdav.WebdavResponseImpl;
+import org.apache.jackrabbit.webdav.server.AbstractWebdavServlet;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationEvent;
import org.apache.maven.archiva.configuration.ConfigurationListener;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.jackrabbit.webdav.server.AbstractWebdavServlet;
-import org.apache.jackrabbit.webdav.*;
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+import org.apache.maven.archiva.security.ServletAuthenticator;
+import org.codehaus.plexus.redback.xwork.filter.authentication.HttpAuthenticator;
import org.codehaus.plexus.spring.PlexusToSpringUtils;
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-import org.apache.maven.archiva.security.ServletAuthenticator;
-import org.codehaus.plexus.redback.xwork.filter.authentication.HttpAuthenticator;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
/**
* RepositoryServlet
*/
import java.io.File;
+import java.util.List;
+
import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.DavResource;
import org.apache.jackrabbit.webdav.lock.Scope;
import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
import org.apache.jackrabbit.webdav.lock.Type;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.repository.audit.AuditListener;
+import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers;
import org.apache.maven.archiva.webdav.util.MimeTypes;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import org.codehaus.plexus.spring.PlexusToSpringUtils;
+import org.easymock.MockControl;
+
+import edu.emory.mathcs.backport.java.util.Collections;
public class DavResourceTest extends PlexusInSpringTestCase
{
private DavResource resource;
private LockManager lockManager;
-
+
+ private RepositoryContentConsumers consumers;
+
+ private ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
+
@Override
protected void setUp()
throws Exception
resource = getDavResource(resourceLocator.getHref(false), myResource);
lockManager = new SimpleLockManager();
resource.addLockManager(lockManager);
+ consumers = new RepositoryContentConsumers();
}
@Override
private DavResource getDavResource(String logicalPath, File file)
{
- return new ArchivaDavResource(file.getAbsolutePath(), logicalPath, mimeTypes, session, resourceLocator, resourceFactory);
+ return new ArchivaDavResource( file.getAbsolutePath(), logicalPath, repository, session, resourceLocator,
+ resourceFactory, mimeTypes, Collections.emptyList(), consumers );
}
public void testDeleteNonExistantResourceShould404()
}
public DavResource createResource(DavResourceLocator locator, DavSession session) throws DavException {
- return new ArchivaDavResource(baseDir.getAbsolutePath(), "/", mimeTypes, session, resourceLocator, resourceFactory);
+ return new ArchivaDavResource( baseDir.getAbsolutePath(), "/", repository, session, resourceLocator,
+ resourceFactory, mimeTypes, Collections.emptyList(), consumers );
}
}
}
<role-hint>basic</role-hint>
<field-name>httpAuth</field-name>
</requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers</role>
+ <role-hint>default</role-hint>
+ </requirement>
</requirements>
</component>
</components>