• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java IndexingContext类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.maven.index.context.IndexingContext的典型用法代码示例。如果您正苦于以下问题:Java IndexingContext类的具体用法?Java IndexingContext怎么用?Java IndexingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

IndexingContext类属于org.apache.maven.index.context包,在下文中一共展示了IndexingContext类的35个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: scanningStarted

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@Messages({
    "# {0} - repo name", "LBL_indexing_repo=Indexing Maven repository: {0}",
    "LBL_findIndexableDirs=Counting indexable directories..."
})
@Override public void scanningStarted(IndexingContext ctx) {
    if (handle != null) {
        handle.finish();
    }
    expectedDirs.clear();
    encounteredDirs.clear();
    handle = ProgressHandle.createHandle(Bundle.LBL_indexing_repo(ri != null ? ri.getName() : indexingContext.getId()), this);
    handle.start();
    handle.progress(Bundle.LBL_findIndexableDirs());
    findIndexableDirs(ctx.getRepository());
    handle.switchToDeterminate(expectedDirs.size());
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:17,
代码来源:RepositoryIndexerListener.java

示例2: getArtifacts

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private  ResultImplementation<String> getArtifacts(final String groupId, final ResultImpl<String> result, final List<RepositoryInfo> repos, final boolean skipUnIndexed) {
    final Set<String> artifacts = new TreeSet<String>(result.getResults());
    final SkippedAction skipAction = new SkippedAction(result);
    iterate(repos, new RepoAction() {
        @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
            BooleanQuery bq = new BooleanQuery();
            String id = groupId + ArtifactInfo.FS;
            bq.add(new BooleanClause(setBooleanRewrite(new PrefixQuery(new Term(ArtifactInfo.UINFO, id))), BooleanClause.Occur.MUST));
            //mkleint: this is not capped, because only a string is collected (and collapsed), the rest gets CGed fast
            IteratorSearchResponse response = repeatedPagedSearch(bq, Collections.singletonList(context), NO_CAP_RESULT_COUNT);
            if (response != null) {
                try {
                for (ArtifactInfo artifactInfo : response.getResults()) {
                    artifacts.add(artifactInfo.getArtifactId());
                }
                } finally {
                    response.close();
                }
            }
        }
    }, skipAction, skipUnIndexed);
    result.setResults(artifacts);
    return result;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:25,
代码来源:NexusRepositoryIndexerImpl.java

示例3: getVersions

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private ResultImplementation<NBVersionInfo> getVersions(final String groupId, final String artifactId, final ResultImpl<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
    final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
    final SkippedAction skipAction = new SkippedAction(result);
    iterate(repos, new RepoAction() {
        @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
            BooleanQuery bq = new BooleanQuery();
            String id = groupId + ArtifactInfo.FS + artifactId + ArtifactInfo.FS;
            bq.add(new BooleanClause(setBooleanRewrite(new PrefixQuery(new Term(ArtifactInfo.UINFO, id))), BooleanClause.Occur.MUST));
            IteratorSearchResponse response = repeatedPagedSearch(bq, Collections.singletonList(context), MAX_RESULT_COUNT);
            if (response != null) {
               try {
                    for (ArtifactInfo ai : response.iterator()) {
                        infos.add(convertToNBVersionInfo(ai));
                    }
                } finally {
                    result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
                    result.addTotalResultCount(response.getTotalHitsCount());
                    response.close();
                }
            }
        }
    }, skipAction, skipUnIndexed);
    doSortIssue226100(infos);
    result.setResults(infos);
    return result;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:27,
代码来源:NexusRepositoryIndexerImpl.java

示例4: findDependencyUsage

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private ResultImplementation<NBVersionInfo> findDependencyUsage(String groupId, String artifactId, String version, final ResultImpl<NBVersionInfo> result, @NullAllowed List<RepositoryInfo> repos, final boolean skipUnIndexed) {
    final Query q = ArtifactDependencyIndexCreator.query(groupId, artifactId, version);
    final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
    final SkippedAction skipAction = new SkippedAction(result);
    iterate(repos, new RepoAction() {
        @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
            IteratorSearchResponse response = repeatedPagedSearch(q, Collections.singletonList(context), MAX_RESULT_COUNT);
            if (response != null) {
                try {
                    for (ArtifactInfo ai : response.iterator()) {
                        infos.add(convertToNBVersionInfo(ai));
                    }
                } finally {
                    result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
                    result.addTotalResultCount(response.getTotalHitsCount());
                    response.close();
                }
            }
        }
    }, skipAction, skipUnIndexed);
    result.setResults(infos);
    return result;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:24,
代码来源:NexusRepositoryIndexerImpl.java

示例5: findBySHA1

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private ResultImplementation<NBVersionInfo> findBySHA1(final String sha1, final ResultImpl<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
    final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
    final SkippedAction skipAction = new SkippedAction(result);
    iterate(repos, new RepoAction() {
        @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
            BooleanQuery bq = new BooleanQuery();
            bq.add(new BooleanClause((setBooleanRewrite(constructQuery(MAVEN.SHA1, sha1))), BooleanClause.Occur.SHOULD));
            IteratorSearchResponse response = repeatedPagedSearch(bq, Collections.singletonList(context), MAX_RESULT_COUNT);
            if (response != null) {
                try {
                    for (ArtifactInfo ai : response.iterator()) {
                        infos.add(convertToNBVersionInfo(ai));
                    }
                } finally {
                    result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
                    result.addTotalResultCount(response.getTotalHitsCount());
                    response.close();
                }
            }
        }
    }, skipAction, skipUnIndexed);
    doSortIssue226100(infos);
    result.setResults(infos);
    return result;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:26,
代码来源:NexusRepositoryIndexerImpl.java

示例6: filterPluginArtifactIds

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private ResultImplementation<String> filterPluginArtifactIds(final String groupId, final String prefix, ResultImpl<String> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
    final Set<String> artifacts = new TreeSet<String>(result.getResults());
    final SkippedAction skipAction = new SkippedAction(result);
    iterate(repos, new RepoAction() {
        @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
            BooleanQuery bq = new BooleanQuery();
            String id = groupId + ArtifactInfo.FS + prefix;
            bq.add(new BooleanClause(new TermQuery(new Term(ArtifactInfo.PACKAGING, "maven-plugin")), BooleanClause.Occur.MUST));
            bq.add(new BooleanClause(setBooleanRewrite(new PrefixQuery(new Term(ArtifactInfo.UINFO, id))), BooleanClause.Occur.MUST));
            //mkleint: this is not capped, because only a string is collected (and collapsed), the rest gets CGed fast
            IteratorSearchResponse response = repeatedPagedSearch(bq, Collections.singletonList(context), NO_CAP_RESULT_COUNT);
            if (response != null) {
                try {
                    for (ArtifactInfo artifactInfo : response.getResults()) {
                        artifacts.add(artifactInfo.getArtifactId());
                    }
                } finally {
                    response.close();
                }
            }
        }
    }, skipAction, skipUnIndexed);
    result.setResults(artifacts);
    return result;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:26,
代码来源:NexusRepositoryIndexerImpl.java

示例7: filterPluginGroupIds

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private ResultImplementation<String> filterPluginGroupIds(final String prefix, ResultImpl<String> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
    final Set<String> artifacts = new TreeSet<String>(result.getResults());
    final SkippedAction skipAction = new SkippedAction(result);
    iterate(repos, new RepoAction() {
        @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
            BooleanQuery bq = new BooleanQuery();
            bq.add(new BooleanClause(new TermQuery(new Term(ArtifactInfo.PACKAGING, "maven-plugin")), BooleanClause.Occur.MUST));
            if (prefix.length() > 0) { //heap out of memory otherwise
                bq.add(new BooleanClause(setBooleanRewrite(new PrefixQuery(new Term(ArtifactInfo.GROUP_ID, prefix))), BooleanClause.Occur.MUST));
            }
            //mkleint: this is not capped, because only a string is collected (and collapsed), the rest gets CGed fast
            IteratorSearchResponse response = repeatedPagedSearch(bq, Collections.singletonList(context), NO_CAP_RESULT_COUNT);
            if (response != null) {
                try {
                    for (ArtifactInfo artifactInfo : response.getResults()) {
                        artifacts.add(artifactInfo.getGroupId());
                    }
                } finally {
                    response.close();
                }
            }
        }
    }, skipAction, skipUnIndexed);
    result.setResults(artifacts);
    return result;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:27,
代码来源:NexusRepositoryIndexerImpl.java

示例8: tearDown

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@After
@Override
public void tearDown()
    throws Exception
{

    for ( IndexingContext indexingContext : indexer.getIndexingContexts().values() )
    {
        indexer.removeIndexingContext( indexingContext, true );
    }
    /*
    removeIndexingContext with true cleanup files.
    // delete created index in the repository
    File indexDir = new File( repositoryConfig.getLocation(), ".indexer" );
    FileUtils.deleteDirectory( indexDir );
    assertFalse( indexDir.exists() );

    indexDir = new File( repositoryConfig.getLocation(), ".index" );
    FileUtils.deleteDirectory( indexDir );
    assertFalse( indexDir.exists() );
    */
    super.tearDown();
}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:24,
代码来源:ArchivaIndexingTaskExecutorTest.java

示例9: cleanupIndex

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
public void cleanupIndex()
{
    log.info( "cleanup IndexingContext" );
    try
    {
        NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
        for ( IndexingContext context : nexusIndexer.getIndexingContexts().values() )
        {
            nexusIndexer.removeIndexingContext( context, true );
        }
    }
    catch ( Exception e )
    {
        log.warn( "fail to cleanupIndex: {}", e.getMessage(), e );
    }

}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:18,
代码来源:MavenIndexerCleaner.java

示例10: getIndexingContexts

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private List<IndexingContext> getIndexingContexts( List<String> ids )
{
    List<IndexingContext> contexts = new ArrayList<>( ids.size() );

    for ( String id : ids )
    {
        IndexingContext context = indexer.getIndexingContexts().get( id );
        if ( context != null )
        {
            contexts.add( context );
        }
        else
        {
            log.warn( "context with id {} not exists", id );
        }
    }

    return contexts;
}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:20,
代码来源:MavenRepositorySearch.java

示例11: getRemoteIndexingContextIds

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@Override
public Set<String> getRemoteIndexingContextIds( String managedRepoId )
    throws RepositoryAdminException
{
    Set<String> ids = new HashSet<>();

    List<ProxyConnector> proxyConnectors = proxyConnectorAdmin.getProxyConnectorAsMap().get( managedRepoId );

    if ( proxyConnectors == null || proxyConnectors.isEmpty() )
    {
        return ids;
    }

    for ( ProxyConnector proxyConnector : proxyConnectors )
    {
        String remoteId = "remote-" + proxyConnector.getTargetRepoId();
        IndexingContext context = indexer.getIndexingContexts().get( remoteId );
        if ( context != null && context.isSearchable() )
        {
            ids.add( remoteId );
        }
    }

    return ids;
}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:26,
代码来源:MavenRepositorySearch.java

示例12: getAllGroupIds

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@Override
public Collection<String> getAllGroupIds( String principal, List<String> selectedRepos )
    throws RepositorySearchException
{
    List<IndexingContext> indexContexts = getIndexingContexts( selectedRepos );

    if ( indexContexts == null || indexContexts.isEmpty() )
    {
        return Collections.emptyList();
    }

    try
    {
        Set<String> allGroupIds = new HashSet<>();
        for ( IndexingContext indexingContext : indexContexts )
        {
            allGroupIds.addAll( indexingContext.getAllGroups() );
        }
        return allGroupIds;
    }
    catch ( IOException e )
    {
        throw new RepositorySearchException( e.getMessage(), e );
    }

}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:27,
代码来源:MavenRepositorySearch.java

示例13: tearDown

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@After
@Override
public void tearDown()
    throws Exception
{
    for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
    {
        nexusIndexer.removeIndexingContext( indexingContext, true );
    }

    FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 ) );
    assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 ).exists() );

    FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 ) );
    assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 ).exists() );

    super.tearDown();
}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:19,
代码来源:AbstractMavenRepositorySearch.java

