+ " ms.");
// expand if explicitly requested or if number of unique GAV matches is less than threshold
boolean expand = forceExpand || gavcount <= COLLAPSE_OVERRIDE_TRESHOLD;
SearchNGResponse response = new SearchNGResponse();
response.setTooManyResults(tooManyResults || iterator.getTotalHitsCount() + 1 >= LUCENE_HIT_LIMIT);
response.setCollapsed(!expand);
List<NexusNGArtifact> responseData = new ArrayList<NexusNGArtifact>();
LinkedHashSet<String> repositoryIds = new LinkedHashSet<String>();
for (GAHolder gahit : gahits.values()) {
if (expand) {
// expand, i.e. include all versions
for (NexusNGArtifact artifact : gahit.getOrderedVersionHits()) {
responseData.add(artifact);
setLatest(artifact, gahit.getLatestRelease(), gahit.getLatestSnapshot());
addRepositoryIds(repositoryIds, artifact);
}
}
else {
// collapse, i.e. only include latest version in each GA
NexusNGArtifact artifact = gahit.getLatestVersionHit();
setLatest(artifact, gahit.getLatestRelease(), gahit.getLatestSnapshot());
responseData.add(artifact);
addRepositoryIds(repositoryIds, artifact);
}
}
response.setData(responseData);
List<NexusNGRepositoryDetail> repoDetails = new ArrayList<NexusNGRepositoryDetail>();
for (String repositoryId : repositoryIds) {
Repository repository;
try {
repository = getUnprotectedRepositoryRegistry().getRepository(repositoryId);
addRepositoryDetails(repoDetails, request, repository);
}
catch (NoSuchRepositoryException e) {
// XXX can't happen, can it?
}
}
response.setRepoDetails(repoDetails);
return response;
}