Search in sources :

Example 1 with RepositoryTaskInfo

use of org.apache.archiva.admin.model.beans.RepositoryTaskInfo in project archiva by apache.

the class DefaultRepositoryTaskAdministration method cancelScanTasks.

@Override
public List<RepositoryTaskInfo> cancelScanTasks(String repositoryId) throws RepositoryAdminException {
    try {
        ArrayList<RepositoryTaskInfo> resultList = new ArrayList<>();
        List<RepositoryTask> removeTasks = scanningTaskExecutor.getQueue().getQueueSnapshot().stream().filter(task -> repositoryId.equals(task.getRepositoryId())).collect(Collectors.toList());
        scanningTaskExecutor.getQueue().removeAll(removeTasks);
        RepositoryTask currentTask = scanningTaskExecutor.getCurrentTask();
        if (currentTask != null && repositoryId.equals(currentTask.getRepositoryId())) {
            scanningTaskExecutor.cancelTask(currentTask);
            resultList.add(getMetadataScanTaskInfo(currentTask));
        }
        resultList.addAll(removeTasks.stream().map(task -> getMetadataScanTaskInfo(task)).collect(Collectors.toList()));
        return resultList;
    } catch (TaskQueueException e) {
        throw RepositoryAdminException.ofKey("repository.task.dequeue_failed", repositoryId);
    }
}
Also used : ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) TaskQueueExecutor(org.apache.archiva.components.taskqueue.execution.TaskQueueExecutor) Logger(org.slf4j.Logger) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RepositoryArchivaTaskScheduler(org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler) RepositoryTaskInfo(org.apache.archiva.admin.model.beans.RepositoryTaskInfo) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) RepositoryRegistry(org.apache.archiva.repository.RepositoryRegistry) LoggerFactory(org.slf4j.LoggerFactory) RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) IndexingTask(org.apache.archiva.admin.model.beans.IndexingTask) ScanStatus(org.apache.archiva.admin.model.beans.ScanStatus) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) RepositoryTaskAdministration(org.apache.archiva.admin.model.admin.RepositoryTaskAdministration) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException) List(java.util.List) MetadataScanTask(org.apache.archiva.admin.model.beans.MetadataScanTask) Service(org.springframework.stereotype.Service) Named(javax.inject.Named) RepositoryStatisticsManager(org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager) IndexingArchivaTaskScheduler(org.apache.archiva.scheduler.indexing.IndexingArchivaTaskScheduler) RepositoryTaskInfo(org.apache.archiva.admin.model.beans.RepositoryTaskInfo) ArrayList(java.util.ArrayList) RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 2 with RepositoryTaskInfo

use of org.apache.archiva.admin.model.beans.RepositoryTaskInfo in project archiva by apache.

the class DefaultRepositoryTaskAdministration method cancelIndexTasks.

@Override
public List<RepositoryTaskInfo> cancelIndexTasks(String repositoryId) throws RepositoryAdminException {
    try {
        ArrayList<RepositoryTaskInfo> resultList = new ArrayList<>();
        List<ArtifactIndexingTask> removeTasks = indexingTaskExecutor.getQueue().getQueueSnapshot().stream().filter(task -> repositoryId.equals(task.getRepository().getId())).collect(Collectors.toList());
        indexingTaskExecutor.getQueue().removeAll(removeTasks);
        ArtifactIndexingTask currentTask = indexingTaskExecutor.getCurrentTask();
        if (currentTask != null && repositoryId.equals(currentTask.getRepository().getId())) {
            indexingTaskExecutor.cancelTask(currentTask);
            resultList.add(getIndexingTaskInfo(currentTask));
        }
        resultList.addAll(removeTasks.stream().map(task -> getIndexingTaskInfo(task)).collect(Collectors.toList()));
        return resultList;
    } catch (TaskQueueException e) {
        throw RepositoryAdminException.ofKey("repository.task.dequeue_failed", repositoryId);
    }
}
Also used : ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) TaskQueueExecutor(org.apache.archiva.components.taskqueue.execution.TaskQueueExecutor) Logger(org.slf4j.Logger) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RepositoryArchivaTaskScheduler(org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler) RepositoryTaskInfo(org.apache.archiva.admin.model.beans.RepositoryTaskInfo) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) RepositoryRegistry(org.apache.archiva.repository.RepositoryRegistry) LoggerFactory(org.slf4j.LoggerFactory) RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) IndexingTask(org.apache.archiva.admin.model.beans.IndexingTask) ScanStatus(org.apache.archiva.admin.model.beans.ScanStatus) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) RepositoryTaskAdministration(org.apache.archiva.admin.model.admin.RepositoryTaskAdministration) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException) List(java.util.List) MetadataScanTask(org.apache.archiva.admin.model.beans.MetadataScanTask) Service(org.springframework.stereotype.Service) Named(javax.inject.Named) RepositoryStatisticsManager(org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager) IndexingArchivaTaskScheduler(org.apache.archiva.scheduler.indexing.IndexingArchivaTaskScheduler) ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) RepositoryTaskInfo(org.apache.archiva.admin.model.beans.RepositoryTaskInfo) ArrayList(java.util.ArrayList) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Aggregations

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 ScanStatus (org.apache.archiva.admin.model.beans.ScanStatus)2 TaskQueueException (org.apache.archiva.components.taskqueue.TaskQueueException)2 TaskQueueExecutor (org.apache.archiva.components.taskqueue.execution.TaskQueueExecutor)2 RepositoryStatisticsManager (org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager)2 RepositoryRegistry (org.apache.archiva.repository.RepositoryRegistry)2 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)2 ArtifactIndexingTask (org.apache.archiva.scheduler.indexing.ArtifactIndexingTask)2 IndexingArchivaTaskScheduler (org.apache.archiva.scheduler.indexing.IndexingArchivaTaskScheduler)2 RepositoryArchivaTaskScheduler (org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler)2 RepositoryTask (org.apache.archiva.scheduler.repository.model.RepositoryTask)2 StringUtils (org.apache.commons.lang3.StringUtils)2