Search in sources :

Example 11 with IndexingContext

use of org.sonatype.nexus.index.context.IndexingContext in project intellij-community by JetBrains.

the class Maven2ServerIndexerImpl method createIndex.

public int createIndex(@NotNull String indexId, @NotNull String repositoryId, @Nullable File file, @Nullable String url, @NotNull File indexDir) throws MavenServerIndexerException {
    try {
        IndexingContext context = myIndexer.addIndexingContextForced(indexId, repositoryId, file, indexDir, url, // repo update url
        null, NexusIndexer.FULL_INDEX);
        int id = System.identityHashCode(context);
        myIndices.put(id, context);
        return id;
    } catch (Exception e) {
        throw new MavenServerIndexerException(wrapException(e));
    }
}
Also used : IndexingContext(org.sonatype.nexus.index.context.IndexingContext) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) ArchetypeDataSourceException(org.apache.maven.archetype.source.ArchetypeDataSourceException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException)

Example 12 with IndexingContext

use of org.sonatype.nexus.index.context.IndexingContext in project intellij-community by JetBrains.

the class NexusIndexerTest method _testUpdatingLocal.

public void _testUpdatingLocal() throws Exception {
    IndexingContext c = addContext("local1", myIndexDir, new File(myRepositoryHelper.getTestDataPath("local1")), null);
    myIndexer.scan(c, new NullScanningListener());
    assertSearchWorks();
}
Also used : IndexingContext(org.sonatype.nexus.index.context.IndexingContext) File(java.io.File)

Example 13 with IndexingContext

use of org.sonatype.nexus.index.context.IndexingContext in project intellij-community by JetBrains.

the class NexusIndexerTest method tearDown.

@Override
protected void tearDown() throws Exception {
    for (IndexingContext c : myIndexer.getIndexingContexts().values()) {
        myIndexer.removeIndexingContext(c, false);
    }
    myEmbedder.release();
    super.tearDown();
}
Also used : IndexingContext(org.sonatype.nexus.index.context.IndexingContext)

Example 14 with IndexingContext

use of org.sonatype.nexus.index.context.IndexingContext in project intellij-community by JetBrains.

the class NexusIndexerTest method _testAddingArtifacts.

public void _testAddingArtifacts() throws Exception {
    IndexingContext c = addContext("virtual", myIndexDir, null, null);
    createProjectPom("");
    ArtifactInfo ai = new ArtifactInfo(c.getRepositoryId(), "group", "id", "version", null);
    ArtifactContext a = new ArtifactContext(new File(myProjectPom.getPath()), null, null, ai, null);
    Maven2ServerIndexerImpl.addArtifact(myIndexer, c, a);
    Query q = new TermQuery(new Term(ArtifactInfo.GROUP_ID, "group"));
    FlatSearchRequest request = new FlatSearchRequest(q, ArtifactInfo.VERSION_COMPARATOR);
    FlatSearchResponse response = myIndexer.searchFlat(request);
    Set<ArtifactInfo> result = response.getResults();
    assertSize(1, result);
    ArtifactInfo found = new ArrayList<ArtifactInfo>(result).get(0);
    assertEquals("group", found.groupId);
    assertEquals("id", found.artifactId);
    assertEquals("version", found.version);
    IndexReader r = c.getIndexReader();
    for (int i = 0; i < r.numDocs(); i++) {
        Document d = r.document(i);
    }
}
Also used : Term(org.apache.lucene.index.Term) Document(org.apache.lucene.document.Document) IndexReader(org.apache.lucene.index.IndexReader) IndexingContext(org.sonatype.nexus.index.context.IndexingContext) File(java.io.File)

Aggregations

IndexingContext (org.sonatype.nexus.index.context.IndexingContext)14 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)8 IOException (java.io.IOException)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 RemoteException (java.rmi.RemoteException)8 ArchetypeDataSourceException (org.apache.maven.archetype.source.ArchetypeDataSourceException)8 File (java.io.File)5 Document (org.apache.lucene.document.Document)4 IndexUpdateRequest (org.sonatype.nexus.index.updater.IndexUpdateRequest)3 THashSet (gnu.trove.THashSet)2 IndexReader (org.apache.lucene.index.IndexReader)2 BooleanQuery (org.apache.lucene.search.BooleanQuery)2 TopDocs (org.apache.lucene.search.TopDocs)2 TransferEvent (org.apache.maven.wagon.events.TransferEvent)2 MavenArtifactInfo (org.jetbrains.idea.maven.model.MavenArtifactInfo)2 MavenId (org.jetbrains.idea.maven.model.MavenId)2 org.sonatype.nexus.index (org.sonatype.nexus.index)2 ArrayList (java.util.ArrayList)1 Term (org.apache.lucene.index.Term)1 WagonManager (org.apache.maven.artifact.manager.WagonManager)1