Examples of IndexingContext


Examples of org.apache.maven.index.context.IndexingContext

            indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
            Occur.SHOULD );

        if ( !indexer.getIndexingContexts().containsKey( repositoryConfig.getId() ) )
        {
            IndexingContext context = indexer.addIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(),
                                                                  new File( repositoryConfig.getLocation() ),
                                                                  new File( repositoryConfig.getLocation(),
                                                                            ".indexer" ), null, null,
                                                                  mavenIndexerUtils.getAllIndexCreators() );
            context.setSearchable( true );
        }

        FlatSearchRequest request = new FlatSearchRequest( q );
        FlatSearchResponse response = indexer.searchFlat( request );
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        throws TaskExecutionException
    {
        ArtifactIndexingTask indexingTask = (ArtifactIndexingTask) task;

        ManagedRepository repository = indexingTask.getRepository();
        IndexingContext context = indexingTask.getContext();

        if ( ArtifactIndexingTask.Action.FINISH.equals( indexingTask.getAction() )
            && indexingTask.isExecuteOnEntireRepo() )
        {
            try
            {
                nexusIndexer.scan( context, null, indexingTask.isOnlyUpdate() );
            }
            catch ( IOException e )
            {
                throw new TaskExecutionException( "Error scan repository " + repository, e );
            }
            log.debug( "Finishing indexing task on repo: {}", repository.getId() );
            finishIndexingTask( indexingTask, repository, context );
        }
        else
        {
            // create context if not a repo scan request
            if ( !indexingTask.isExecuteOnEntireRepo() )
            {
                try
                {
                    log.debug( "Creating indexing context on resource: {}", indexingTask.getResourceFile().getPath() );
                    context = managedRepositoryAdmin.createIndexContext( repository );
                }
                catch ( RepositoryAdminException e )
                {
                    log.error( "Error occurred while creating context: " + e.getMessage() );
                    throw new TaskExecutionException( "Error occurred while creating context: " + e.getMessage(), e );
                }
            }

            if ( context == null || context.getIndexDirectory() == null )
            {
                throw new TaskExecutionException( "Trying to index an artifact but the context is already closed" );
            }

            try
            {
                File artifactFile = indexingTask.getResourceFile();
                ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );

                if ( ac != null )
                {
                    if ( indexingTask.getAction().equals( ArtifactIndexingTask.Action.ADD ) )
                    {
                        //IndexSearcher s = context.getIndexSearcher();
                        //String uinfo = ac.getArtifactInfo().getUinfo();
                        //TopDocs d = s.search( new TermQuery( new Term( ArtifactInfo.UINFO, uinfo ) ), 1 );

                        BooleanQuery q = new BooleanQuery();
                        q.add( nexusIndexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression(
                            ac.getArtifactInfo().groupId ) ), BooleanClause.Occur.MUST );
                        q.add( nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression(
                            ac.getArtifactInfo().artifactId ) ), BooleanClause.Occur.MUST );
                        q.add( nexusIndexer.constructQuery( MAVEN.VERSION, new SourcedSearchExpression(
                            ac.getArtifactInfo().version ) ), BooleanClause.Occur.MUST );
                        if ( ac.getArtifactInfo().classifier != null )
                        {
                            q.add( nexusIndexer.constructQuery( MAVEN.CLASSIFIER, new SourcedSearchExpression(
                                ac.getArtifactInfo().classifier ) ), BooleanClause.Occur.MUST );
                        }
                        if ( ac.getArtifactInfo().packaging != null )
                        {
                            q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
                                ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
                        }
                        FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
                        FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
                        if ( flatSearchResponse.getResults().isEmpty() )
                        {
                            log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() );
                            nexusIndexer.addArtifactToIndex( ac, context );
                        }
                        else
                        {
                            log.debug( "Updating artifact '{}' in index..", ac.getArtifactInfo() );
                            // TODO check if update exists !!
                            nexusIndexer.deleteArtifactFromIndex( ac, context );
                            nexusIndexer.addArtifactToIndex( ac, context );
                        }

                        context.updateTimestamp();

                        // close the context if not a repo scan request
                        if ( !indexingTask.isExecuteOnEntireRepo() )
                        {
                            log.debug( "Finishing indexing task on resource file : {}",
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

    protected void createIndex( String repository, List<File> filesToBeIndexed, boolean scan )
        throws Exception
    {

        IndexingContext context = nexusIndexer.getIndexingContexts().get( repository );

        if ( context != null )
        {
            nexusIndexer.removeIndexingContext( context, true );
        }

        File indexerDirectory = new File( FileUtil.getBasedir(), "/target/repos/" + repository + "/.indexer" );

        if ( indexerDirectory.exists() )
        {
            FileUtils.deleteDirectory( indexerDirectory );
        }

        assertFalse( indexerDirectory.exists() );

        File lockFile = new File( FileUtil.getBasedir(), "/target/repos/" + repository + "/.indexer/write.lock" );
        if ( lockFile.exists() )
        {
            lockFile.delete();
        }

        assertFalse( lockFile.exists() );

        File repo = new File( FileUtil.getBasedir(), "src/test/" + repository );
        assertTrue( repo.exists() );
        File indexDirectory =
            new File( FileUtil.getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
        indexDirectory.deleteOnExit();
        FileUtils.deleteDirectory( indexDirectory );

        context = nexusIndexer.addIndexingContext( repository, repository, repo, indexDirectory,
                                                   repo.toURI().toURL().toExternalForm(),
                                                   indexDirectory.toURI().toURL().toString(),
                                                   search.getAllIndexCreators() );

        // minimize datas in memory
        context.getIndexWriter().setMaxBufferedDocs( -1 );
        context.getIndexWriter().setRAMBufferSizeMB( 1 );
        for ( File artifactFile : filesToBeIndexed )
        {
            assertTrue( "file not exists " + artifactFile.getPath(), artifactFile.exists() );
            ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
            nexusIndexer.addArtifactToIndex( ac, context );
            context.updateTimestamp( true );
        }

        if ( scan )
        {
            nexusIndexer.scan( context, new ArtifactScanListener(), false );
        }
        // force flushing
        context.getIndexWriter().commit();
        context.getIndexWriter().close( true );
        // wait for io flush ....
        //Thread.sleep( 2000 );
        context.setSearchable( true );

    }
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

    {
        List<IndexingContext> contexts = new ArrayList<IndexingContext>( ids.size() );

        for ( String id : ids )
        {
            IndexingContext context = indexer.getIndexingContexts().get( id );
            if ( context != null )
            {
                contexts.add( context );
            }
            else
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

                    else
                    {
                        indexDirectory = new File( repoConfig.getLocation(), ".indexer" );
                    }

                    IndexingContext context = indexer.getIndexingContexts().get( repoConfig.getId() );
                    if ( context != null )
                    {
                        // alreday here so no need to record it again
                        log.debug( "index with id {} already exists skip adding it", repoConfig.getId() );
                        // set searchable flag
                        context.setSearchable( repoConfig.isScanned() );
                        indexingContextIds.add( context.getId() );
                        indexingContextIds.addAll( getRemoteIndexingContextIds( repo ) );
                        continue;
                    }

                    context = indexer.addIndexingContext( repoConfig.getId(), repoConfig.getId(),
                                                          new File( repoConfig.getLocation() ), indexDirectory, null,
                                                          null, getAllIndexCreators() );
                    context.setSearchable( repoConfig.isScanned() );
                    if ( context.isSearchable() )
                    {
                        indexingContextIds.addAll( getRemoteIndexingContextIds( repo ) );
                        indexingContextIds.add( context.getId() );
                    }
                    else
                    {
                        log.warn( "indexingContext with id {} not searchable", repoConfig.getId() );
                    }
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        }

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

Examples of org.apache.maven.index.context.IndexingContext

        try
        {
            // close index on shutdown
            for ( RemoteRepository remoteRepository : getRemoteRepositories() )
            {
                IndexingContext context = indexer.getIndexingContexts().get( remoteRepository.getId() );
                if ( context != null )
                {
                    indexer.removeIndexingContext( context, false );
                }
            }
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        {
            // FIXME get this from ArchivaAdministration
            String appServerBase = System.getProperty( "appserver.base" );

            String contextKey = "remote-" + remoteRepository.getId();
            IndexingContext indexingContext = indexer.getIndexingContexts().get( contextKey );
            if ( indexingContext != null )
            {
                return indexingContext;
            }
            // create path
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        try
        {
            // close index on shutdown
            for ( ManagedRepository managedRepository : getManagedRepositories() )
            {
                IndexingContext context = indexer.getIndexingContexts().get( managedRepository.getId() );
                if ( context != null )
                {
                    indexer.removeIndexingContext( context, false );
                }
            }
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        try
        {
            NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );

            IndexingContext context = nexusIndexer.getIndexingContexts().get( repository.getId() );
            if ( context != null )
            {
                // delete content only if directory exists
                nexusIndexer.removeIndexingContext( context,
                                                    deleteContent && context.getIndexDirectoryFile().exists() );
            }
        }
        catch ( PlexusSisuBridgeException e )
        {
            throw new RepositoryAdminException( e.getMessage(), e );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.