final DavServletResponse response )
throws DavException
{
ArchivaDavResourceLocator archivaLocator = checkLocatorIsInstanceOfRepositoryLocator( locator );
RepositoryGroupConfiguration repoGroupConfig =
archivaConfiguration.getConfiguration().getRepositoryGroupsAsMap().get( archivaLocator.getRepositoryId() );
String activePrincipal = getActivePrincipal( request );
List<String> resourcesInAbsolutePath = new ArrayList<String>();
boolean readMethod = WebdavMethodUtil.isReadMethod( request.getMethod() );
DavResource resource;
if ( repoGroupConfig != null )
{
if ( !readMethod )
{
throw new DavException( HttpServletResponse.SC_METHOD_NOT_ALLOWED,
"Write method not allowed for repository groups." );
}
log.debug( "Repository group '{}' accessed by '{}", repoGroupConfig.getId(), activePrincipal );
// handle browse requests for virtual repos
if ( getLogicalResource( archivaLocator, null, true ).endsWith( "/" ) )
{
try
{
return getResourceFromGroup( request, repoGroupConfig.getRepositories(), archivaLocator,
repoGroupConfig );
}
catch ( RepositoryAdminException e )
{
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
}
}
else
{
// make a copy to avoid potential concurrent modifications (eg. by configuration)
// TODO: ultimately, locking might be more efficient than copying in this fashion since updates are
// infrequent
List<String> repositories = new ArrayList<String>( repoGroupConfig.getRepositories() );
resource = processRepositoryGroup( request, archivaLocator, repositories, activePrincipal,
resourcesInAbsolutePath, repoGroupConfig );
}
}
else
{
try
{
RemoteRepository remoteRepository =
remoteRepositoryAdmin.getRemoteRepository( archivaLocator.getRepositoryId() );
if ( remoteRepository != null )
{
String logicalResource = getLogicalResource( archivaLocator, null, false );
IndexingContext indexingContext = remoteRepositoryAdmin.createIndexContext( remoteRepository );
File resourceFile = StringUtils.equals( logicalResource, "/" )
? new File( indexingContext.getIndexDirectoryFile().getParent() )
: new File( indexingContext.getIndexDirectoryFile().getParent(), logicalResource );
resource = new ArchivaDavResource( resourceFile.getAbsolutePath(), locator.getResourcePath(), null,
request.getRemoteAddr(), activePrincipal,
request.getDavSession(), archivaLocator, this, mimeTypes,
auditListeners, scheduler, fileLockManager );
setHeaders( response, locator, resource );
return resource;
}
}
catch ( RepositoryAdminException e )
{
log.debug( "RepositoryException remote repository with d'{}' not found, msg: {}",
archivaLocator.getRepositoryId(), e.getMessage() );
}
ManagedRepositoryContent managedRepositoryContent = null;
try
{
managedRepositoryContent =
repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
}
catch ( RepositoryNotFoundException e )
{
throw new DavException( HttpServletResponse.SC_NOT_FOUND,
"Invalid repository: " + archivaLocator.getRepositoryId() );
}
catch ( RepositoryException e )
{
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
}
log.debug( "Managed repository '{}' accessed by '{}'", managedRepositoryContent.getId(), activePrincipal );
try
{
resource = processRepository( request, archivaLocator, activePrincipal, managedRepositoryContent,
managedRepositoryAdmin.getManagedRepository(
archivaLocator.getRepositoryId() ) );
String logicalResource = getLogicalResource( archivaLocator, null, false );
resourcesInAbsolutePath.add(
new File( managedRepositoryContent.getRepoRoot(), logicalResource ).getAbsolutePath() );
}
catch ( RepositoryAdminException e )
{
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
}
}
String requestedResource = request.getRequestURI();
// MRM-872 : merge all available metadata
// merge metadata only when requested via the repo group
if ( ( repositoryRequest.isMetadata( requestedResource ) || repositoryRequest.isMetadataSupportFile(
requestedResource ) ) && repoGroupConfig != null )
{
// this should only be at the project level not version level!
if ( isProjectReference( requestedResource ) )
{
ArchivaDavResource res = (ArchivaDavResource) resource;
String filePath =
StringUtils.substringBeforeLast( res.getLocalResource().getAbsolutePath().replace( '\\', '/' ),
"/" );
filePath = filePath + "/maven-metadata-" + repoGroupConfig.getId() + ".xml";
// for MRM-872 handle checksums of the merged metadata files
if ( repositoryRequest.isSupportFile( requestedResource ) )
{
File metadataChecksum =