use of org.apache.archiva.indexer.search.RepositorySearchException in project archiva by apache.
the class MavenRepositorySearch method getRemoteIndexingContextIds.
@Override
public Set<String> getRemoteIndexingContextIds(String managedRepoId) throws RepositorySearchException {
Set<String> ids = new HashSet<>();
List<ProxyConnector> proxyConnectors = null;
try {
proxyConnectors = proxyConnectorAdmin.getProxyConnectorAsMap().get(managedRepoId);
} catch (RepositoryAdminException e) {
throw new RepositorySearchException(e.getMessage(), e);
}
if (proxyConnectors == null || proxyConnectors.isEmpty()) {
return ids;
}
for (ProxyConnector proxyConnector : proxyConnectors) {
String remoteId = "remote-" + proxyConnector.getTargetRepoId();
RemoteRepository repo = repositoryRegistry.getRemoteRepository(proxyConnector.getTargetRepoId());
if (repo.getType() == RepositoryType.MAVEN) {
try {
IndexingContext context = repo.getIndexingContext() != null ? repo.getIndexingContext().getBaseContext(IndexingContext.class) : null;
if (context != null && context.isSearchable()) {
ids.add(remoteId);
}
} catch (UnsupportedBaseContextException e) {
// Ignore this one
}
}
}
return ids;
}
use of org.apache.archiva.indexer.search.RepositorySearchException in project archiva by apache.
the class MavenRepositorySearch method search.
private SearchResults search(SearchResultLimits limits, BooleanQuery q, List<String> indexingContextIds, List<? extends ArtifactInfoFilter> filters, List<String> selectedRepos, boolean includePoms) throws RepositorySearchException {
try {
FlatSearchRequest request = new FlatSearchRequest(q);
request.setContexts(getIndexingContexts(indexingContextIds));
if (limits != null) {
// we apply limits only when first page asked
if (limits.getSelectedPage() == 0) {
request.setCount(limits.getPageSize() * (Math.max(1, limits.getSelectedPage())));
}
}
FlatSearchResponse response = indexer.searchFlat(request);
if (response == null || response.getTotalHitsCount() == 0) {
SearchResults results = new SearchResults();
results.setLimits(limits);
return results;
}
return convertToSearchResults(response, limits, filters, selectedRepos, includePoms);
} catch (IOException e) {
throw new RepositorySearchException(e.getMessage(), e);
} catch (RepositoryAdminException e) {
throw new RepositorySearchException(e.getMessage(), e);
}
}
Aggregations