use of org.openarchives.oai._2.IdentifyType in project mod-oai-pmh by folio-org.
the class GetOaiRepositoryInfoHelper method handle.
@Override
public Future<Response> handle(Request request, Context ctx) {
Promise<Response> promise = Promise.promise();
try {
OAIPMH oai = getResponseHelper().buildBaseOaipmhResponse(request).withIdentify(new IdentifyType().withRepositoryName(getRepositoryName(request.getRequestId())).withBaseURL(request.getOaiRequest().getValue()).withProtocolVersion(REPOSITORY_PROTOCOL_VERSION_2_0).withEarliestDatestamp(getEarliestDatestamp()).withGranularity(GranularityType.fromValue(RepositoryConfigurationUtil.getProperty(request.getRequestId(), REPOSITORY_TIME_GRANULARITY))).withDeletedRecord(DeletedRecordType.fromValue(RepositoryConfigurationUtil.getProperty(request.getRequestId(), REPOSITORY_DELETED_RECORDS))).withAdminEmails(getEmails(request.getRequestId())).withCompressions(GZIP, DEFLATE).withDescriptions(getDescriptions(request)));
promise.complete(getResponseHelper().buildSuccessResponse(oai));
} catch (Exception e) {
logger.error("Error happened while processing Identify verb request.", e);
promise.fail(e);
}
return promise.future();
}
use of org.openarchives.oai._2.IdentifyType in project openaire-cris-validator by EuroCRIS.
the class OAIPMHEndpoint method callIdentify.
/**
* Sends the Identify request and returns the result.
* @return the result of the Identify call
* @throws IOException on network error
* @throws SAXException on XML parsing error
* @throws JAXBException on XML processing error
*/
public IdentifyType callIdentify() throws IOException, SAXException, JAXBException {
final IdentifyType identifyResponse = makeConnection(true, "Identify").getIdentify();
supportedCompressions = Optional.of(identifyResponse.getCompression());
repositoryIdentifier = extractRepoIdentifier(identifyResponse);
return identifyResponse;
}
use of org.openarchives.oai._2.IdentifyType in project openaire-cris-validator by EuroCRIS.
the class FileLoggingConnectionStreamFactory method check000_Identify.
/**
* Ask for ?verb=Identity and test it for consistence – checks (1).
* @throws Exception on any unexpected circumstance
*/
@Test
public void check000_Identify() throws Exception {
final IdentifyType identify = endpoint.callIdentify();
CheckingIterable<DescriptionType> checker = CheckingIterable.over(identify.getDescription());
checker = checker.checkContainsOne(new Predicate<DescriptionType>() {
@Override
public boolean test(final DescriptionType description) {
final Object obj = description.getAny();
if (obj instanceof JAXBElement<?>) {
final JAXBElement<?> jaxbEl = (JAXBElement<?>) obj;
final Object obj1 = jaxbEl.getValue();
if (obj1 instanceof OaiIdentifierType) {
final OaiIdentifierType oaiIdentifier = (OaiIdentifierType) obj1;
sampleIdentifier = Optional.ofNullable(oaiIdentifier.getSampleIdentifier());
return true;
}
}
return false;
}
}, "the Identify descriptions list (1b)", "an 'oai-identifier' element");
checker = checker.checkContainsOne(new Predicate<DescriptionType>() {
@Override
public boolean test(final DescriptionType description) {
final Object obj = description.getAny();
if (obj instanceof Element) {
final Element el = (Element) obj;
if ("Service".equals(el.getLocalName()) && OPENAIRE_CERIF_XMLNS.equals(el.getNamespaceURI())) {
serviceAcronym = XmlUtils.getTextContents(XmlUtils.getFirstMatchingChild(el, "Acronym", el.getNamespaceURI()));
validateMetadataPayload(el);
return true;
}
}
return false;
}
}, "the Identify descriptions list (1a)", "a 'Service' element");
checker.run();
if (!endpoint.getBaseUrl().startsWith("file:")) {
assertEquals("Identify response has a different endpoint base URL (1d)", endpoint.getBaseUrl(), identify.getBaseURL());
}
final Optional<String> repoIdentifier = endpoint.getRepositoryIdentifer();
if (serviceAcronym.isPresent() && repoIdentifier.isPresent()) {
assertEquals("Service acronym is not the same as the repository identifier (1c)", serviceAcronym.get(), repoIdentifier.get());
}
}
use of org.openarchives.oai._2.IdentifyType in project openaire-cris-validator by EuroCRIS.
the class OAIPMHEndpoint method extractRepoIdentifier.
/**
* Extracts the OAI identifier's repository identifier value.
* @param identifyResponse the response to an Identify request
* @param the repository identifier if one is provided, an empty {@link Optional} otherwise.
*/
private Optional<String> extractRepoIdentifier(final IdentifyType identifyResponse) {
for (final DescriptionType description : identifyResponse.getDescription()) {
final Object obj = description.getAny();
if (obj instanceof JAXBElement<?>) {
final JAXBElement<?> jaxbEl = (JAXBElement<?>) obj;
final Object obj1 = jaxbEl.getValue();
if (obj1 instanceof OaiIdentifierType) {
final OaiIdentifierType oaiIdentifier = (OaiIdentifierType) obj1;
return Optional.ofNullable(oaiIdentifier.getRepositoryIdentifier());
}
}
}
return Optional.empty();
}
Aggregations