Package org.apache.maven.index.context

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


        // or we found what we need
        while ( ( result == null ) && ( pointer < maxRecPointer ) && ( pointer < hits.scoreDocs.length ) )
        {
            Document doc = indexSearcher.doc( hits.scoreDocs[pointer].doc );

            IndexingContext context = getIndexingContextForPointer( doc, hits.scoreDocs[pointer].doc );

            result = IndexUtils.constructArtifactInfo( doc, context );

            if ( result != null )
            {
                // WARNING: NOT FOR PRODUCTION SYSTEMS, THIS IS VERY COSTLY OPERATION
                // For debugging only!!!
                if ( searchRequest.isLuceneExplain() )
                {
                    result.getAttributes().put( Explanation.class.getName(),
                        indexSearcher.explain( searchRequest.getQuery(), hits.scoreDocs[pointer].doc ).toString() );
                }

                result.setLuceneScore( hits.scoreDocs[pointer].score );

                result.repository = context.getRepositoryId();

                result.context = context.getId();

                if ( filter != null )
                {
                    if ( !filter.accepts( context, result ) )
                    {
View Full Code Here


                    remoteRepositoryAdmin.getRemoteRepository( archivaLocator.getRepositoryId() );

                if ( remoteRepository != null )
                {
                    String logicalResource = getLogicalResource( archivaLocator, null, false );
                    IndexingContext indexingContext = remoteRepositoryAdmin.createIndexContext( remoteRepository );
                    File resourceFile = StringUtils.equals( logicalResource, "/" )
                        ? new File( indexingContext.getIndexDirectoryFile().getParent() )
                        : new File( indexingContext.getIndexDirectoryFile().getParent(), logicalResource );
                    resource = new ArchivaDavResource( resourceFile.getAbsolutePath(), locator.getResourcePath(), null,
                                                       request.getRemoteAddr(), activePrincipal,
                                                       request.getDavSession(), archivaLocator, this, mimeTypes,
                                                       auditListeners, scheduler, fileLockManager );
                    setHeaders( response, locator, resource );
View Full Code Here

            MergedRemoteIndexesTaskRequest taskRequest =
                new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );

            MergedRemoteIndexesTask job = new MergedRemoteIndexesTask( taskRequest );

            IndexingContext indexingContext = job.execute().getIndexingContext();

            File mergedRepoDir = indexingContext.getIndexDirectoryFile();
            TemporaryGroupIndex temporaryGroupIndex =
                new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(), repositoryGroupConfiguration.getId(),
                                         repositoryGroupConfiguration.getMergedIndexTtl() ).setCreationTime(
                    new Date().getTime() );
            temporaryGroupIndexMap.put( repositoryGroupConfiguration.getId(), temporaryGroupIndex );
            session.setAttribute( TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY,
                                  temporaryGroupIndexMap );
View Full Code Here

        throws TaskExecutionException
    {
        ArtifactIndexingTask indexingTask = (ArtifactIndexingTask) task;

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

        if ( ArtifactIndexingTask.Action.FINISH.equals( indexingTask.getAction() )
            && indexingTask.isExecuteOnEntireRepo() )
        {
            try
            {
                long start = System.currentTimeMillis();
                nexusIndexer.scan( context, null, indexingTask.isOnlyUpdate() );
                long end = System.currentTimeMillis();
                log.info( "indexed maven repository: {}, onlyUpdate: {}, time {} ms", repository.getId(),
                          indexingTask.isOnlyUpdate(), ( end - start ) );
            }
            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() == null
                        ? "none"
                        : 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();
                if ( artifactFile == null )
                {
                    log.debug( "no artifact pass in indexing task so skip it" );
                }
                else
                {
                    ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );

                    if ( ac != null )
                    {
                        // MRM-1779 pom must be indexed too
                        // TODO make that configurable?
                        if ( artifactFile.getPath().endsWith( ".pom" ) )
                        {
                            ac.getArtifactInfo().fextension = "pom";
                            ac.getArtifactInfo().packaging = "pom";
                            ac.getArtifactInfo().classifier = "pom";
                        }
                        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();
                            context.commit();


                        }
                        else
                        {
View Full Code Here

                    remoteRepositoryAdmin.getRemoteRepository( archivaLocator.getRepositoryId() );

                if ( remoteRepository != null )
                {
                    String logicalResource = getLogicalResource( archivaLocator, null, false );
                    IndexingContext indexingContext = remoteRepositoryAdmin.createIndexContext( remoteRepository );
                    File resourceFile = StringUtils.equals( logicalResource, "/" )
                        ? new File( indexingContext.getIndexDirectoryFile().getParent() )
                        : new File( indexingContext.getIndexDirectoryFile().getParent(), logicalResource );
                    resource = new ArchivaDavResource( resourceFile.getAbsolutePath(), locator.getResourcePath(), null,
                                                       request.getRemoteAddr(), activePrincipal,
                                                       request.getDavSession(), archivaLocator, this, mimeTypes,
                                                       auditListeners, scheduler, fileLockManager );
                    setHeaders( response, locator, resource );
View Full Code Here

            MergedRemoteIndexesTaskRequest taskRequest =
                new MergedRemoteIndexesTaskRequest(indexMergerRequest, indexMerger);

            MergedRemoteIndexesTask job = new MergedRemoteIndexesTask( taskRequest );

            IndexingContext indexingContext = job.execute().getIndexingContext();

            File mergedRepoDir = indexingContext.getIndexDirectoryFile();
            TemporaryGroupIndex temporaryGroupIndex =
                new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(), repositoryGroupConfiguration.getId(),
                                         repositoryGroupConfiguration.getMergedIndexTtl() ).setCreationTime(
                    new Date().getTime() );
            temporaryGroupIndexMap.put( repositoryGroupConfiguration.getId(), temporaryGroupIndex );
            session.setAttribute( TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY,
                                  temporaryGroupIndexMap );
View Full Code Here

        {
            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 );
                }
            }
View Full Code Here

        try
        {
            String appServerBase = getRegistry().getString( "appserver.base" );

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

        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

        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

Related Classes of org.apache.maven.index.context.IndexingContext

Copyright © 2018 www.massapicom. 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.