public Set<MavenArtifactInfo> search(int indexId, Query query, int maxResult) throws MavenServerIndexerException { try { IndexingContext index = getIndex(indexId); TopDocs docs = null; try { BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE); docs = index.getIndexSearcher().search(query, null, maxResult); } catch (BooleanQuery.TooManyClauses ignore) { // this exception occurs when too wide wildcard is used on too big data. } if (docs == null || docs.scoreDocs.length == 0) return Collections.emptySet(); Set<MavenArtifactInfo> result = new THashSet<MavenArtifactInfo>(); for (int i = 0; i < docs.scoreDocs.length; i++) { int docIndex = docs.scoreDocs[i].doc; Document doc = index.getIndexReader().document(docIndex); ArtifactInfo a = IndexUtils.constructArtifactInfo(doc, index); if (a == null) continue; a.repository = getRepositoryPathOrUrl(index); result.add(Maven2ModelConverter.convertArtifactInfo(a)); } return result; } catch (Exception e) { throw new MavenServerIndexerException(wrapException(e)); } }
private void doCollectArchetypes(String roleHint, Set<MavenArchetype> result) throws RemoteException { try { ArchetypeDataSource source = myEmbedder.getComponent(ArchetypeDataSource.class, roleHint); ArchetypeCatalog catalog = source.getArchetypeCatalog(new Properties()); for (Archetype each : (Iterable<? extends Archetype>) catalog.getArchetypes()) { result.add(Maven2ModelConverter.convertArchetype(each)); } } catch (ArchetypeDataSourceException e) { Maven2ServerGlobals.getLogger().warn(e); } }