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);
}
}
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);
}
}
Aggregations