Examples of ArtifactIndexingTask


Examples of org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask

    {
        File artifactFile =
            new File( repositoryConfig.getLocation(),
                      "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );

        ArtifactIndexingTask task =
            TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.ADD );
       
        archivaConfigControl.expectAndReturn( archivaConfiguration.getConfiguration(), configuration, 2 );
       
        archivaConfigControl.replay();
View Full Code Here

Examples of org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask

    public void executeTask( Task task )
        throws TaskExecutionException
    {
        synchronized( indexerEngine )
        {
            ArtifactIndexingTask indexingTask = ( ArtifactIndexingTask ) task;
           
            ManagedRepositoryConfiguration repository =
                archivaConfiguration.getConfiguration().findManagedRepositoryById( indexingTask.getRepositoryId() );
   
            String indexDir = repository.getIndexDir();
            File managedRepository = new File( repository.getLocation() );
           
            File indexDirectory = null;
            if( indexDir != null && !"".equals( indexDir ) )
            {
                indexDirectory = new File( repository.getIndexDir() );
            }
            else
            {
                indexDirectory = new File( managedRepository, ".indexer" );
            }
           
            IndexingContext context = null;
            try
            {
                context =
                    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 );
                    indexPacker.packIndex( request );
                }               
            }
            catch ( IOException e )
            {
                throw new TaskExecutionException( "Error occurred while executing indexing task '" +
                    indexingTask.getName() + "'" );
            }
            catch ( UnsupportedExistingLuceneIndexException e )
            {
                throw new TaskExecutionException( "Unsupported Lucene index format: " + e.getMessage() );
            }
View Full Code Here

Examples of org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask

    {
        File artifactFile =
            new File( repositoryConfig.getLocation(),
                      "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );

        ArtifactIndexingTask task =
            TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context );

        indexingExecutor.executeTask( task );

        BooleanQuery q = new BooleanQuery();
View Full Code Here

Examples of org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask

    {
        File artifactFile =
            new File( repositoryConfig.getLocation(),
                      "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );

        ArtifactIndexingTask task =
            TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context );

        indexingExecutor.executeTask( task );
        indexingExecutor.executeTask( task );
View Full Code Here

Examples of org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask

    {
        File artifactFile =
            new File( repositoryConfig.getLocation(),
                      "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );

        ArtifactIndexingTask task =
            TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context );

        // remove artifact from index
        indexingExecutor.executeTask( task );
View Full Code Here

Examples of org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask

    {
        File artifactFile =
            new File( repositoryConfig.getLocation(),
                      "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );

        ArtifactIndexingTask task =
            TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context );

        indexingExecutor.executeTask( task );

        task =
View Full Code Here

Examples of org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask

    public void executeTask( Task task )
        throws TaskExecutionException
    {
        synchronized ( indexerEngine )
        {
            ArtifactIndexingTask indexingTask = (ArtifactIndexingTask) task;

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

            if ( ArtifactIndexingTask.Action.FINISH.equals( indexingTask.getAction() ) )
            {
                try
                {
                    context.optimize();

                    File managedRepository = new File( repository.getLocation() );
                    final File indexLocation = new File( managedRepository, ".index" );
                    IndexPackingRequest request = new IndexPackingRequest( context, indexLocation );
                    indexPacker.packIndex( request );

                    log.debug( "Index file packaged at '" + indexLocation.getPath() + "'." );
                }
                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 );
                }
                finally
                {
                    if ( context != null )
                    {
                        try
                        {
                            context.close( false );
                        }
                        catch ( IOException e )
                        {
                            log.error( "Error occurred while closing context: " + e.getMessage() );
                            throw new TaskExecutionException( "Error occurred while closing context: " + e.getMessage() );
                        }
                    }
                }
            }
            else
            {
                if ( 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 ) )
                        {
                            boolean add = true;
                            IndexReader r = context.getIndexReader();
                            for ( int i = 0; i < r.numDocs(); i++ )
                            {
View Full Code Here

Examples of org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask

    public void processFile( String path )
        throws ConsumerException
    {
        File artifactFile = new File( managedRepository, path );

        ArtifactIndexingTask task =
            TaskCreator.createIndexingTask( repositoryContent.getRepository(), artifactFile,
                                            ArtifactIndexingTask.Action.ADD, context );
        try
        {
            log.debug( "Queueing indexing task + '" + task + "' to add or update the artifact in the index." );
View Full Code Here

Examples of org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask

        }
    }

    public void completeScan()
    {
        ArtifactIndexingTask task =
            TaskCreator.createIndexingTask( repositoryContent.getRepository(), null,
                                            ArtifactIndexingTask.Action.FINISH, context );
        try
        {
            log.debug( "Queueing indexing task + '" + task + "' to finish indexing." );
View Full Code Here

Examples of org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask

            if ( !artifactFile.exists() )
            {
                context = TaskCreator.createContext( repository );

                ArtifactIndexingTask task =
                    TaskCreator.createIndexingTask( repository, artifactFile, ArtifactIndexingTask.Action.DELETE,
                                                    context );

                log.debug( "Queueing indexing task '" + task + "' to remove the artifact from the index." );
                scheduler.queueIndexingTask( task );
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.