private FlatSearchResponse searchFlat(String repositoryId, FlatSearchRequest req)
throws NoSuchRepositoryException
{
LockedIndexingContexts lockedContexts = lockSearchTargetIndexingContexts(repositoryId);
if (lockedContexts == null) {
return new FlatSearchResponse(req.getQuery(), 0, Collections.<ArtifactInfo>emptySet());
}
try {
req.getContexts().addAll(lockedContexts.contexts.values());
FlatSearchResponse result = mavenIndexer.searchFlat(req);
postprocessResults(result.getResults());
return result;
}
catch (BooleanQuery.TooManyClauses e) {
if (log.isDebugEnabled()) {
log.debug("Too many clauses exception caught:", e);
}
return new FlatSearchResponse(req.getQuery(), -1, new HashSet<ArtifactInfo>());
}
catch (IOException e) {
log.error("Got I/O exception while searching for query \"" + req.getQuery() + "\"", e);
return new FlatSearchResponse(req.getQuery(), 0, new HashSet<ArtifactInfo>());
}
finally {
lockedContexts.lock.unlock();
}
}