Search in sources :

Example 1 with ProcessInProgressException

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));
    });
}
Also used : ProcessInProgressException(org.folio.service.holdings.exception.ProcessInProgressException) LoadStatusAttributes(org.folio.rest.jaxrs.model.LoadStatusAttributes)

Aggregations

LoadStatusAttributes (org.folio.rest.jaxrs.model.LoadStatusAttributes)1 ProcessInProgressException (org.folio.service.holdings.exception.ProcessInProgressException)1