Search in sources :

Example 16 with TaskQueueException

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

the class DefaultRepositoryTaskAdministration method scheduleMetadataFullScan.

@Override
public void scheduleMetadataFullScan(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, true));
    } 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)

Example 17 with TaskQueueException

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

the class DefaultRepositoryTaskAdministration method scheduleFullScan.

@Override
public void scheduleFullScan(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);
        }
        ArtifactIndexingTask task = new ArtifactIndexingTask(repository, null, ArtifactIndexingTask.Action.FINISH, repository.getIndexingContext());
        task.setExecuteOnEntireRepo(true);
        task.setOnlyUpdate(false);
        indexingArchivaTaskScheduler.queueTask(task);
        repositoryArchivaTaskScheduler.queueTask(new RepositoryTask(repositoryId, true));
    } 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) RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 18 with TaskQueueException

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

the class DefaultRepositoryTaskAdministration method getCurrentScanStatus.

@Override
public ScanStatus getCurrentScanStatus(String repositoryId) throws RepositoryAdminException {
    if (StringUtils.isEmpty(repositoryId)) {
        throw RepositoryAdminException.ofKey("repository.id.invalid", "");
    }
    org.apache.archiva.repository.ManagedRepository repository = repositoryRegistry.getManagedRepository(repositoryId);
    if (repository == null) {
        throw RepositoryAdminException.ofKey("repository.not_found", repositoryId);
    }
    ScanStatus status = new ScanStatus();
    try {
        RepositoryTask scanTask = scanningTaskExecutor.getCurrentTask();
        if (scanTask != null && !repositoryId.equals(scanTask.getRepositoryId())) {
            scanTask = null;
        }
        ArtifactIndexingTask indexTask = indexingTaskExecutor.getCurrentTask();
        if (indexTask != null && !repositoryId.equals(indexTask.getRepository().getId())) {
            indexTask = null;
        }
        updateScanInfo(status, scanTask, scanningTaskExecutor.getQueue().getQueueSnapshot().stream().filter(task -> repositoryId.equals(task.getRepositoryId())).collect(Collectors.toList()));
        updateIndexInfo(status, indexTask, indexingTaskExecutor.getQueue().getQueueSnapshot().stream().filter(task -> repositoryId.equals(task.getRepository().getId())).collect(Collectors.toList()));
        return status;
    } catch (TaskQueueException e) {
        log.error("Could not get task information: {}", e.getMessage(), e);
        throw RepositoryAdminException.ofKey("repository.scan.task_retrieval_failed", e.getMessage());
    }
}
Also used : ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) ScanStatus(org.apache.archiva.admin.model.beans.ScanStatus) RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 19 with TaskQueueException

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

the class DefaultRepositoryTaskAdministration method getCurrentScanStatus.

@Override
public ScanStatus getCurrentScanStatus() throws RepositoryAdminException {
    ScanStatus status = new ScanStatus();
    try {
        RepositoryTask scanTask = scanningTaskExecutor.getCurrentTask();
        ArtifactIndexingTask indexTask = indexingTaskExecutor.getCurrentTask();
        updateScanInfo(status, scanTask, scanningTaskExecutor.getQueue().getQueueSnapshot());
        updateIndexInfo(status, indexTask, indexingTaskExecutor.getQueue().getQueueSnapshot());
        return status;
    } catch (TaskQueueException e) {
        log.error("Could not get task information: {}", e.getMessage(), e);
        throw RepositoryAdminException.ofKey("repository.scan.task_retrieval_failed", e.getMessage());
    }
}
Also used : ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) ScanStatus(org.apache.archiva.admin.model.beans.ScanStatus) RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 20 with TaskQueueException

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

the class DefaultFileUploadService method queueRepositoryTask.

private void queueRepositoryTask(String repositoryId, StorageAsset localFile) {
    RepositoryTask task = new RepositoryTask();
    task.setRepositoryId(repositoryId);
    task.setResourceFile(localFile);
    task.setUpdateRelatedArtifacts(true);
    task.setScanAll(false);
    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)

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