use of org.folio.service.holdings.exception.ProcessInProgressException in project mod-kb-ebsco-java by folio-org.
the class HoldingsServiceImpl method tryChangingStatusToInProgress.
private CompletableFuture<Void> tryChangingStatusToInProgress(HoldingsLoadingStatus newStatus, UUID credentialsId, String tenantId) {
return holdingsStatusRepository.findByCredentialsId(credentialsId, tenantId).thenCompose(status -> {
LoadStatusAttributes attributes = status.getData().getAttributes();
logger.info(CURRENT_STATUS_MESSAGE, credentialsId, attributes.getStatus().getName());
if (!isInProgress(status) || processTimedOut(status)) {
return holdingsStatusRepository.delete(credentialsId, tenantId).thenCompose(o -> holdingsStatusRepository.save(newStatus, credentialsId, tenantId));
}
return failedFuture(new ProcessInProgressException(LOADING_STATUS_IN_PROGRESS_MESSAGE));
});
}
Aggregations