Search in sources :

Example 1 with IndexingContext

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

the class NexusIndexerTest method _testAddingTwoContextsWithSameId.

public void _testAddingTwoContextsWithSameId() throws Exception {
    IndexingContext i1 = addContext("id", new File(myIndexDir, "one"), null, null);
    IndexingContext i2 = addContext("id", new File(myIndexDir, "two"), null, null);
    myIndexer.removeIndexingContext(i1, false);
    myIndexer.removeIndexingContext(i2, false);
    addContext("id", new File(myIndexDir, "one"), null, null);
    addContext("id", new File(myIndexDir, "two"), null, null);
}
Also used : IndexingContext(org.sonatype.nexus.index.context.IndexingContext) File(java.io.File)

Example 2 with IndexingContext

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

the class Maven3ServerIndexerImpl method addArtifact.

@Override
public MavenId addArtifact(int indexId, File artifactFile) throws RemoteException, MavenServerIndexerException {
    try {
        IndexingContext index = getIndex(indexId);
        ArtifactContext artifactContext = myArtifactContextProducer.getArtifactContext(index, artifactFile);
        if (artifactContext == null)
            return null;
        addArtifact(myIndexer, index, artifactContext);
        org.sonatype.nexus.index.ArtifactInfo a = artifactContext.getArtifactInfo();
        return new MavenId(a.groupId, a.artifactId, a.version);
    } catch (Exception e) {
        throw new MavenServerIndexerException(wrapException(e));
    }
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) IndexingContext(org.sonatype.nexus.index.context.IndexingContext) org.sonatype.nexus.index(org.sonatype.nexus.index) 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 3 with IndexingContext

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

the class NexusIndexerTest method _testIteratingAddedArtifacts.

public void _testIteratingAddedArtifacts() throws Exception {
    if (ignore())
        return;
    IndexingContext c = addContext("virtual", myIndexDir, null, null);
    addArtifact(c, "group1", "id1", "version1", "x:/path1");
    addArtifact(c, "group2", "id2", "version2", "x:/path2");
    addArtifact(c, "group3", "id3", "version3", "x:/path3");
    IndexReader r = c.getIndexReader();
    assertEquals(5, r.numDocs());
    List<String> result = new ArrayList<String>();
    for (int i = 0; i < r.numDocs(); i++) {
        // third document becomes deleted somehow...
        Document d = r.document(i);
        String uinfo = d.get(ArtifactInfo.UINFO);
        result.add(uinfo);
    }
    System.out.println(result);
}
Also used : IndexReader(org.apache.lucene.index.IndexReader) ArrayList(java.util.ArrayList) IndexingContext(org.sonatype.nexus.index.context.IndexingContext) Document(org.apache.lucene.document.Document)

Example 4 with IndexingContext

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

the class NexusIndexerTest method _testDownloading.

public void _testDownloading() throws Exception {
    String id = "remote";
    String url = "file:///" + myRepositoryHelper.getTestDataPath("remote");
    IndexingContext c = addContext(id, myIndexDir, null, url);
    IndexUpdateRequest request = new IndexUpdateRequest(c);
    request.setResourceFetcher(new Maven2ServerIndexFetcher(id, url, myEmbedder.getComponent(WagonManager.class), new NullTransferListener()));
    myUpdater.fetchAndUpdateIndex(request);
    assertSearchWorks();
}
Also used : Maven2ServerIndexFetcher(org.jetbrains.idea.maven.server.embedder.Maven2ServerIndexFetcher) IndexUpdateRequest(org.sonatype.nexus.index.updater.IndexUpdateRequest) IndexingContext(org.sonatype.nexus.index.context.IndexingContext)

Example 5 with IndexingContext

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

the class Maven2ServerIndexerImpl method addArtifact.

public MavenId addArtifact(int indexId, File artifactFile) throws MavenServerIndexerException {
    try {
        IndexingContext index = getIndex(indexId);
        ArtifactContext artifactContext = myArtifactContextProducer.getArtifactContext(index, artifactFile);
        if (artifactContext == null)
            return null;
        addArtifact(myIndexer, index, artifactContext);
        org.sonatype.nexus.index.ArtifactInfo a = artifactContext.getArtifactInfo();
        return new MavenId(a.groupId, a.artifactId, a.version);
    } catch (Exception e) {
        throw new MavenServerIndexerException(wrapException(e));
    }
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) IndexingContext(org.sonatype.nexus.index.context.IndexingContext) org.sonatype.nexus.index(org.sonatype.nexus.index) 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)

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