use of org.openarchives.oai._2.OAIPMHerrorType in project mod-oai-pmh by folio-org.
the class VerbValidatorTest method verifyContainsError.
private void verifyContainsError(List<OAIPMHerrorType> errors, OAIPMHerrorcodeType code, String errorMessage) {
String errorMessageFixed = errorMessage;
if (errorMessage.contains(METADATA_PREFIX_PARAM + "," + IDENTIFIER_PARAM)) {
errorMessageFixed = errorMessage.replace(METADATA_PREFIX_PARAM + "," + IDENTIFIER_PARAM, IDENTIFIER_PARAM + "," + METADATA_PREFIX_PARAM);
}
OAIPMHerrorType error = new OAIPMHerrorType().withCode(code).withValue(errorMessageFixed);
assertTrue(errors.contains(error));
}
use of org.openarchives.oai._2.OAIPMHerrorType in project mod-oai-pmh by folio-org.
the class ResponseHelperTest method buildOaipmhResponsesWithError.
private Map<OAIPMHerrorcodeType, OAIPMH> buildOaipmhResponsesWithError() {
OAIPMHerrorType badArgumentError = new OAIPMHerrorType().withCode(BAD_ARGUMENT).withValue(TEST_ERROR_MESSAGE);
OAIPMHerrorType notFoundError = new OAIPMHerrorType().withCode(ID_DOES_NOT_EXIST).withValue(TEST_ERROR_MESSAGE);
OAIPMHerrorType cannotDisseminateFormatError = new OAIPMHerrorType().withCode(CANNOT_DISSEMINATE_FORMAT).withValue(TEST_ERROR_MESSAGE);
Map<OAIPMHerrorcodeType, OAIPMH> responsesWithErrors = new HashMap<>();
responsesWithErrors.put(BAD_ARGUMENT, responseHelper.buildOaipmhResponseWithErrors(request, badArgumentError));
responsesWithErrors.put(ID_DOES_NOT_EXIST, responseHelper.buildOaipmhResponseWithErrors(request, notFoundError));
responsesWithErrors.put(CANNOT_DISSEMINATE_FORMAT, responseHelper.buildOaipmhResponseWithErrors(request, cannotDisseminateFormatError));
return responsesWithErrors;
}
use of org.openarchives.oai._2.OAIPMHerrorType in project mod-oai-pmh by folio-org.
the class VerbValidator method validateRequiredParams.
/**
* Verifies that any of the required parameters is not missing.
*
* @param requestParams - vertx context
* @param verb - request verb
* @param errors - errors list
*/
private void validateRequiredParams(Map<String, String> requestParams, Verb verb, List<OAIPMHerrorType> errors) {
Set<String> params = new HashSet<>();
if (verb.getExclusiveParam() != null && requestParams.get(verb.getExclusiveParam()) != null) {
params.add(verb.getExclusiveParam());
} else {
params.addAll(verb.getRequiredParams());
}
final String missingRequiredParams = params.stream().filter(p -> StringUtils.isEmpty(requestParams.get(p))).collect(Collectors.joining(","));
if (StringUtils.isNotEmpty(missingRequiredParams)) {
errors.add(new OAIPMHerrorType().withCode(BAD_ARGUMENT).withValue(format(MISSING_REQUIRED_PARAMETERS_ERROR_MESSAGE, missingRequiredParams)));
}
}
Aggregations