]> source.dussan.org Git - archiva.git/commitdiff
add a nex flag to indicate the merged index is temporary
authorOlivier Lamy <olamy@apache.org>
Tue, 17 Dec 2013 07:29:51 +0000 (07:29 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 17 Dec 2013 07:29:51 +0000 (07:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1551477 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java
archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java
archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java

index 68ab59791aab881f10407fa6d058a41d75f04e6d..bc39b8da4056bf294076e91f489e8daa2d6d2bba 100644 (file)
@@ -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() );
index 65ceb17d0da8eb2d4978670abb0fff66114e943c..1209410b770801f9a4994c88a06f9cb14a3db05f 100644 (file)
@@ -47,6 +47,8 @@ public class IndexMergerRequest
 
     private File mergedIndexDirectory;
 
+    private boolean temporary;
+
     public IndexMergerRequest( Collection<String> 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();
     }
index 2bc10e101ae0fc64119eae4c4aeb98e6192b4400..95c73a163cf16288b1b0ea58ea3fedc4c101f690 100644 (file)
@@ -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);