Package org.apache.maven.archiva.scheduled.tasks

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


    }

    public void testExecutorForceScanAll()
        throws Exception
    {
        RepositoryTask repoTask = new RepositoryTask();

        repoTask.setRepositoryId( TEST_REPO_ID );
        repoTask.setScanAll( true );

        RepositoryContentStatistics stats = new RepositoryContentStatistics();
        stats.setDuration( 1234567 );
        stats.setNewFileCount( 8 );
        stats.setRepositoryId( TEST_REPO_ID );
View Full Code Here


        {
            addActionError( "Cannot run indexer on blank repository id." );
            return SUCCESS;
        }

        RepositoryTask task = new RepositoryTask();
        task.setRepositoryId( repoid );
        task.setName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repoid );
        task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );

        boolean scheduleTask = false;

        try
        {
View Full Code Here

    }

    public void executeTask( Task task )
        throws TaskExecutionException
    {
        RepositoryTask repoTask = (RepositoryTask) task;
       
        if ( StringUtils.isBlank( repoTask.getRepositoryId() ) )
        {
            throw new TaskExecutionException("Unable to execute RepositoryTask with blank repository Id.");
        }

        log.info( "Executing task from queue with job name: " + repoTask.getName() );
       
        try
        {
            ManagedRepositoryConfiguration arepo = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoTask.getRepositoryId() );
            if ( arepo == null )
            {
                throw new TaskExecutionException( "Unable to execute RepositoryTask with invalid repository id: " + repoTask.getRepositoryId() );
            }

            long sinceWhen = RepositoryScanner.FRESH_SCAN;

            List<RepositoryContentStatistics> results = dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) );
View Full Code Here

            {
                return false;
            }
        }

        RepositoryTask task = new RepositoryTask();
        task.setRepositoryId( repoId );
        task.setName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repoId );
        task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );

        taskScheduler.queueRepositoryTask( task );         
       
        return new Boolean( true );
    }
View Full Code Here

    {       
        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
        configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ),
                                       createManagedRepo( "internal", "default", "Internal Repository", true, false ) );
       
        RepositoryTask task = new RepositoryTask();
       
        taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingAnyRepositoryTask(), true );
        taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingRepositoryTask( "internal" ), false );
       
        taskScheduler.queueRepositoryTask( task );
View Full Code Here

        {
            addActionError( "Cannot run indexer on blank repository id." );
            return SUCCESS;
        }

        RepositoryTask task = new RepositoryTask();
        task.setRepositoryId( repoid );
        task.setName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repoid );
        task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );

        boolean scheduleTask = false;

        try
        {
View Full Code Here

    // MRM-848: Pre-configured repository initially appear to be empty
    private synchronized void queueInitialRepoScan( ManagedRepositoryConfiguration repoConfig )
    {
        String repoId = repoConfig.getId();

        RepositoryTask task = new RepositoryTask();
        task.setRepositoryId( repoId );
        task.setName( REPOSITORY_JOB + ":" + repoId + ":initial-scan" );
        task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );

        boolean scheduleTask = false;

        if ( queuedRepos.contains( repoId ) )
        {
View Full Code Here

    public void executeTask( Task task )
        throws TaskExecutionException
    {
        this.task = task;
       
        RepositoryTask repoTask = (RepositoryTask) task;
       
        if ( StringUtils.isBlank( repoTask.getRepositoryId() ) )
        {
            throw new TaskExecutionException("Unable to execute RepositoryTask with blank repository Id.");
        }

        log.info( "Executing task from queue with job name: " + repoTask.getName() );

        ManagedRepositoryConfiguration arepo = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoTask.getRepositoryId() );
       
        // execute consumers on resource file if set
        if( repoTask.getResourceFile() != null )
        {
            consumers.executeConsumers( arepo, repoTask.getResourceFile() );
        }
        else
        {
            // otherwise, execute consumers on whole repository
            try
            {  
                if ( arepo == null )
                {
                    throw new TaskExecutionException( "Unable to execute RepositoryTask with invalid repository id: " + repoTask.getRepositoryId() );
                }
   
                long sinceWhen = RepositoryScanner.FRESH_SCAN;
   
                List<RepositoryContentStatistics> results = (List<RepositoryContentStatistics>) dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) );
View Full Code Here

   
    private void executeConsumers( File localFile )
    {
        try
        {
            RepositoryTask currentTaskInExecution = ( RepositoryTask ) taskExecutor.getCurrentTaskInExecution();
            if( currentTaskInExecution != null || scheduler.isProcessingAnyRepositoryTask() )
            {  
                // check if the repository is already queued to be scanned
                if( scheduler.isProcessingRepositoryTaskWithName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repository.getId() )
                        || scheduler.isProcessingRepositoryTaskWithName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repository.getId() + ":" + localFile.getName() ) )
                {
                    // no need to execute the consumers since repo is already queued
                    return;
                }
                else
                {
                    // schedule the task
                    RepositoryTask task = new RepositoryTask();
                    task.setRepositoryId( repository.getId() );
                    task.setName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repository.getId() + ":" + localFile.getName() );
                    task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );
                    task.setResourceFile( localFile );
                   
                    try
                    {
                        scheduler.queueRepositoryTask( task );
                    }
View Full Code Here

            {
                return false;
            }
        }

        RepositoryTask task = new RepositoryTask();
        task.setRepositoryId( repoId );
        task.setName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repoId );
        task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );

        taskScheduler.queueRepositoryTask( task );         
       
        return new Boolean( true );
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.archiva.scheduled.tasks.RepositoryTask

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.