use of org.folio.circulation.domain.RequestLevel.TITLE in project mod-circulation by folio-org.
the class RequestFromRepresentationService method validateRequestLevel.
private Result<Request> validateRequestLevel(Request request) {
JsonObject representation = request.getRequestRepresentation();
String requestLevelRaw = representation.getString(REQUEST_LEVEL);
RequestLevel requestLevel = RequestLevel.from(requestLevelRaw);
boolean tlrEnabled = request.getTlrSettingsConfiguration().isTitleLevelRequestsFeatureEnabled();
List<RequestLevel> allowedStatuses = tlrEnabled ? List.of(ITEM, TITLE) : List.of(ITEM);
if (!allowedStatuses.contains(requestLevel)) {
String allowedStatusesJoined = allowedStatuses.stream().map(existingLevel -> StringUtils.wrap(existingLevel.getValue(), '"')).collect(Collectors.joining(", "));
return failedValidation("requestLevel must be one of the following: " + allowedStatusesJoined, "requestLevel", requestLevelRaw);
}
return succeeded(request);
}
Aggregations