示例14: getIndexingContext

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private IndexingContext getIndexingContext()
    throws ConsumerException
{

    if ( this.indexingContext == null )
    {
        try
        {
            indexingContext = managedRepositoryAdmin.createIndexContext( repository );
        }
        catch ( RepositoryAdminException e )
        {
            throw new ConsumerException( e.getMessage(), e );
        }
    }
    return indexingContext;
}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:18,
代码来源:NexusIndexerConsumer.java

示例15: shutdown

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@PreDestroy
public void shutdown()
    throws RepositoryAdminException
{
    try
    {
        // close index on shutdown
        for ( ManagedRepository managedRepository : getManagedRepositories() )
        {
            IndexingContext context = indexer.getIndexingContexts().get( managedRepository.getId() );
            if ( context != null )
            {
                indexer.removeIndexingContext( context, false );
            }
        }
    }
    catch ( IOException e )
    {
        throw new RepositoryAdminException( e.getMessage(), e );
    }
}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:22,
代码来源:DefaultManagedRepositoryAdmin.java

示例16: shutdown

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@PreDestroy
private void shutdown()
    throws RepositoryAdminException
{
    try
    {
        List<RemoteRepository> remoteRepositories = getRemoteRepositories();
        // close index on shutdown
        for ( RemoteRepository remoteRepository : remoteRepositories )
        {
            IndexingContext context = indexer.getIndexingContexts().get( remoteRepository.getId() );
            if ( context != null )
            {
                indexer.removeIndexingContext( context, false );
            }
        }
    }
    catch ( IOException e )
    {
        throw new RepositoryAdminException( e.getMessage(), e );
    }
}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:23,
代码来源:DefaultRemoteRepositoryAdmin.java

