archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1181728 - in /archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src: main/java/org/apache/archiva/indexer/search/ test/java/org/apache/archiva/indexer/search/
Date Tue, 11 Oct 2011 11:45:22 GMT
Author: olamy
Date: Tue Oct 11 11:45:22 2011
New Revision: 1181728

URL: http://svn.apache.org/viewvc?rev=1181728&view=rev
Log:
add a method to retrieve all groupIds available in indexs

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java?rev=1181728&r1=1181727&r2=1181728&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
Tue Oct 11 11:45:22 2011
@@ -49,6 +49,7 @@ import javax.inject.Inject;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -95,7 +96,7 @@ public class NexusRepositorySearch
                                 List<String> previousSearchTerms)
         throws RepositorySearchException
     {
-        List<String> indexingContextIds = addIndexingContexts(selectedRepos);
+        List<String> indexingContextIds = addIndexingContexts( selectedRepos );
 
         // since upgrade to nexus 2.0.0, query has changed from g:[QUERIED TERM]* to g:*[QUERIED
TERM]*
         //      resulting to more wildcard searches so we need to increase max clause count
@@ -399,6 +400,28 @@ public class NexusRepositorySearch
         return ids;
     }
 
+    public Collection<String> getAllGroupIds(String principal, List<String> selectedRepos)
+        throws RepositorySearchException
+    {
+        List<IndexingContext> indexContexts = getIndexingContexts( selectedRepos );
+        if (indexContexts == null || indexContexts.isEmpty())
+        {
+            return Collections.emptyList();
+        }
+
+        try
+        {
+            Set<String> allGroupIds = new HashSet<String>(  );
+            for (IndexingContext indexingContext : indexContexts)
+            {
+                allGroupIds.addAll( indexingContext.getAllGroups() );
+            }
+            return allGroupIds;
+        } catch ( IOException e )
+        {
+            throw new RepositorySearchException( e.getMessage(), e );
+        }
+    }
 
     protected List<? extends IndexCreator> getAllIndexCreators()
     {

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java?rev=1181728&r1=1181727&r2=1181728&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java
Tue Oct 11 11:45:22 2011
@@ -19,6 +19,7 @@ package org.apache.archiva.indexer.searc
  * under the License.
  */
 
+import java.util.Collection;
 import java.util.List;
 
 
@@ -48,4 +49,7 @@ public interface RepositorySearch
      */
     SearchResults search( String principal, SearchFields searchFields, SearchResultLimits
limits )
         throws RepositorySearchException;
+    
+    Collection<String> getAllGroupIds( String principal, List<String> selectedRepos
)
+        throws RepositorySearchException;
 }

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java?rev=1181728&r1=1181727&r2=1181728&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
Tue Oct 11 11:45:22 2011
@@ -29,6 +29,7 @@ import org.springframework.test.context.
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 
 
@@ -803,4 +804,22 @@ public class NexusRepositorySearchTest
         assertEquals( 1, results.getHits().size() );
         assertEquals( "test-webapp", results.getHits().get( 0 ).getArtifactId() );
     }
+
+    @Test
+    public void getAllGroupIds() throws Exception
+    {
+        createIndexContainingMoreArtifacts( true );
+
+        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ,
0 , 2 );
+
+        archivaConfigControl.replay();
+
+        Collection<String> groupIds = search.getAllGroupIds( "user", selectedRepos
);
+
+        archivaConfigControl.verify();
+
+        log.info( "groupIds: " + groupIds );
+    }
 }



Mime
View raw message