@PostConstruct
public void initialize()
{
-
+ // no op
}
public DavResource createResource( final DavResourceLocator locator, final DavServletRequest request,
log.debug( "Repository group '{}' accessed by '{}", repoGroupConfig.getId(), activePrincipal );
// handle browse requests for virtual repos
- if ( RepositoryPathUtil.getLogicalResource( archivaLocator.getOrigResourcePath() ).endsWith( "/" ) )
+ if ( getLogicalResource( archivaLocator, null, true ).endsWith( "/" ) )
{
- return getResourceFromGroup( request, repoGroupConfig.getRepositories(), archivaLocator,
- repoGroupConfig );
+ try
+ {
+ return getResourceFromGroup( request, repoGroupConfig.getRepositories(), archivaLocator,
+ repoGroupConfig );
+ }
+ catch ( RepositoryAdminException e )
+ {
+ throw new DavException( 500, e );
+ }
}
else
{
if ( remoteRepository != null )
{
- String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
+ String logicalResource = getLogicalResource( archivaLocator, null, false );
IndexingContext indexingContext = remoteRepositoryAdmin.createIndexContext( remoteRepository );
File resourceFile = StringUtils.equals( logicalResource, "/" )
? new File( indexingContext.getIndexDirectoryFile().getParent() )
try
{
- managedRepositoryContent = repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
+ managedRepositoryContent =
+ repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
}
catch ( RepositoryNotFoundException e )
{
try
{
resource = processRepository( request, archivaLocator, activePrincipal, managedRepositoryContent,
- managedRepositoryAdmin.getManagedRepository( archivaLocator.getRepositoryId() ) );
+ managedRepositoryAdmin.getManagedRepository(
+ archivaLocator.getRepositoryId() ) );
+
+ String logicalResource = getLogicalResource( archivaLocator, null, false );
+ resourcesInAbsolutePath.add(
+ new File( managedRepositoryContent.getRepoRoot(), logicalResource ).getAbsolutePath() );
+
}
catch ( RepositoryAdminException e )
{
throw new DavException( 500, e );
}
-
- String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
- resourcesInAbsolutePath.add(
- new File( managedRepositoryContent.getRepoRoot(), logicalResource ).getAbsolutePath() );
}
String requestedResource = request.getRequestURI();
if ( metadataChecksum.exists() )
{
LogicalResource logicalResource =
- new LogicalResource( RepositoryPathUtil.getLogicalResource( locator.getResourcePath() ) );
+ new LogicalResource (getLogicalResource( archivaLocator, null, false ) );
resource =
new ArchivaDavResource( metadataChecksum.getAbsolutePath(), logicalResource.getPath(), null,
{
File resourceFile = writeMergedMetadataToFile( mergedMetadata, filePath );
- LogicalResource logicalResource = new LogicalResource(
- RepositoryPathUtil.getLogicalResource( locator.getResourcePath() ) );
+ LogicalResource logicalResource = new LogicalResource( getLogicalResource( archivaLocator, null, false ) );
resource =
new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(), null,
catch ( DigesterException de )
{
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
- "Error occurred while generating checksum files." );
+ "Error occurred while generating checksum files." + de.getMessage() );
}
}
}
{
for ( String repositoryId : repositories )
{
- ManagedRepositoryContent managedRepository;
+ ManagedRepositoryContent managedRepositoryContent;
try
{
- managedRepository = repositoryFactory.getManagedRepositoryContent( repositoryId );
+ managedRepositoryContent = repositoryFactory.getManagedRepositoryContent( repositoryId );
}
catch ( RepositoryNotFoundException e )
{
try
{
+ ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository( repositoryId );
DavResource updatedResource =
- processRepository( request, archivaLocator, activePrincipal, managedRepository,
- managedRepositoryAdmin.getManagedRepository( repositoryId ) );
+ processRepository( request, archivaLocator, activePrincipal, managedRepositoryContent,
+ managedRepository );
if ( resource == null )
{
resource = updatedResource;
}
- String logicalResource = RepositoryPathUtil.getLogicalResource( archivaLocator.getResourcePath() );
+ String logicalResource = getLogicalResource( archivaLocator, null, false );
if ( logicalResource.endsWith( "/" ) )
{
logicalResource = logicalResource.substring( 1 );
}
resourcesInAbsolutePath.add(
- new File( managedRepository.getRepoRoot(), logicalResource ).getAbsolutePath() );
+ new File( managedRepositoryContent.getRepoRoot(), logicalResource ).getAbsolutePath() );
}
catch ( DavException e )
{
return resource;
}
+ private String getLogicalResource( ArchivaDavResourceLocator archivaLocator, ManagedRepository managedRepository,
+ boolean useOrigResourcePath )
+ {
+ // FIXME remove this hack
+ // but currently managedRepository can be null in case of group
+ String layout = managedRepository == null ? new ManagedRepository( ).getLayout() : managedRepository.getLayout();
+ RepositoryStorage repositoryStorage =
+ this.applicationContext.getBean( "repositoryStorage#" + layout, RepositoryStorage.class );
+ String path = repositoryStorage.getFilePath(
+ useOrigResourcePath ? archivaLocator.getOrigResourcePath() : archivaLocator.getResourcePath(), managedRepository );
+ log.debug( "found path {} for resourcePath: '{}' with managedRepo '{}' and layout '{}'", path,
+ archivaLocator.getResourcePath(), managedRepository == null ? "null" : managedRepository.getId(), layout );
+ return path;
+ }
+
private DavResource processRepository( final DavServletRequest request, ArchivaDavResourceLocator archivaLocator,
String activePrincipal, ManagedRepositoryContent managedRepositoryContent,
ManagedRepository managedRepository )
DavResource resource = null;
if ( isAuthorized( request, managedRepositoryContent.getId() ) )
{
- RepositoryStorage repositoryStorage =
- this.applicationContext.getBean( "repositoryStorage#" + managedRepository.getLayout(),
- RepositoryStorage.class );
- String path = repositoryStorage.getFilePath( archivaLocator.getResourcePath(), managedRepository );
+ String path = getLogicalResource( archivaLocator, managedRepository, false );
if ( path.startsWith( "/" ) )
{
path = path.substring( 1 );
AuditEvent.CREATE_DIR, activePrincipal );
}
}
- } return resource;
+ }
+ return resource;
}
public DavResource createResource( final DavResourceLocator locator, final DavSession davSession )
{
ArchivaDavResourceLocator archivaLocator = checkLocatorIsInstanceOfRepositoryLocator( locator );
- ManagedRepositoryContent managedRepository;
+ ManagedRepositoryContent managedRepositoryContent;
try
{
- managedRepository = repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
+ managedRepositoryContent =
+ repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
}
catch ( RepositoryNotFoundException e )
{
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
}
- String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
- if ( logicalResource.startsWith( "/" ) )
+ DavResource resource = null;
+ try
{
- logicalResource = logicalResource.substring( 1 );
- }
- File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource );
- DavResource resource =
- new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource, managedRepository.getRepository(),
- davSession, archivaLocator, this, mimeTypes, auditListeners, scheduler );
+ String logicalResource = getLogicalResource( archivaLocator, managedRepositoryAdmin.getManagedRepository(
+ archivaLocator.getRepositoryId() ), false );
+ if ( logicalResource.startsWith( "/" ) )
+ {
+ logicalResource = logicalResource.substring( 1 );
+ }
+ File resourceFile = new File( managedRepositoryContent.getRepoRoot(), logicalResource );
+ resource = new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource,
+ managedRepositoryContent.getRepository(), davSession, archivaLocator,
+ this, mimeTypes, auditListeners, scheduler );
- resource.addLockManager( lockManager );
+ resource.addLockManager( lockManager );
+ }
+ catch ( RepositoryAdminException e )
+ {
+ throw new DavException( 500, e );
+ }
return resource;
}
private DavResource getResourceFromGroup( DavServletRequest request, List<String> repositories,
ArchivaDavResourceLocator locator,
RepositoryGroupConfiguration repositoryGroupConfiguration )
- throws DavException
+ throws DavException, RepositoryAdminException
{
List<File> mergedRepositoryContents = new ArrayList<File>();
- String path = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
+ // multiple repo types so we guess they are all the same type
+ // so use the first one
+ // FIXME add a method with group in the repository storage
+ String firstRepoId = repositoryGroupConfiguration.getRepositories().get( 1 );
+
+ String path = getLogicalResource( locator, managedRepositoryAdmin.getManagedRepository( firstRepoId ), false );
if ( path.startsWith( "/" ) )
{
path = path.substring( 1 );