示例17: cleanupIndex

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
public void cleanupIndex()
{
    log.info( "cleanup IndexingContext" );
    try
    {
        for ( IndexingContext context : nexusIndexer.getIndexingContexts().values() )
        {
            nexusIndexer.removeIndexingContext( context, true );
        }
    }
    catch ( Exception e )
    {
        log.warn( "fail to cleanupIndex: {}", e.getMessage(), e );
    }

}
 

开发者ID:apache,
项目名称:archiva,
代码行数:17,
代码来源:MavenIndexerCleaner.java

示例18: tearDown

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@After
@Override
public void tearDown()
    throws Exception
{
    for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
    {
        nexusIndexer.removeIndexingContext( indexingContext, true );
    }

    FileUtils.deleteDirectory( Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 ) );
    assertFalse( Files.exists(Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 )) );

    FileUtils.deleteDirectory( Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 ) );
    assertFalse( Files.exists(Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 )) );

    super.tearDown();
}
 

开发者ID:apache,
项目名称:archiva,
代码行数:19,
代码来源:AbstractMavenRepositorySearch.java

示例19: addArtifactsToIndex

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@Test
public void addArtifactsToIndex() throws Exception {

    ArchivaIndexingContext ctx = createTestContext();
    Path destDir = repository.getLocalPath().resolve("org/apache/archiva/archiva-search/1.0");
    Path srcDir = Paths.get("src/test/maven-search-test-repo/org/apache/archiva/archiva-search/1.0");
    org.apache.commons.io.FileUtils.copyDirectory(srcDir.toFile(), destDir.toFile());
    List<URI> uriList = new ArrayList<>();
    uriList.add(destDir.resolve("archiva-search-1.0.jar").toUri());
    uriList.add(destDir.resolve("archiva-search-1.0-sources.jar").toUri());
    mavenIndexManager.addArtifactsToIndex(ctx, uriList);

    IndexingContext mvnCtx = mavenIndexManager.getMvnContext(ctx);
    String term = "org.apache.archiva";
    Query q = new BooleanQuery.Builder().add( queryCreator.constructQuery( MAVEN.GROUP_ID, new UserInputSearchExpression( term ) ),
            BooleanClause.Occur.SHOULD ).build();
    assertEquals(2, mvnCtx.acquireIndexSearcher().count(q));
}
 

