Examples of ArtifactContext


Examples of org.sonatype.nexus.index.ArtifactContext

                    new DefaultIndexingContext( repository.getId(), repository.getId(), managedRepository,
                                            indexDirectory, null, null, NexusIndexer.FULL_INDEX, false );
                context.setSearchable( repository.isScanned() );
               
                File artifactFile = indexingTask.getResourceFile();               
                ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
               
                if( ac != null )
                {  
                    if( indexingTask.getAction().equals( ArtifactIndexingTask.ADD ) )
                    {
                        boolean add = true;
                        IndexReader r = context.getIndexReader();     
                        for ( int i = 0; i < r.numDocs(); i++ )
                        {
                            if ( !r.isDeleted( i ) )
                            {
                                Document d = r.document( i );         
                                String uinfo = d.get( ArtifactInfo.UINFO );                               
                                if( ac.getArtifactInfo().getUinfo().equals( uinfo ) )
                                {
                                    add = false;
                                    break;
                                }
                            }
                        }
                       
                        if( add )
                        {  
                            log.debug( "Adding artifact '" + ac.getArtifactInfo() + "' to index.." );
                            indexerEngine.index( context, ac );
                        }
                        else
                        {
                            log.debug( "Updating artifact '" + ac.getArtifactInfo() + "' in index.." );
                            indexerEngine.update( context, ac );
                        }
                    }
                    else
                    {                          
                        log.debug( "removing artifact '" + ac.getArtifactInfo() + "' from index.." );
                        indexerEngine.remove( context, ac );
                    }
                   
                    final File indexLocation = new File( managedRepository, ".index" );
                    IndexPackingRequest request = new IndexPackingRequest( context, indexLocation );
View Full Code Here

Examples of org.sonatype.nexus.index.ArtifactContext

        //indexerEngine.beginIndexing( context );

        for ( File artifactFile : filesToBeIndexed )
        {
            ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
            indexerEngine.index( context, ac );
        }

        context.close( false );
        //indexerEngine.endIndexing( context );
View Full Code Here

Examples of org.sonatype.nexus.index.ArtifactContext

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

                    if ( ac != null )
                    {
                        if ( indexingTask.getAction().equals( ArtifactIndexingTask.Action.ADD ) )
                        {
                            boolean add = true;
                            IndexReader r = context.getIndexReader();
                            for ( int i = 0; i < r.numDocs(); i++ )
                            {
                                if ( !r.isDeleted( i ) )
                                {
                                    Document d = r.document( i );
                                    String uinfo = d.get( ArtifactInfo.UINFO );
                                    if ( ac.getArtifactInfo().getUinfo().equals( uinfo ) )
                                    {
                                        add = false;
                                        break;
                                    }
                                }
                            }

                            if ( add )
                            {
                                log.debug( "Adding artifact '" + ac.getArtifactInfo() + "' to index.." );
                                indexerEngine.index( context, ac );
                                context.getIndexWriter().commit();
                            }
                            else
                            {
                                log.debug( "Updating artifact '" + ac.getArtifactInfo() + "' in index.." );
                                indexerEngine.update( context, ac );
                                context.getIndexWriter().commit();
                            }
                        }
                        else
                        {
                            log.debug( "Removing artifact '" + ac.getArtifactInfo() + "' from index.." );
                            indexerEngine.remove( context, ac );
                            context.getIndexWriter().commit();
                        }
                    }
                }
View Full Code Here

