use of org.openarchives.oai._2.OAIPMHerrorcodeType.BAD_VERB in project mod-oai-pmh by folio-org.
the class VerbValidator method validate.
/**
* Validates request parameters except 'from' and 'until' against particular verb.
*
* @param object - name of verb against witch parameters are validated
* @param requestParams - map with request parameters
* @return list of errors.
*/
public List<OAIPMHerrorType> validate(Object object, Map<String, String> requestParams, Request request) {
List<OAIPMHerrorType> errors = new ArrayList<>();
String verbName = Objects.nonNull(object) ? object.toString() : "empty";
Verb verb = Verb.fromName(verbName);
if (Objects.nonNull(verb)) {
validateRequiredParams(requestParams, verb, errors);
validateExclusiveParam(verb, requestParams, request, errors);
validateIllegalParams(verb, requestParams, errors);
} else {
errors.add(new OAIPMHerrorType().withCode(BAD_VERB).withValue(format(VERB_NOT_IMPLEMENTED_ERROR_MESSAGE, verbName)));
}
return errors;
}
use of org.openarchives.oai._2.OAIPMHerrorcodeType.BAD_VERB in project mod-oai-pmh by folio-org.
the class ResponseHelperTest method shouldBuildOaipmhResponseWithErrorCodeAndValue.
@Test
void shouldBuildOaipmhResponseWithErrorCodeAndValue() {
OAIPMH oaipmh = responseHelper.buildOaipmhResponseWithErrors(request, BAD_VERB, TEST_ERROR_MESSAGE);
boolean isErrorPresented = oaipmh.getErrors().stream().anyMatch(error -> error.getCode().equals(BAD_VERB) && error.getValue().equals(TEST_ERROR_MESSAGE));
assertTrue(isErrorPresented);
assertNotNull(oaipmh.getResponseDate());
assertEquals(oaipmh.getRequest(), request.getOaiRequest());
}
Aggregations