Search in sources :

Example 1 with UnprocessableEntityException

use of org.folio.inventory.exceptions.UnprocessableEntityException in project mod-inventory by folio-org.

the class Holdings method refuseWhenBlockedFieldsChanged.

private CompletionStage<HoldingsRecord> refuseWhenBlockedFieldsChanged(HoldingsRecord existingHoldings, HoldingsRecord updatedHoldings) {
    if (isHoldingsControlledByRecord(existingHoldings) && areHoldingsBlockedFieldsChanged(existingHoldings, updatedHoldings)) {
        var errorMessage = BLOCKED_FIELDS_UPDATED_ERROR_MSG + StringUtils.join(config.getHoldingsBlockedFields(), COMMA);
        LOGGER.error(errorMessage);
        return failedFuture(new UnprocessableEntityException(errorMessage, null, null));
    }
    return completedFuture(existingHoldings);
}
Also used : UnprocessableEntityException(org.folio.inventory.exceptions.UnprocessableEntityException)

Example 2 with UnprocessableEntityException

use of org.folio.inventory.exceptions.UnprocessableEntityException in project mod-inventory by folio-org.

the class EndpointFailureHandler method handleFailure.

public static void handleFailure(Throwable failure, RoutingContext context) {
    final Throwable failureToHandle = getKnownException(failure);
    if (failureToHandle instanceof UnprocessableEntityException) {
        UnprocessableEntityException validationFailure = (UnprocessableEntityException) failureToHandle;
        unprocessableEntity(context.response(), validationFailure.getMessage(), validationFailure.getPropertyName(), validationFailure.getPropertyValue());
    } else if (failureToHandle instanceof NotFoundException) {
        ClientErrorResponse.notFound(context.response(), failureToHandle.getMessage());
    } else if (failureToHandle instanceof ExternalResourceFetchException) {
        final ExternalResourceFetchException externalException = (ExternalResourceFetchException) failureToHandle;
        forward(context.response(), externalException.getBody(), externalException.getStatusCode(), externalException.getContentType());
    } else {
        ServerErrorResponse.internalError(context.response(), failureToHandle);
    }
}
Also used : UnprocessableEntityException(org.folio.inventory.exceptions.UnprocessableEntityException) ExternalResourceFetchException(org.folio.inventory.exceptions.ExternalResourceFetchException) NotFoundException(org.folio.inventory.exceptions.NotFoundException)

Example 3 with UnprocessableEntityException

use of org.folio.inventory.exceptions.UnprocessableEntityException in project mod-inventory by folio-org.

the class Instances method refuseWhenBlockedFieldsChanged.

private CompletionStage<Instance> refuseWhenBlockedFieldsChanged(Instance existingInstance, Instance updatedInstance) {
    if (isInstanceControlledByRecord(existingInstance) && areInstanceBlockedFieldsChanged(existingInstance, updatedInstance)) {
        String errorMessage = BLOCKED_FIELDS_UPDATE_ERROR_MESSAGE + StringUtils.join(config.getInstanceBlockedFields(), COMMA);
        log.error(errorMessage);
        return failedFuture(new UnprocessableEntityException(errorMessage, null, null));
    }
    return completedFuture(existingInstance);
}
Also used : UnprocessableEntityException(org.folio.inventory.exceptions.UnprocessableEntityException)

Aggregations

UnprocessableEntityException (org.folio.inventory.exceptions.UnprocessableEntityException)3 ExternalResourceFetchException (org.folio.inventory.exceptions.ExternalResourceFetchException)1 NotFoundException (org.folio.inventory.exceptions.NotFoundException)1