Examples of org.sonatype.nexus.index.ArtifactContext

                    new DefaultIndexingContext( repository.getId(), repository.getId(), managedRepository,
                                            indexDirectory, null, null, NexusIndexer.FULL_INDEX, false );
                context.setSearchable( repository.isScanned() );
               
                File artifactFile = indexingTask.getResourceFile();               
                ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
               
                if( ac != null )
                {  
                    if( indexingTask.getAction().equals( ArtifactIndexingTask.ADD ) )
                    {
                        boolean add = true;
                        IndexReader r = context.getIndexReader();     
                        for ( int i = 0; i < r.numDocs(); i++ )
                        {
                            if ( !r.isDeleted( i ) )
                            {
                                Document d = r.document( i );         
                                String uinfo = d.get( ArtifactInfo.UINFO );                               
                                if( ac.getArtifactInfo().getUinfo().equals( uinfo ) )
                                {
                                    add = false;
                                    break;
                                }
                            }
                        }
                       
                        if( add )
                        {  
                            log.debug( "Adding artifact '" + ac.getArtifactInfo() + "' to index.." );
                            indexerEngine.index( context, ac );
                            context.optimize();
                        }
                        else
                        {
                            log.debug( "Updating artifact '" + ac.getArtifactInfo() + "' in index.." );
                            indexerEngine.update( context, ac );
                            context.optimize();
                        }
                    }
                    else
                    {                          
                        log.debug( "Removing artifact '" + ac.getArtifactInfo() + "' from index.." );
                        indexerEngine.remove( context, ac );
                        context.optimize();
                    }
                   
                    final File indexLocation = new File( managedRepository, ".index" );
View Full Code Here

Examples of org.sonatype.nexus.index.ArtifactContext

        //indexerEngine.beginIndexing( context );

        for ( File artifactFile : filesToBeIndexed )
        {
            ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
            indexerEngine.index( context, ac );
        }

        context.close( false );
        //indexerEngine.endIndexing( context );
View Full Code Here

Examples of org.sonatype.nexus.index.ArtifactContext

    {
        result.incrementCount();

        IndexingContext context = request.getIndexingContext();

        ArtifactContext ac = artifactContextProducer.getArtifactContext( context, file );

        if ( ac != null )
        {
            try
            {
View Full Code Here

Examples of org.sonatype.nexus.index.ArtifactContext

                    Hits hits = s.search( new TermQuery( term ) );

                    if ( hits.length() == 0 )
                    {
                        ArtifactInfo info = constructArtifactInfo( d );
                        ArtifactContext artifactContext = new ArtifactContext( null, null, null, info );
                        ArtifactIndexingContext indexingContext = new DefaultArtifactIndexingContext( artifactContext );

                        Document doc = new Document();

                        doc.add( new Field( ArtifactInfo.UINFO, AbstractIndexCreator.getGAV(
View Full Code Here

Examples of org.sonatype.nexus.index.ArtifactContext

    extends AbstractIndexCreator
{
 
    public void populateArtifactInfo( ArtifactIndexingContext context ) throws IOException
    {
        ArtifactContext artifactContext = context.getArtifactContext();
       
        ArtifactInfo ai = artifactContext.getArtifactInfo();

        File artifactFile = artifactContext.getArtifact();

        if ( artifactFile != null && artifactFile.exists() && artifactFile.getName().endsWith( ".jar" ) )
        {
            ai.classNames = getClasses( artifactFile );
        }
View Full Code Here

Examples of org.sonatype.nexus.index.ArtifactContext

    private Locator sha1l = new Sha1Locator();

    public void populateArtifactInfo( ArtifactIndexingContext context )
    {
        ArtifactContext artifactContext = context.getArtifactContext();

        File artifact = artifactContext.getArtifact();

        File pom = artifactContext.getPom();

        ArtifactInfo ai = artifactContext.getArtifactInfo();

        if ( pom != null )
        {
            Model model = modelReader.readModel( pom, ai.groupId, ai.artifactId, ai.version );
View Full Code Here

Examples of org.sonatype.nexus.index.ArtifactContext

                }
               
                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 );
                            if ( d.totalHits == 0 )
                            {
                                log.debug( "Adding artifact '" + ac.getArtifactInfo() + "' to index.." );
                                indexerEngine.index( context, ac );
                                context.getIndexWriter().commit();
                            }
                            else
                            {
                                log.debug( "Updating artifact '" + ac.getArtifactInfo() + "' in index.." );
                                indexerEngine.update( context, ac );
                                context.getIndexWriter().commit();
                            }

                            // close the context if not a repo scan request
                            if( !indexingTask.isExecuteOnEntireRepo() )
                            {
                                log.debug( "Finishing indexing task on resource file : " + indexingTask.getResourceFile().getPath() );
                                finishIndexingTask( indexingTask, repository, context );  
                            }
                        }
                        else
                        {
                            log.debug( "Removing artifact '" + ac.getArtifactInfo() + "' from index.." );
                            indexerEngine.remove( context, ac );
                            context.getIndexWriter().commit();
                        }
                    }
                }
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.