use of org.openarchives.oai._2.OAIPMHerrorType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithNoRecordsFoundFromStorage.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithNoRecordsFoundFromStorage(VerbType verb) {
String metadataPrefix = MetadataPrefix.DC.getName();
String from = NO_RECORDS_DATE;
String set = "all";
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(FROM_PARAM, from).param(SET_PARAM, set).param(METADATA_PREFIX_PARAM, metadataPrefix);
// Unmarshal string to OAIPMH and verify required data presents
OAIPMH oaipmh = verifyResponseWithErrors(request, verb, 404, 1);
// The dates are of invalid format so they are not present in request
assertThat(oaipmh.getRequest().getMetadataPrefix(), equalTo(metadataPrefix));
assertThat(oaipmh.getRequest().getFrom(), equalTo(from));
assertThat(oaipmh.getRequest().getSet(), equalTo(set));
OAIPMHerrorType error = oaipmh.getErrors().get(0);
assertThat(error.getCode(), equalTo(NO_RECORDS_MATCH));
assertThat(error.getValue(), equalTo(NO_RECORD_FOUND_ERROR));
}
use of org.openarchives.oai._2.OAIPMHerrorType in project openaire-cris-validator by EuroCRIS.
the class OAIPMHEndpoint method checkForErrors.
private void checkForErrors(final OAIPMHtype response) {
final StringBuilder sb = new StringBuilder();
for (final OAIPMHerrorType error : response.getError()) {
if (!OAIPMHerrorcodeType.NO_RECORDS_MATCH.equals(error.getCode())) {
sb.append(error.getCode().name());
sb.append(": ");
sb.append(error.getValue());
sb.append("; ");
}
}
if (sb.length() > 0) {
final String errors = sb.substring(0, sb.length() - 2);
throw new IllegalStateException(errors);
}
}
use of org.openarchives.oai._2.OAIPMHerrorType in project mod-oai-pmh by folio-org.
the class AbstractHelper method buildResponseWithErrors.
protected Future<Response> buildResponseWithErrors(Request request, Promise<Response> promise, List<OAIPMHerrorType> errors) {
OAIPMH oai;
if (request.isRestored()) {
oai = responseHelper.buildOaipmhResponseWithErrors(request, BAD_RESUMPTION_TOKEN, RESUMPTION_TOKEN_FORMAT_ERROR);
} else {
oai = responseHelper.buildOaipmhResponseWithErrors(request, errors);
}
promise.complete(responseHelper.buildFailureResponse(oai, request));
return promise.future();
}
use of org.openarchives.oai._2.OAIPMHerrorType in project mod-oai-pmh by folio-org.
the class GetOaiIdentifiersHelper method handle.
@Override
public Future<javax.ws.rs.core.Response> handle(Request request, Context ctx) {
Promise<javax.ws.rs.core.Response> promise = Promise.promise();
try {
ResponseHelper responseHelper = getResponseHelper();
List<OAIPMHerrorType> errors = validateRequest(request);
if (!errors.isEmpty()) {
OAIPMH oai;
if (request.isRestored()) {
oai = responseHelper.buildOaipmhResponseWithErrors(request, BAD_RESUMPTION_TOKEN, RESUMPTION_TOKEN_FORMAT_ERROR);
} else {
oai = responseHelper.buildOaipmhResponseWithErrors(request, errors);
}
promise.complete(getResponseHelper().buildFailureResponse(oai, request));
return promise.future();
}
requestAndProcessSrsRecords(request, ctx, promise);
} catch (Exception e) {
handleException(promise, e);
}
return promise.future();
}
use of org.openarchives.oai._2.OAIPMHerrorType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiRecordsWithMetadataPrefixMarc21WithHoldingsAndSrsHasNoRecordsForInventoryInstance.
@Test
void getOaiRecordsWithMetadataPrefixMarc21WithHoldingsAndSrsHasNoRecordsForInventoryInstance() {
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_RECORDS.value()).param(FROM_PARAM, INSTANCE_WITHOUT_SRS_RECORD_DATE).param(METADATA_PREFIX_PARAM, MetadataPrefix.MARC21WITHHOLDINGS.getName());
OAIPMH oaipmh = verifyResponseWithErrors(request, LIST_RECORDS, 404, 1);
OAIPMHerrorType error = oaipmh.getErrors().get(0);
assertEquals(NO_RECORD_FOUND_ERROR, error.getValue());
}
Aggregations