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;
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
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()
{
* under the License.
*/
+import java.util.Collection;
import java.util.List;
*/
SearchResults search( String principal, SearchFields searchFields, SearchResultLimits limits )
throws RepositorySearchException;
+
+ Collection<String> getAllGroupIds( String principal, List<String> selectedRepos )
+ throws RepositorySearchException;
}
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
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 );
+ }
}