开发者ID:apache,
项目名称:archiva,
代码行数:19,
代码来源:MavenIndexManagerTest.java

示例20: removeArtifactsFromIndex

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@Test
public void removeArtifactsFromIndex() throws Exception {
    ArchivaIndexingContext ctx = createTestContext();
    Path destDir = repository.getLocalPath().resolve("org/apache/archiva/archiva-search/1.0");
    Path srcDir = Paths.get("src/test/maven-search-test-repo/org/apache/archiva/archiva-search/1.0");
    org.apache.commons.io.FileUtils.copyDirectory(srcDir.toFile(), destDir.toFile());
    List<URI> uriList = new ArrayList<>();
    uriList.add(destDir.resolve("archiva-search-1.0.jar").toUri());
    uriList.add(destDir.resolve("archiva-search-1.0-sources.jar").toUri());
    mavenIndexManager.addArtifactsToIndex(ctx, uriList);

    IndexingContext mvnCtx = mavenIndexManager.getMvnContext(ctx);
    String term = "org.apache.archiva";
    Query q = new BooleanQuery.Builder().add( queryCreator.constructQuery( MAVEN.GROUP_ID, new UserInputSearchExpression( term ) ),
            BooleanClause.Occur.SHOULD ).build();
    assertEquals(2, mvnCtx.acquireIndexSearcher().count(q));
    uriList.remove(0);
    mavenIndexManager.removeArtifactsFromIndex(ctx, uriList);
    assertEquals(1, mvnCtx.acquireIndexSearcher().count(q));
}
 

