use of org.folio.oaipmh.Constants.VERB_PARAM in project mod-oai-pmh by folio-org.
the class VerbValidator method validateExclusiveParam.
/**
* In case of resumption token param presence verifies if there any other parameters were specified too. If they were then error
* will be added to error list.
*
* @param verb - verb
* @param requestParams - request parameters
* @param request - oai-pmh request
* @param errors - list of errors
*/
private void validateExclusiveParam(Verb verb, Map<String, String> requestParams, Request request, List<OAIPMHerrorType> errors) {
String resumptionToken = requestParams.get(verb.getExclusiveParam());
if (verb.getExclusiveParam() != null && resumptionToken != null) {
requestParams.keySet().stream().filter(p -> !verb.getExcludedParams().contains(p)).filter(p -> !verb.getExclusiveParam().equals(p)).findAny().ifPresent(param -> {
if (!param.equals(VERB_PARAM)) {
errors.add(new OAIPMHerrorType().withCode(BAD_ARGUMENT).withValue(format(EXCLUSIVE_PARAM_ERROR_MESSAGE, verb.name(), verb.getExclusiveParam())));
}
});
if (!request.isResumptionTokenParsableAndValid()) {
OAIPMHerrorType error = new OAIPMHerrorType().withCode(BAD_RESUMPTION_TOKEN).withValue(format(INVALID_RESUMPTION_TOKEN, verb.name()));
errors.add(error);
return;
}
if (request.isResumptionTokenTimeExpired()) {
OAIPMHerrorType errorByExpiredTime = new OAIPMHerrorType().withCode(BAD_RESUMPTION_TOKEN).withValue(EXPIRED_RESUMPTION_TOKEN);
errors.add(errorByExpiredTime);
}
}
}
Aggregations