mirror of https://github.com/apache/archiva.git
add a method to retrieve all groupIds available in indexs
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1181728 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e67d4b4bf4
commit
3d268094df
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.archiva.indexer.search;
|
|||
* 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;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
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 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue