use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.
the class DefaultRepositoriesService method removeScanningTaskFromQueue.
@Override
public ActionStatus removeScanningTaskFromQueue(String repositoryId) {
RepositoryTask task = new RepositoryTask();
task.setRepositoryId(repositoryId);
try {
return new ActionStatus(repositoryTaskScheduler.unQueueTask(task));
} catch (TaskQueueException e) {
log.error("failed to unschedule scanning of repo with id {}", repositoryId, e);
return ActionStatus.FAIL;
}
}
use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.
the class DefaultManagedRepositoryAdmin method scanRepository.
public Boolean scanRepository(String repositoryId, boolean fullScan) {
if (getRepositoryTaskScheduler().isProcessingRepositoryTask(repositoryId)) {
log.info("scanning of repository with id {} already scheduled", repositoryId);
}
RepositoryTask task = new RepositoryTask();
task.setRepositoryId(repositoryId);
task.setScanAll(fullScan);
try {
getRepositoryTaskScheduler().queueTask(task);
} catch (TaskQueueException e) {
log.error("failed to schedule scanning of repo with id {}", repositoryId, e);
return false;
}
return true;
}
use of org.apache.archiva.components.taskqueue.TaskQueueException 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.components.taskqueue.TaskQueueException in project archiva by apache.
the class DefaultRepositoryTaskAdministration method scheduleIndexFullScan.
@Override
public void scheduleIndexFullScan(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);
} catch (TaskQueueException e) {
log.error("Could not queue the task: {}", e.getMessage(), e);
throw RepositoryAdminException.ofKey("repository.scan.task_queue_error", e, e.getMessage());
}
}
use of org.apache.archiva.components.taskqueue.TaskQueueException 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