*/
private String groupId;
+ private String mergedIndexPath = "/.indexer";
+
public IndexMergerRequest( Collection<String> repositoriesIds, boolean packIndex, String groupId )
{
this.repositoriesIds = repositoriesIds;
this.groupId = groupId;
}
+ /**
+ * @since 1.4-M4
+ */
+ public IndexMergerRequest( Collection<String> repositoriesIds, boolean packIndex, String groupId,
+ String mergedIndexPath )
+ {
+ this.repositoriesIds = repositoriesIds;
+ this.packIndex = packIndex;
+ this.groupId = groupId;
+ this.mergedIndexPath = mergedIndexPath;
+ }
+
public Collection<String> getRepositoriesIds()
{
return repositoriesIds;
this.groupId = groupId;
}
+ public String getMergedIndexPath()
+ {
+ return mergedIndexPath;
+ }
+
+ public void setMergedIndexPath( String mergedIndexPath )
+ {
+ this.mergedIndexPath = mergedIndexPath;
+ }
+
@Override
public String toString()
{
- final StringBuilder sb = new StringBuilder();
- sb.append( "IndexMergerRequest" );
- sb.append( "{repositoriesIds=" ).append( repositoriesIds );
+ final StringBuilder sb = new StringBuilder( "IndexMergerRequest{" );
+ sb.append( "repositoriesIds=" ).append( repositoriesIds );
sb.append( ", packIndex=" ).append( packIndex );
sb.append( ", groupId='" ).append( groupId ).append( '\'' );
+ sb.append( ", mergedIndexPath='" ).append( mergedIndexPath ).append( '\'' );
sb.append( '}' );
return sb.toString();
}
/**
*
*/
-@Service( "davResourceFactory#archiva" )
+@Service("davResourceFactory#archiva")
public class ArchivaDavResourceFactory
implements DavResourceFactory, Auditable
{
*
*/
@Inject
- @Named( value = "repositoryProxyConnectors#default" )
+ @Named(value = "repositoryProxyConnectors#default")
private RepositoryProxyConnectors connectors;
/**
*
*/
@Inject
- @Named( value = "httpAuthenticator#basic" )
+ @Named(value = "httpAuthenticator#basic")
private HttpAuthenticator httpAuth;
@Inject
*
*/
@Inject
- @Named( value = "archivaTaskScheduler#repository" )
+ @Named(value = "archivaTaskScheduler#repository")
private RepositoryArchivaTaskScheduler scheduler;
private ApplicationContext applicationContext;
// infrequent
List<String> repositories = new ArrayList<String>( repoGroupConfig.getRepositories() );
resource = processRepositoryGroup( request, archivaLocator, repositories, activePrincipal,
- resourcesInAbsolutePath, archivaLocator.getRepositoryId() );
+ resourcesInAbsolutePath, repoGroupConfig );
}
}
else
private DavResource processRepositoryGroup( final DavServletRequest request,
ArchivaDavResourceLocator archivaLocator, List<String> repositories,
String activePrincipal, List<String> resourcesInAbsolutePath,
- String repositoryGroupId )
+ RepositoryGroupConfiguration repoGroupConfig )
throws DavException
{
DavResource resource = null;
// we are in the case of index file request
String requestedFileName = StringUtils.substringAfterLast( pathInfo, "/" );
File temporaryIndexDirectory =
- buildMergedIndexDirectory( repositories, activePrincipal, request, repositoryGroupId );
+ buildMergedIndexDirectory( repositories, activePrincipal, request, repoGroupConfig );
File resourceFile = new File( temporaryIndexDirectory, requestedFileName );
resource = new ArchivaDavResource( resourceFile.getAbsolutePath(), requestedFileName, null,
// remove last /
String pathInfo = StringUtils.removeEnd( request.getPathInfo(), "/" );
- if ( StringUtils.endsWith( pathInfo, "/" + repositoryGroupConfiguration.getMergedIndexPath() )
- || StringUtils.endsWith( pathInfo, "/" + repositoryGroupConfiguration.getMergedIndexPath() + "/" ) )
+ if ( StringUtils.endsWith( pathInfo, repositoryGroupConfiguration.getMergedIndexPath() ) )
{
- File mergedRepoDir = buildMergedIndexDirectory( repositories, activePrincipal, request,
- repositoryGroupConfiguration.getId() );
+ File mergedRepoDir =
+ buildMergedIndexDirectory( repositories, activePrincipal, request, repositoryGroupConfiguration );
mergedRepositoryContents.add( mergedRepoDir );
}
else
}
protected File buildMergedIndexDirectory( List<String> repositories, String activePrincipal,
- DavServletRequest request, String groupId )
+ DavServletRequest request,
+ RepositoryGroupConfiguration repositoryGroupConfiguration )
throws DavException
{
temporaryGroupIndexMap = new HashMap<String, TemporaryGroupIndex>();
}
- TemporaryGroupIndex tmp = temporaryGroupIndexMap.get( groupId );
+ TemporaryGroupIndex tmp = temporaryGroupIndexMap.get( repositoryGroupConfiguration.getId() );
if ( tmp != null && tmp.getDirectory() != null && tmp.getDirectory().exists() )
{
* 1000 ) )
{
log.debug( MarkerFactory.getMarker( "group.merged.index" ),
- "tmp group index '{}' is too old so delete it", groupId );
+ "tmp group index '{}' is too old so delete it", repositoryGroupConfiguration.getId() );
indexMerger.cleanTemporaryGroupIndex( tmp );
}
else
{
log.debug( MarkerFactory.getMarker( "group.merged.index" ),
- "merged index for group '{}' found in cache", groupId );
+ "merged index for group '{}' found in cache", repositoryGroupConfiguration.getId() );
return tmp.getDirectory();
}
}
e.getMessage() );
}
}
- log.info( "generate temporary merged index for repository group '{}' for repositories '{}'", groupId,
- authzRepos );
- IndexingContext indexingContext =
- indexMerger.buildMergedIndex( new IndexMergerRequest( authzRepos, true, groupId ) );
+ log.info( "generate temporary merged index for repository group '{}' for repositories '{}'",
+ repositoryGroupConfiguration.getId(), authzRepos );
+ IndexingContext indexingContext = indexMerger.buildMergedIndex(
+ new IndexMergerRequest( authzRepos, true, repositoryGroupConfiguration.getId(),
+ repositoryGroupConfiguration.getMergedIndexPath() ) );
File mergedRepoDir = indexingContext.getIndexDirectoryFile();
- TemporaryGroupIndex temporaryGroupIndex =
- new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(), groupId ).setCreationTime(
- new Date().getTime() );
- temporaryGroupIndexMap.put( groupId, temporaryGroupIndex );
+ TemporaryGroupIndex temporaryGroupIndex = new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(),
+ repositoryGroupConfiguration.getId() ).setCreationTime(
+ new Date().getTime() );
+ temporaryGroupIndexMap.put( repositoryGroupConfiguration.getId(), temporaryGroupIndex );
session.setAttribute( TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY,
temporaryGroupIndexMap );
return mergedRepoDir;