mirror of https://github.com/apache/archiva.git
use a bean class for request to ease future enhancements
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1443527 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e0ecff38ea
commit
cde16b4a26
|
@ -87,7 +87,7 @@ public class DefaultIndexMerger
|
||||||
this.groupMergedIndexTtl = Integer.getInteger( IndexMerger.TMP_GROUP_INDEX_SYS_KEY, DEFAULT_GROUP_INDEX_TTL );
|
this.groupMergedIndexTtl = Integer.getInteger( IndexMerger.TMP_GROUP_INDEX_SYS_KEY, DEFAULT_GROUP_INDEX_TTL );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexingContext buildMergedIndex( Collection<String> repositoriesIds, boolean packIndex )
|
public IndexingContext buildMergedIndex( IndexMergerRequest indexMergerRequest )
|
||||||
throws IndexMergerException
|
throws IndexMergerException
|
||||||
{
|
{
|
||||||
File tempRepoFile = Files.createTempDir();
|
File tempRepoFile = Files.createTempDir();
|
||||||
|
@ -102,7 +102,7 @@ public class DefaultIndexMerger
|
||||||
indexer.addIndexingContext( tempRepoId, tempRepoId, tempRepoFile, indexLocation, null, null,
|
indexer.addIndexingContext( tempRepoId, tempRepoId, tempRepoFile, indexLocation, null, null,
|
||||||
mavenIndexerUtils.getAllIndexCreators() );
|
mavenIndexerUtils.getAllIndexCreators() );
|
||||||
|
|
||||||
for ( String repoId : repositoriesIds )
|
for ( String repoId : indexMergerRequest.getRepositoriesIds() )
|
||||||
{
|
{
|
||||||
IndexingContext idxToMerge = indexer.getIndexingContexts().get( repoId );
|
IndexingContext idxToMerge = indexer.getIndexingContexts().get( repoId );
|
||||||
if ( idxToMerge != null )
|
if ( idxToMerge != null )
|
||||||
|
@ -113,12 +113,13 @@ public class DefaultIndexMerger
|
||||||
|
|
||||||
indexingContext.optimize();
|
indexingContext.optimize();
|
||||||
|
|
||||||
if ( packIndex )
|
if ( indexMergerRequest.isPackIndex() )
|
||||||
{
|
{
|
||||||
IndexPackingRequest request = new IndexPackingRequest( indexingContext, indexLocation );
|
IndexPackingRequest request = new IndexPackingRequest( indexingContext, indexLocation );
|
||||||
indexPacker.packIndex( request );
|
indexPacker.packIndex( request );
|
||||||
}
|
}
|
||||||
temporaryGroupIndexes.add( new TemporaryGroupIndex( tempRepoFile, tempRepoId ) );
|
temporaryGroupIndexes.add(
|
||||||
|
new TemporaryGroupIndex( tempRepoFile, tempRepoId, indexMergerRequest.getGroupId() ) );
|
||||||
return indexingContext;
|
return indexingContext;
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
|
|
|
@ -35,12 +35,11 @@ public interface IndexMerger
|
||||||
static final String TMP_GROUP_INDEX_SYS_KEY = "archiva.tmp.group.index.ttl";
|
static final String TMP_GROUP_INDEX_SYS_KEY = "archiva.tmp.group.index.ttl";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param repositoriesIds repositories Ids to merge content
|
* @param indexMergerRequest
|
||||||
* @param packIndex will generate a downloadable index
|
|
||||||
* @return a temporary directory with a merge index (directory marked deleteOnExit)
|
* @return a temporary directory with a merge index (directory marked deleteOnExit)
|
||||||
* @throws IndexMergerException
|
* @throws IndexMergerException
|
||||||
*/
|
*/
|
||||||
IndexingContext buildMergedIndex( Collection<String> repositoriesIds, boolean packIndex )
|
IndexingContext buildMergedIndex( IndexMergerRequest indexMergerRequest )
|
||||||
throws IndexMergerException;
|
throws IndexMergerException;
|
||||||
|
|
||||||
void cleanTemporaryGroupIndex( TemporaryGroupIndex temporaryGroupIndex );
|
void cleanTemporaryGroupIndex( TemporaryGroupIndex temporaryGroupIndex );
|
||||||
|
|
|
@ -34,10 +34,13 @@ public class TemporaryGroupIndex
|
||||||
|
|
||||||
private String indexId;
|
private String indexId;
|
||||||
|
|
||||||
public TemporaryGroupIndex( File directory, String indexId )
|
private String groupId;
|
||||||
|
|
||||||
|
public TemporaryGroupIndex( File directory, String indexId, String groupId )
|
||||||
{
|
{
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
this.indexId = indexId;
|
this.indexId = indexId;
|
||||||
|
this.groupId = groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCreationTime()
|
public long getCreationTime()
|
||||||
|
|
|
@ -57,8 +57,8 @@ public class TemporaryGroupIndexCleaner
|
||||||
log.info( "cleanTemporaryIndex" );
|
log.info( "cleanTemporaryIndex" );
|
||||||
for ( TemporaryGroupIndex temporaryGroupIndex : indexMerger.getTemporaryGroupIndexes() )
|
for ( TemporaryGroupIndex temporaryGroupIndex : indexMerger.getTemporaryGroupIndexes() )
|
||||||
{
|
{
|
||||||
// cleanup files older than 60 minutes 3600000
|
// cleanup files older than the ttl
|
||||||
if ( new Date().getTime() - temporaryGroupIndex.getCreationTime() > 3600000 )
|
if ( new Date().getTime() - temporaryGroupIndex.getCreationTime() > indexMerger.getGroupMergedIndexTtl() )
|
||||||
{
|
{
|
||||||
indexMerger.cleanTemporaryGroupIndex( temporaryGroupIndex );
|
indexMerger.cleanTemporaryGroupIndex( temporaryGroupIndex );
|
||||||
|
|
||||||
|
|
|
@ -991,6 +991,7 @@
|
||||||
<archiva.devMode>${archiva.devMode}</archiva.devMode>
|
<archiva.devMode>${archiva.devMode}</archiva.devMode>
|
||||||
<archiva.javascriptLog>${archiva.javascriptLog}</archiva.javascriptLog>
|
<archiva.javascriptLog>${archiva.javascriptLog}</archiva.javascriptLog>
|
||||||
<archiva.logMissingI18n>${archiva.logMissingI18n}</archiva.logMissingI18n>
|
<archiva.logMissingI18n>${archiva.logMissingI18n}</archiva.logMissingI18n>
|
||||||
|
<archiva.tmp.group.index.ttl>0</archiva.tmp.group.index.ttl>
|
||||||
</systemProperties>
|
</systemProperties>
|
||||||
<additionalClasspathDirs>
|
<additionalClasspathDirs>
|
||||||
<additionalClasspathDir>${basedir}/src/test/tomcat</additionalClasspathDir>
|
<additionalClasspathDir>${basedir}/src/test/tomcat</additionalClasspathDir>
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
|
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
|
||||||
import org.apache.archiva.indexer.merger.IndexMerger;
|
import org.apache.archiva.indexer.merger.IndexMerger;
|
||||||
import org.apache.archiva.indexer.merger.IndexMergerException;
|
import org.apache.archiva.indexer.merger.IndexMergerException;
|
||||||
|
import org.apache.archiva.indexer.merger.IndexMergerRequest;
|
||||||
import org.apache.archiva.indexer.merger.TemporaryGroupIndex;
|
import org.apache.archiva.indexer.merger.TemporaryGroupIndex;
|
||||||
import org.apache.archiva.indexer.search.RepositorySearch;
|
import org.apache.archiva.indexer.search.RepositorySearch;
|
||||||
import org.apache.archiva.maven2.metadata.MavenMetadataReader;
|
import org.apache.archiva.maven2.metadata.MavenMetadataReader;
|
||||||
|
@ -1216,10 +1217,11 @@ public class ArchivaDavResourceFactory
|
||||||
}
|
}
|
||||||
log.info( "generate temporary merged index for repository group '{}' for repositories '{}'", groupId,
|
log.info( "generate temporary merged index for repository group '{}' for repositories '{}'", groupId,
|
||||||
authzRepos );
|
authzRepos );
|
||||||
IndexingContext indexingContext = indexMerger.buildMergedIndex( authzRepos, true );
|
IndexingContext indexingContext =
|
||||||
|
indexMerger.buildMergedIndex( new IndexMergerRequest( authzRepos, true, groupId ) );
|
||||||
File mergedRepoDir = indexingContext.getIndexDirectoryFile();
|
File mergedRepoDir = indexingContext.getIndexDirectoryFile();
|
||||||
TemporaryGroupIndex temporaryGroupIndex =
|
TemporaryGroupIndex temporaryGroupIndex =
|
||||||
new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId() ).setCreationTime(
|
new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(), groupId ).setCreationTime(
|
||||||
new Date().getTime() );
|
new Date().getTime() );
|
||||||
temporaryGroupIndexMap.put( groupId, temporaryGroupIndex );
|
temporaryGroupIndexMap.put( groupId, temporaryGroupIndex );
|
||||||
session.setAttribute( TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY,
|
session.setAttribute( TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY,
|
||||||
|
|
Loading…
Reference in New Issue