开发者ID:apache,
项目名称:archiva,
代码行数:21,
代码来源:MavenIndexManagerTest.java

示例21: shutdown

点赞 3

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@PreDestroy
private void shutdown()
    throws RepositoryAdminException
{
    try
    {
        List<org.apache.archiva.admin.model.beans.RemoteRepository> remoteRepositories = getRemoteRepositories();
        // close index on shutdown
        for ( org.apache.archiva.admin.model.beans.RemoteRepository remoteRepository : remoteRepositories )
        {
            IndexingContext context = indexer.getIndexingContexts().get( remoteRepository.getId() );
            if ( context != null )
            {
                indexer.removeIndexingContext( context, false );
            }
        }
    }
    catch ( IOException e )
    {
        throw new RepositoryAdminException( e.getMessage(), e );
    }
}
 

开发者ID:apache,
项目名称:archiva,
代码行数:23,
代码来源:DefaultRemoteRepositoryAdmin.java

示例22: search

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
static void search(String className, Indexer indexer, Collection<IndexingContext> contexts, List<? super ClassUsage> results) throws IOException {
    String searchString = crc32base64(className.replace('.', '/'));
    Query refClassQuery = indexer.constructQuery(ClassDependencyIndexCreator.FLD_NB_DEPENDENCY_CLASS.getOntology(), new StringSearchExpression(searchString));
    TopScoreDocCollector collector = TopScoreDocCollector.create(NexusRepositoryIndexerImpl.MAX_RESULT_COUNT, null);
    for (IndexingContext context : contexts) {
        IndexSearcher searcher = context.acquireIndexSearcher();
        try {
    searcher.search(refClassQuery, collector);
    ScoreDoc[] hits = collector.topDocs().scoreDocs;
    LOG.log(Level.FINER, "for {0} ~ {1} found {2} hits", new Object[] {className, searchString, hits.length});
    for (ScoreDoc hit : hits) {
        int docId = hit.doc;
        Document d = searcher.doc(docId);
        String fldValue = d.get(ClassDependencyIndexCreator.NB_DEPENDENCY_CLASSES);
        LOG.log(Level.FINER, "{0} uses: {1}", new Object[] {className, fldValue});
        Set<String> refClasses = parseField(searchString, fldValue, d.get(ArtifactInfo.NAMES));
        if (!refClasses.isEmpty()) {
            ArtifactInfo ai = IndexUtils.constructArtifactInfo(d, context);
            if (ai != null) {
                ai.setRepository(context.getRepositoryId());
                List<NBVersionInfo> version = NexusRepositoryIndexerImpl.convertToNBVersionInfo(Collections.singleton(ai));
                if (!version.isEmpty()) {
                    results.add(new ClassUsage(version.get(0), refClasses));
                }
            }
        }
    }
    } finally {
        context.releaseIndexSearcher(searcher);
    }
    }
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:33,
代码来源:ClassDependencyIndexCreator.java

示例23: scanningFinished

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@Override public void scanningFinished(IndexingContext ctx, ScanningResult result) {
//        Set<File> unencountered = new TreeSet<File>(expectedDirs);
//        unencountered.removeAll(encounteredDirs);
//        System.err.println("did not encounter " + unencountered.size() + ":");
//        for (File d : unencountered) {
//            System.err.println("  " + d);
//        }
    }
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:9,
代码来源:RepositoryIndexerListener.java

示例24: getArtifactContext

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@Override public ArtifactContext getArtifactContext(IndexingContext context, File file) {
    ArtifactContext ac = super.getArtifactContext(context, file);
    if (ac != null) {
        final ArtifactInfo ai = ac.getArtifactInfo();
        String fext = ai.getFileExtension();
        if (fext != null) {
            if (fext.endsWith(".lastUpdated")) {
                // #197670: why is this even considered?
                return null;
            }
            // Workaround for anomalous classifier behavior of nbm-maven-plugin:
            if (fext.equals("nbm")) {
                return new ArtifactContext(ac.getPom(), ac.getArtifact(), ac.getMetadata(), new ArtifactInfo(ai.getRepository(), ai.getGroupId(), ai.getArtifactId(), ai.getVersion(), ai.getClassifier(), fext) {
                    private String uinfo = null;
                    @Override public String getUinfo() {
                        if (uinfo == null) {
                            uinfo = new StringBuilder().
                                    append(ai.getGroupId()).append(ArtifactInfoRecord.FS).
                                    append(ai.getArtifactId()).append(ArtifactInfoRecord.FS).
                                    append(ai.getVersion()).append(ArtifactInfoRecord.FS).
                                    append(ArtifactInfoRecord.NA).append(ArtifactInfoRecord.FS).
                                    append(ai.getPackaging()).toString();
                        }
                        return uinfo;
                    }
                }, ac.getGav());
            }
        }
    }
    return ac;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:32,
代码来源:CustomArtifactContextProducer.java

示例25: addIndexingContextForced

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
public IndexingContext addIndexingContextForced( String id, String repositoryId, File repository,
    File indexDirectory, String repositoryUrl, String indexUpdateUrl,
    List<? extends IndexCreator> indexers )
    throws IOException
{
    IndexingContext context =
        indexer.createIndexingContext( id, repositoryId, repository, indexDirectory, repositoryUrl, indexUpdateUrl,
                                       true, true, indexers );
    indexingContexts.put( context.getId(), context );
    return context;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:12,
代码来源:NexusRepositoryIndexerImpl.java

示例26: removeIndexingContext

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
public void removeIndexingContext( IndexingContext context, boolean deleteFiles )
    throws IOException
{
    if ( indexingContexts.containsKey( context.getId() ) )
    {
        indexingContexts.remove( context.getId() );
        indexer.closeIndexingContext( context, deleteFiles );
    }
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:10,
代码来源:NexusRepositoryIndexerImpl.java

示例27: shutdownAll

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
public void shutdownAll() {
    LOGGER.fine("Shutting Down All Contexts");
    // Do not acquire write access since that can block waiting for a hung download.
    try {
        if (inited) {
            for (IndexingContext ic : getIndexingContexts().values()) {
                LOGGER.log(Level.FINER, "Shutting Down: {0}", ic.getId());
                removeIndexingContext(ic, false);
            }
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:15,
代码来源:NexusRepositoryIndexerImpl.java

示例28: getGAVsForPackaging

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private ResultImplementation<String> getGAVsForPackaging(final String packaging, final ResultImpl<String> result, 
                                         List<RepositoryInfo> repos, final boolean skipUnIndexed) {
    final List<String> infos = new ArrayList<String>(result.getResults());
    final SkippedAction skipAction = new SkippedAction(result);
    iterate(repos, new RepoAction() {
        @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
            BooleanQuery bq = new BooleanQuery();
            bq.add(new BooleanClause(new TermQuery(new Term(ArtifactInfo.PACKAGING, packaging)), BooleanClause.Occur.MUST));
            IteratorSearchResponse response = repeatedPagedSearch(bq, Collections.singletonList(context), NO_CAP_RESULT_COUNT);
            if (response != null) {
               try {
                    for (ArtifactInfo ai : response.iterator()) {
                        String gav = ai.getGroupId() + ":" + ai.getArtifactId() + ":" + ai.getVersion();
                        if (!infos.contains(gav)) {
                            infos.add(gav);
                        }
                    }
                } finally {
                    result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
                    result.addTotalResultCount(response.getTotalHitsCount());
                    response.close();
                }
            }
        }
    }, skipAction, skipUnIndexed);
    result.setResults(infos);
    return result;        
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:29,
代码来源:NexusRepositoryIndexerImpl.java

示例29: getRecords

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private ResultImplementation<NBVersionInfo> getRecords(final String groupId, final String artifactId, final String version, final ResultImpl<NBVersionInfo> result, 
                                         List<RepositoryInfo> repos, final boolean skipUnIndexed) {
    final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
    final SkippedAction skipAction = new SkippedAction(result);
    iterate(repos, new RepoAction() {
        @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
            BooleanQuery bq = new BooleanQuery();
            String id = groupId + ArtifactInfo.FS + artifactId + ArtifactInfo.FS + version + ArtifactInfo.FS;
            bq.add(new BooleanClause(new PrefixQuery(new Term(ArtifactInfo.UINFO, id)), BooleanClause.Occur.MUST));
            IteratorSearchResponse response = repeatedPagedSearch(bq, Collections.singletonList(context), MAX_RESULT_COUNT);
            if (response != null) {
               try {
                    for (ArtifactInfo ai : response.iterator()) {
                        infos.add(convertToNBVersionInfo(ai));
                    }
                } finally {
                    result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
                    result.addTotalResultCount(response.getTotalHitsCount());
                    response.close();
                }
            }
        }
    }, skipAction, skipUnIndexed);
    doSortIssue226100(infos);
    result.setResults(infos);
    return result;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:28,
代码来源:NexusRepositoryIndexerImpl.java

示例30: findVersionsByClass

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private ResultImplementation<NBVersionInfo> findVersionsByClass(final String className, final ResultImpl<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
    final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
    final SkippedAction skipAction = new SkippedAction(result);
    iterate(repos, new RepoAction() {
        @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
            String clsname = className.replace(".", "/");
                while (!clsname.isEmpty() && (clsname.startsWith("*") || clsname.startsWith("?"))) {
                    //#238740
                    clsname = clsname.substring(1);
                }
                if (clsname.isEmpty()) {
                    return;
                }
            
            Query q = setBooleanRewrite(constructQuery(MAVEN.CLASSNAMES, clsname.toLowerCase(Locale.ENGLISH)));
            IteratorSearchResponse response = repeatedPagedSearch(q, Collections.singletonList(context), MAX_RESULT_COUNT);
            if (response != null) {
                try {
                    infos.addAll(postProcessClasses(response.getResults(), clsname));
                } finally {
                    //?? really count in this case?
                    result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
                    result.addTotalResultCount(response.getTotalHitsCount());
                    response.close();
                }
            }
        }
    }, skipAction, skipUnIndexed);
    doSortIssue226100(infos);
    result.setResults(infos);
    return result;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:33,
代码来源:NexusRepositoryIndexerImpl.java

示例31: findArchetypes

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private ResultImplementation<NBVersionInfo> findArchetypes(final ResultImpl<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
    final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
    final SkippedAction skipAction = new SkippedAction(result);
    iterate(repos, new RepoAction() {
        @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
            BooleanQuery bq = new BooleanQuery();
            // XXX also consider using NexusArchetypeDataSource
            bq.add(new BooleanClause(new TermQuery(new Term(ArtifactInfo.PACKAGING, "maven-archetype")), BooleanClause.Occur.MUST)); //NOI18N
            FlatSearchRequest fsr = new FlatSearchRequest(bq, ArtifactInfo.VERSION_COMPARATOR);
            /* There are >512 archetypes in Central, and we want them all in ChooseArchetypePanel
            fsr.setCount(MAX_RESULT_COUNT);
            */
            IteratorSearchResponse response = repeatedPagedSearch(bq, Collections.singletonList(context), NO_CAP_RESULT_COUNT);
            if (response != null) {
                try {
                    for (ArtifactInfo ai : response.iterator()) {
                        infos.add(convertToNBVersionInfo(ai));
                    }
                } finally {
                    result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
                    result.addTotalResultCount(response.getTotalHitsCount());
                    response.close();
                }
            }
        }
    }, skipAction, skipUnIndexed);
    doSortIssue226100(infos);
    result.setResults(infos);
    return result;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:31,
代码来源:NexusRepositoryIndexerImpl.java

示例32: accepts

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@Override
public boolean accepts(IndexingContext ctx, ArtifactInfo ai) {
    if ("javadoc".equals(ai.getClassifier()) || "sources".equals(ai.getClassifier())) {
        return false;
    }
    return true;
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:8,
代码来源:NexusRepositoryIndexerImpl.java

示例33: finishIndexingTask

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
private void finishIndexingTask( ArtifactIndexingTask indexingTask, ManagedRepository repository,
                                 IndexingContext context )
    throws TaskExecutionException
{
    try
    {

        context.optimize();

        if ( !repository.isSkipPackedIndexCreation() )
        {

            IndexPackingRequest request = new IndexPackingRequest( context, context.getIndexDirectoryFile() );
            indexPacker.packIndex( request );
            context.updateTimestamp( true );

            log.debug( "Index file packaged at '{}'.", context.getIndexDirectoryFile() );
        }
        else
        {
            log.debug( "skip packed index creation" );
        }
    }
    catch ( IOException e )
    {
        log.error( "Error occurred while executing indexing task '" + indexingTask + "': " + e.getMessage() );
        throw new TaskExecutionException( "Error occurred while executing indexing task '" + indexingTask + "'",
                                          e );
    }
}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:31,
代码来源:ArchivaIndexingTaskExecutor.java

示例34: startup

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@PostConstruct
public void startup()
    throws ArchivaException, RepositoryAdminException, PlexusSisuBridgeException, IOException,
    UnsupportedExistingLuceneIndexException, DownloadRemoteIndexException
{
    archivaConfiguration.addListener( this );
    // TODO add indexContexts even if null

    nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );

    indexUpdater = plexusSisuBridge.lookup( IndexUpdater.class );

    this.indexPacker = plexusSisuBridge.lookup( IndexPacker.class );

    for ( RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() )
    {
        String contextKey = "remote-" + remoteRepository.getId();
        IndexingContext context = nexusIndexer.getIndexingContexts().get( contextKey );
        if ( context == null )
        {
            continue;
        }

        // TODO record jobs from configuration
        if ( remoteRepository.isDownloadRemoteIndex() && StringUtils.isNotEmpty(
            remoteRepository.getCronExpression() ) )
        {
            boolean fullDownload = context.getIndexDirectoryFile().list().length == 0;
            scheduleDownloadRemote( remoteRepository.getId(), false, fullDownload );
        }
    }


}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:35,
代码来源:DefaultDownloadRemoteIndexScheduler.java

示例35: shutdown

点赞 2

import org.apache.maven.index.context.IndexingContext; //导入依赖的package包/类
@PreDestroy
public void shutdown()
    throws RepositoryAdminException, IOException
{
    for ( RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() )
    {
        String contextKey = "remote-" + remoteRepository.getId();
        IndexingContext context = nexusIndexer.getIndexingContexts().get( contextKey );
        if ( context == null )
        {
            continue;
        }
        nexusIndexer.removeIndexingContext( context, false );
    }
}
 

开发者ID:ruikom,
项目名称:apache-archiva,
代码行数:16,
代码来源:DefaultDownloadRemoteIndexScheduler.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)