Search in sources :

Example 1 with TaskQueueException

use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.

the class DefaultRepositoryProxyHandler method queueRepositoryTask.

private void queueRepositoryTask(String repositoryId, StorageAsset localFile) {
    RepositoryTask task = new RepositoryTask();
    task.setRepositoryId(repositoryId);
    task.setResourceFile(localFile);
    task.setUpdateRelatedArtifacts(true);
    task.setScanAll(true);
    try {
        scheduler.queueTask(task);
    } catch (TaskQueueException e) {
        log.error("Unable to queue repository task to execute consumers on resource file ['{}" + "'].", localFile.getName());
    }
}
Also used : RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 2 with TaskQueueException

use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.

the class NexusIndexerConsumer method processFile.

@Override
public void processFile(String path) throws ConsumerException {
    Path artifactFile = managedRepository.resolve(path);
    ArtifactIndexingTask task = new ArtifactIndexingTask(repository, artifactFile, ArtifactIndexingTask.Action.ADD, repository.getIndexingContext());
    try {
        log.debug("Queueing indexing task '{}' to add or update the artifact in the index.", task);
        scheduler.queueTask(task);
    } catch (TaskQueueException e) {
        throw new ConsumerException(e.getMessage(), e);
    }
}
Also used : Path(java.nio.file.Path) ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) ConsumerException(org.apache.archiva.consumers.ConsumerException) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 3 with TaskQueueException

use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.

the class DefaultRepositoriesService method queueRepositoryTask.

private void queueRepositoryTask(String repositoryId, StorageAsset localFile) {
    RepositoryTask task = new RepositoryTask();
    task.setRepositoryId(repositoryId);
    task.setResourceFile(localFile);
    task.setUpdateRelatedArtifacts(true);
    try {
        scheduler.queueTask(task);
    } catch (TaskQueueException e) {
        log.error("Unable to queue repository task to execute consumers on resource file ['{}" + "'].", localFile.getName());
    }
}
Also used : RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 4 with TaskQueueException

use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.

the class DefaultRepositoryTaskAdministration method scheduleIndexScan.

@Override
public void scheduleIndexScan(String repositoryId, String relativePath) throws RepositoryAdminException {
    if (StringUtils.isEmpty(repositoryId)) {
        throw RepositoryAdminException.ofKey("repository.id.invalid", "");
    }
    try {
        org.apache.archiva.repository.ManagedRepository repository = repositoryRegistry.getManagedRepository(repositoryId);
        if (repository == null) {
            throw RepositoryAdminException.ofKey("repository.not_found", repositoryId);
        }
        StorageAsset asset = repository.getAsset(relativePath);
        if (!asset.exists()) {
            throw RepositoryAdminException.ofKey("repository.file.not_found", repositoryId, relativePath);
        }
        ArtifactIndexingTask task = new ArtifactIndexingTask(repository, asset.getFilePath(), ArtifactIndexingTask.Action.FINISH, repository.getIndexingContext());
        task.setExecuteOnEntireRepo(false);
        task.setOnlyUpdate(true);
        indexingArchivaTaskScheduler.queueTask(task);
    } catch (TaskQueueException e) {
        log.error("Could not queue the task: {}", e.getMessage(), e);
        throw RepositoryAdminException.ofKey("repository.scan.task_queue_error", e, e.getMessage());
    }
}
Also used : ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 5 with TaskQueueException

use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.

the class DefaultRepositoryTaskAdministration method scheduleMetadataUpdateScan.

@Override
public void scheduleMetadataUpdateScan(String repositoryId) throws RepositoryAdminException {
    if (StringUtils.isEmpty(repositoryId)) {
        throw RepositoryAdminException.ofKey("repository.id.invalid", "");
    }
    try {
        org.apache.archiva.repository.ManagedRepository repository = repositoryRegistry.getManagedRepository(repositoryId);
        if (repository == null) {
            throw RepositoryAdminException.ofKey("repository.not_found", repositoryId);
        }
        repositoryArchivaTaskScheduler.queueTask(new RepositoryTask(repositoryId, false));
    } catch (TaskQueueException e) {
        log.error("Could not queue the task: {}", e.getMessage(), e);
        throw RepositoryAdminException.ofKey("repository.scan.task_queue_error", e, e.getMessage());
    }
}
Also used : RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Aggregations

TaskQueueException (org.apache.archiva.components.taskqueue.TaskQueueException)20 RepositoryTask (org.apache.archiva.scheduler.repository.model.RepositoryTask)15 ArtifactIndexingTask (org.apache.archiva.scheduler.indexing.ArtifactIndexingTask)10 ScanStatus (org.apache.archiva.admin.model.beans.ScanStatus)4 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Named (javax.inject.Named)2 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)2 RepositoryTaskAdministration (org.apache.archiva.admin.model.admin.RepositoryTaskAdministration)2 IndexingTask (org.apache.archiva.admin.model.beans.IndexingTask)2 MetadataScanTask (org.apache.archiva.admin.model.beans.MetadataScanTask)2 RepositoryTaskInfo (org.apache.archiva.admin.model.beans.RepositoryTaskInfo)2 TaskQueueExecutor (org.apache.archiva.components.taskqueue.execution.TaskQueueExecutor)2 ConsumerException (org.apache.archiva.consumers.ConsumerException)2 RepositoryStatisticsManager (org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager)2 RepositoryRegistry (org.apache.archiva.repository.RepositoryRegistry)2 IndexingArchivaTaskScheduler (org.apache.archiva.scheduler.indexing.IndexingArchivaTaskScheduler)2