archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1196845 - in /archiva/trunk/archiva-modules: archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/ archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/
Date Wed, 02 Nov 2011 22:33:10 GMT
Author: olamy
Date: Wed Nov  2 22:33:09 2011
New Revision: 1196845

URL: http://svn.apache.org/viewvc?rev=1196845&view=rev
Log:
[MRM-815] aggregate indices for repository groups.
pack index for download.

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java?rev=1196845&r1=1196844&r2=1196845&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java
Wed Nov  2 22:33:09 2011
@@ -27,6 +27,8 @@ import org.apache.archiva.common.plexusb
 import org.apache.maven.index.NexusIndexer;
 import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
+import org.apache.maven.index.packer.IndexPacker;
+import org.apache.maven.index.packer.IndexPackingRequest;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
@@ -49,15 +51,18 @@ public class DefaultIndexMerger
 
     private NexusIndexer indexer;
 
+    private IndexPacker indexPacker;
+
     @javax.inject.Inject
     public DefaultIndexMerger( PlexusSisuBridge plexusSisuBridge, MavenIndexerUtils mavenIndexerUtils
)
         throws PlexusSisuBridgeException
     {
         this.indexer = plexusSisuBridge.lookup( NexusIndexer.class );
         this.mavenIndexerUtils = mavenIndexerUtils;
+        indexPacker = plexusSisuBridge.lookup( IndexPacker.class, "default" );
     }
 
-    public File buildMergedIndex( Collection<String> repositoriesIds )
+    public File buildMergedIndex( Collection<String> repositoriesIds, boolean packIndex
)
         throws IndexMergerException
     {
         File tempRepoFile = Files.createTempDir();
@@ -67,9 +72,10 @@ public class DefaultIndexMerger
 
         try
         {
+            File indexLocation = new File( tempRepoFile, ".indexer" );
             IndexingContext indexingContext =
-                indexer.addIndexingContext( tempRepoId, tempRepoId, tempRepoFile, new File(
tempRepoFile, ".indexer" ),
-                                            null, null, mavenIndexerUtils.getAllIndexCreators()
);
+                indexer.addIndexingContext( tempRepoId, tempRepoId, tempRepoFile, indexLocation,
null, null,
+                                            mavenIndexerUtils.getAllIndexCreators() );
 
             for ( String repoId : repositoriesIds )
             {
@@ -80,6 +86,13 @@ public class DefaultIndexMerger
                 }
             }
 
+            indexingContext.optimize();
+
+            if ( packIndex )
+            {
+                IndexPackingRequest request = new IndexPackingRequest( indexingContext, indexLocation
);
+                indexPacker.packIndex( request );
+            }
             return indexingContext.getIndexDirectoryFile();
         }
         catch ( IOException e )

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java?rev=1196845&r1=1196844&r2=1196845&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java
Wed Nov  2 22:33:09 2011
@@ -29,9 +29,10 @@ public interface IndexMerger
 {
     /**
      * @param repositoriesIds repositories Ids to merge content
+     * @param packIndex will generate a downloadable index
      * @return a temporary directory with a merge index (directory marked deleteOnExit)
      * @throws IndexMergerException
      */
-    File buildMergedIndex( Collection<String> repositoriesIds )
+    File buildMergedIndex( Collection<String> repositoriesIds, boolean packIndex )
         throws IndexMergerException;
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java?rev=1196845&r1=1196844&r2=1196845&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
Wed Nov  2 22:33:09 2011
@@ -1033,7 +1033,7 @@ public class ArchivaDavResourceFactory
                 }
             }
             // remove last /
-            String pathInfo = StringUtils.removeEnd( request.getPathInfo(), "/"  );
+            String pathInfo = StringUtils.removeEnd( request.getPathInfo(), "/" );
             if ( StringUtils.endsWith( path, ".indexer" ) )
             {
                 try
@@ -1063,7 +1063,7 @@ public class ArchivaDavResourceFactory
                         }
                     }
 
-                    File mergedRepoDir = indexMerger.buildMergedIndex( authzRepos );
+                    File mergedRepoDir = indexMerger.buildMergedIndex( authzRepos, true );
                     mergedRepositoryContents.add( mergedRepoDir );
 
                 }



Mime
View raw message