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