From 009686ad2d546baf389f7b79ab45e817c00bcc39 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 17 Dec 2013 07:29:51 +0000 Subject: [PATCH] add a nex flag to indicate the merged index is temporary git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1551477 13f79535-47bb-0310-9956-ffa450edef68 --- .../indexer/merger/DefaultIndexMerger.java | 15 ++++++++----- .../indexer/merger/IndexMergerRequest.java | 21 ++++++++++++++++++- .../webdav/ArchivaDavResourceFactory.java | 3 ++- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java index 68ab59791..bc39b8da4 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java @@ -20,11 +20,15 @@ package org.apache.archiva.indexer.merger; import com.google.common.io.Files; +import org.apache.archiva.admin.model.RepositoryAdminException; +import org.apache.archiva.admin.model.beans.RepositoryGroup; +import org.apache.archiva.admin.model.group.RepositoryGroupAdmin; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.StopWatch; import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.context.IndexingContext; @@ -54,9 +58,6 @@ public class DefaultIndexMerger private Logger log = LoggerFactory.getLogger( getClass() ); - @Inject - private ManagedRepositoryAdmin managedRepositoryAdmin; - private MavenIndexerUtils mavenIndexerUtils; private NexusIndexer indexer; @@ -120,8 +121,12 @@ public class DefaultIndexMerger IndexPackingRequest request = new IndexPackingRequest( indexingContext, indexLocation ); indexPacker.packIndex( request ); } - temporaryGroupIndexes.add( new TemporaryGroupIndex( mergedIndexDirectory, tempRepoId, groupId, - indexMergerRequest.getMergedIndexTtl() ) ); + + if ( indexMergerRequest.isTemporary() ) + { + temporaryGroupIndexes.add( new TemporaryGroupIndex( mergedIndexDirectory, tempRepoId, groupId, + indexMergerRequest.getMergedIndexTtl() ) ); + } stopWatch.stop(); log.info( "merged index for repos {} in {} s", indexMergerRequest.getRepositoriesIds(), stopWatch.getTime() ); diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java index 65ceb17d0..1209410b7 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java @@ -47,6 +47,8 @@ public class IndexMergerRequest private File mergedIndexDirectory; + private boolean temporary; + public IndexMergerRequest( Collection repositoriesIds, boolean packIndex, String groupId ) { this.repositoriesIds = repositoriesIds; @@ -133,6 +135,22 @@ public class IndexMergerRequest return this; } + public boolean isTemporary() + { + return temporary; + } + + public void setTemporary( boolean temporary ) + { + this.temporary = temporary; + } + + + public IndexMergerRequest temporary( boolean temporary ) + { + this.temporary = temporary; + return this; + } @Override public String toString() @@ -143,7 +161,8 @@ public class IndexMergerRequest sb.append( ", groupId='" ).append( groupId ).append( '\'' ); sb.append( ", mergedIndexPath='" ).append( mergedIndexPath ).append( '\'' ); sb.append( ", mergedIndexTtl=" ).append( mergedIndexTtl ); - sb.append( ", mergedIndexDirectory='" ).append( mergedIndexDirectory ).append( '\'' ); + sb.append( ", mergedIndexDirectory=" ).append( mergedIndexDirectory ); + sb.append( ", temporary=" ).append( temporary ); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index 2bc10e101..95c73a163 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -1314,7 +1314,8 @@ public class ArchivaDavResourceFactory IndexMergerRequest indexMergerRequest = new IndexMergerRequest( authzRepos, true, repositoryGroupConfiguration.getId(), repositoryGroupConfiguration.getMergedIndexPath(), - repositoryGroupConfiguration.getMergedIndexTtl() ).mergedIndexDirectory( tempRepoFile ); + repositoryGroupConfiguration.getMergedIndexTtl() ).mergedIndexDirectory( tempRepoFile ) + .temporary( true ); MergedRemoteIndexesTaskRequest taskRequest = new MergedRemoteIndexesTaskRequest(indexMergerRequest, indexMerger); -- 2.39.5