Search in sources :

Example 11 with RecordType

use of net.opengis.cat.csw._3.RecordType in project osate2 by osate.

the class AadlBaNameResolver method getBasicPropertyResolver.

private BasicProperty getBasicPropertyResolver(BehaviorVariable bv, Property p, String basicPropertyName) {
    QualifiedNamedElement qne = (QualifiedNamedElement) p;
    Property propNE = resolveProperty(qne);
    PropertyType pt = propNE.getPropertyType();
    if (pt instanceof RecordType) {
        RecordType rt = (RecordType) pt;
        for (BasicProperty bp : rt.getOwnedFields()) {
            if (bp.getName().equalsIgnoreCase(basicPropertyName)) {
                return bp;
            }
        }
    }
    return null;
}
Also used : BasicProperty(org.osate.aadl2.BasicProperty) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) RecordType(org.osate.aadl2.RecordType) PropertyType(org.osate.aadl2.PropertyType) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property)

Example 12 with RecordType

use of net.opengis.cat.csw._3.RecordType in project ddf by codice.

the class TestCswSourceBase method generateCswCollection.

protected CswRecordCollection generateCswCollection(String file) {
    InputStream stream = getClass().getResourceAsStream(file);
    GetRecordsResponseType recordsResponse = parseXml(stream);
    GetRecordsResponseType records = new GetRecordsResponseType();
    recordsResponse.copyTo(records);
    List<Metacard> cswRecords = new LinkedList<>();
    for (JAXBElement<? extends AbstractRecordType> rec : records.getSearchResults().getAbstractRecord()) {
        MetacardImpl metacard = new MetacardImpl();
        cswRecords.add(metacard);
        if (rec.getValue() instanceof BriefRecordType) {
            BriefRecordType record = (BriefRecordType) rec.getValue();
            metacard.setId(record.getIdentifier().get(0).getValue().getContent().get(0));
            if (!CollectionUtils.isEmpty(record.getType().getContent())) {
                metacard.setContentTypeName(record.getType().getContent().get(0));
            }
        } else if (rec.getValue() instanceof SummaryRecordType) {
            SummaryRecordType record = (SummaryRecordType) rec.getValue();
            metacard.setId(record.getIdentifier().get(0).getValue().getContent().get(0));
            if (!CollectionUtils.isEmpty(record.getType().getContent())) {
                metacard.setContentTypeName(record.getType().getContent().get(0));
            }
        } else if (rec.getValue() instanceof RecordType) {
            RecordType record = (RecordType) rec.getValue();
            for (JAXBElement<SimpleLiteral> jb : record.getDCElement()) {
                if ("identifier".equals(jb.getName().getLocalPart())) {
                    metacard.setId(jb.getValue().getContent().get(0));
                }
                if ("type".equals(jb.getName().getLocalPart()) && !CollectionUtils.isEmpty(jb.getValue().getContent())) {
                    metacard.setContentTypeName(jb.getValue().getContent().get(0));
                }
            }
        }
    }
    CswRecordCollection collection = new CswRecordCollection();
    collection.setCswRecords(cswRecords);
    collection.setNumberOfRecordsMatched(records.getSearchResults().getNumberOfRecordsMatched().intValue());
    collection.setNumberOfRecordsReturned(records.getSearchResults().getNumberOfRecordsReturned().intValue());
    return collection;
}
Also used : SummaryRecordType(net.opengis.cat.csw.v_2_0_2.SummaryRecordType) InputStream(java.io.InputStream) BriefRecordType(net.opengis.cat.csw.v_2_0_2.BriefRecordType) LinkedList(java.util.LinkedList) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Metacard(ddf.catalog.data.Metacard) AbstractRecordType(net.opengis.cat.csw.v_2_0_2.AbstractRecordType) RecordType(net.opengis.cat.csw.v_2_0_2.RecordType) SummaryRecordType(net.opengis.cat.csw.v_2_0_2.SummaryRecordType) BriefRecordType(net.opengis.cat.csw.v_2_0_2.BriefRecordType) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) GetRecordsResponseType(net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType) SimpleLiteral(net.opengis.cat.csw.v_2_0_2.dc.elements.SimpleLiteral)

Example 13 with RecordType

use of net.opengis.cat.csw._3.RecordType in project mod-oai-pmh by folio-org.

the class OaiPmhImplTest method verifyHeaderDateStamp.

private void verifyHeaderDateStamp(OAIPMH oaipmh, VerbType verbType, String timeGranularity) {
    String verb = verbType.value();
    if (verb.equals(LIST_RECORDS.value())) {
        oaipmh.getListRecords().getRecords().stream().map(RecordType::getHeader).map(HeaderType::getDatestamp).forEach(headerDateStamp -> verifyHeaderDateStamp(headerDateStamp, timeGranularity));
    } else if (verb.equals(LIST_IDENTIFIERS.value())) {
        oaipmh.getListIdentifiers().getHeaders().stream().map(HeaderType::getDatestamp).forEach(headerDateStamp -> verifyHeaderDateStamp(headerDateStamp, timeGranularity));
    } else if (verb.equals(GET_RECORD.value())) {
        String datestamp = oaipmh.getGetRecord().getRecord().getHeader().getDatestamp();
        verifyHeaderDateStamp(datestamp, timeGranularity);
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) DATE_SRS_500_ERROR_RESPONSE(org.folio.rest.impl.OkapiMockServer.DATE_SRS_500_ERROR_RESPONSE) Header(io.restassured.http.Header) Autowired(org.springframework.beans.factory.annotation.Autowired) GranularityType(org.openarchives.oai._2.GranularityType) SRS_RECORD_WITH_NEW_METADATA_DATE(org.folio.rest.impl.OkapiMockServer.SRS_RECORD_WITH_NEW_METADATA_DATE) METADATA_PREFIX_PARAM(org.folio.oaipmh.Constants.METADATA_PREFIX_PARAM) AfterAll(org.junit.jupiter.api.AfterAll) OAI_TEST_TENANT(org.folio.rest.impl.OkapiMockServer.OAI_TEST_TENANT) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) OAIPMHerrorType(org.openarchives.oai._2.OAIPMHerrorType) ResumptionTokenType(org.openarchives.oai._2.ResumptionTokenType) GZIP(org.folio.oaipmh.Constants.GZIP) RESUMPTION_TOKEN_PARAM(org.folio.oaipmh.Constants.RESUMPTION_TOKEN_PARAM) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) SRS_RECORD_WITH_INVALID_JSON_STRUCTURE(org.folio.rest.impl.OkapiMockServer.SRS_RECORD_WITH_INVALID_JSON_STRUCTURE) CANNOT_DISSEMINATE_FORMAT(org.openarchives.oai._2.OAIPMHerrorcodeType.CANNOT_DISSEMINATE_FORMAT) JsonObject(io.vertx.core.json.JsonObject) VerbType(org.openarchives.oai._2.VerbType) BigInteger(java.math.BigInteger) IDENTIFIER_PARAM(org.folio.oaipmh.Constants.IDENTIFIER_PARAM) ZoneOffset(java.time.ZoneOffset) UNTIL_PARAM(org.folio.oaipmh.Constants.UNTIL_PARAM) LIST_SETS(org.openarchives.oai._2.VerbType.LIST_SETS) DEFAULT_RECORD_DATE(org.folio.rest.impl.OkapiMockServer.DEFAULT_RECORD_DATE) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SRS_RECORD_WITH_OLD_METADATA_DATE(org.folio.rest.impl.OkapiMockServer.SRS_RECORD_WITH_OLD_METADATA_DATE) InstancesService(org.folio.oaipmh.service.InstancesService) Arguments(org.junit.jupiter.params.provider.Arguments) PostgresClient(org.folio.rest.persist.PostgresClient) StandardCharsets(java.nio.charset.StandardCharsets) GET_ENRICHED_INSTANCES_500_ERROR_RETURNED_FROM_STORAGE_DATE(org.folio.rest.impl.OkapiMockServer.GET_ENRICHED_INSTANCES_500_ERROR_RETURNED_FROM_STORAGE_DATE) INVENTORY_27_INSTANCES_IDS_DATE(org.folio.rest.impl.OkapiMockServer.INVENTORY_27_INSTANCES_IDS_DATE) Logger(org.apache.logging.log4j.Logger) Stream(java.util.stream.Stream) URLEncodedUtils(org.apache.http.client.utils.URLEncodedUtils) OAIPMHerrorcodeType(org.openarchives.oai._2.OAIPMHerrorcodeType) DATE_FOR_INSTANCES_10_PARTIALLY(org.folio.rest.impl.OkapiMockServer.DATE_FOR_INSTANCES_10_PARTIALLY) RestAssured.given(io.restassured.RestAssured.given) RestAssured(io.restassured.RestAssured) REPOSITORY_DELETED_RECORDS(org.folio.oaipmh.Constants.REPOSITORY_DELETED_RECORDS) REPOSITORY_TIME_GRANULARITY(org.folio.oaipmh.Constants.REPOSITORY_TIME_GRANULARITY) ISO_UTC_DATE_TIME(org.folio.oaipmh.Constants.ISO_UTC_DATE_TIME) VertxTestContext(io.vertx.junit5.VertxTestContext) DEFLATE(org.folio.oaipmh.Constants.DEFLATE) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) PostgresTesterContainer(org.folio.postgres.testing.PostgresTesterContainer) LocalDateTime(java.time.LocalDateTime) DATE_INVENTORY_10_INSTANCE_IDS(org.folio.rest.impl.OkapiMockServer.DATE_INVENTORY_10_INSTANCE_IDS) LIST_ILLEGAL_ARGUMENTS_ERROR(org.folio.oaipmh.Constants.LIST_ILLEGAL_ARGUMENTS_ERROR) DecoderConfig(io.restassured.config.DecoderConfig) DATE_FOR_INSTANCES_10(org.folio.rest.impl.OkapiMockServer.DATE_FOR_INSTANCES_10) THREE_INSTANCES_DATE(org.folio.rest.impl.OkapiMockServer.THREE_INSTANCES_DATE) LIST_METADATA_FORMATS(org.openarchives.oai._2.VerbType.LIST_METADATA_FORMATS) REPOSITORY_STORAGE(org.folio.oaipmh.Constants.REPOSITORY_STORAGE) Matchers.hasSize(org.hamcrest.Matchers.hasSize) NO_RECORD_FOUND_ERROR(org.folio.oaipmh.Constants.NO_RECORD_FOUND_ERROR) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) RestAssuredConfig(io.restassured.config.RestAssuredConfig) ResponseConverter(org.folio.oaipmh.ResponseConverter) ValueSource(org.junit.jupiter.params.provider.ValueSource) REPOSITORY_ENABLE_OAI_SERVICE(org.folio.oaipmh.Constants.REPOSITORY_ENABLE_OAI_SERVICE) ID_DOES_NOT_EXIST(org.openarchives.oai._2.OAIPMHerrorcodeType.ID_DOES_NOT_EXIST) Dc(org.openarchives.oai._2_0.oai_dc.Dc) DataFieldType(gov.loc.marc21.slim.DataFieldType) NO_ITEMS_DATE(org.folio.rest.impl.OkapiMockServer.NO_ITEMS_DATE) JAXBElement(javax.xml.bind.JAXBElement) Vertx(io.vertx.core.Vertx) REPOSITORY_NAME(org.folio.oaipmh.Constants.REPOSITORY_NAME) VERB_PARAM(org.folio.oaipmh.Constants.VERB_PARAM) PARTITIONABLE_RECORDS_DATE_TIME(org.folio.rest.impl.OkapiMockServer.PARTITIONABLE_RECORDS_DATE_TIME) Assert.assertTrue(org.junit.Assert.assertTrue) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) REPOSITORY_SRS_CLIENT_IDLE_TIMEOUT_SEC(org.folio.oaipmh.Constants.REPOSITORY_SRS_CLIENT_IDLE_TIMEOUT_SEC) BAD_ARGUMENT(org.openarchives.oai._2.OAIPMHerrorcodeType.BAD_ARGUMENT) MetadataPrefix(org.folio.oaipmh.MetadataPrefix) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) RecordType(org.openarchives.oai._2.RecordType) REPOSITORY_SRS_HTTP_REQUEST_RETRY_ATTEMPTS(org.folio.oaipmh.Constants.REPOSITORY_SRS_HTTP_REQUEST_RETRY_ATTEMPTS) NO_RECORDS_DATE(org.folio.rest.impl.OkapiMockServer.NO_RECORDS_DATE) REPOSITORY_SUPPRESSED_RECORDS_PROCESSING(org.folio.oaipmh.Constants.REPOSITORY_SUPPRESSED_RECORDS_PROCESSING) UNKNOWN(org.openarchives.oai._2.VerbType.UNKNOWN) Assert.assertEquals(org.junit.Assert.assertEquals) NotThreadSafe(javax.annotation.concurrent.NotThreadSafe) CoreMatchers.is(org.hamcrest.CoreMatchers.is) ValidatableResponse(io.restassured.response.ValidatableResponse) FROM_PARAM(org.folio.oaipmh.Constants.FROM_PARAM) OFFSET_PARAM(org.folio.oaipmh.Constants.OFFSET_PARAM) HeaderType(org.openarchives.oai._2.HeaderType) Constants(org.folio.oaipmh.Constants) HttpStatus(org.apache.http.HttpStatus) StatusType(org.openarchives.oai._2.StatusType) NEXT_RECORD_ID_PARAM(org.folio.oaipmh.Constants.NEXT_RECORD_ID_PARAM) Context(io.vertx.core.Context) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) REPOSITORY_ADMIN_EMAILS(org.folio.oaipmh.Constants.REPOSITORY_ADMIN_EMAILS) TestInstance(org.junit.jupiter.api.TestInstance) ContentDecoder(io.restassured.config.DecoderConfig.ContentDecoder) Collectors.toMap(java.util.stream.Collectors.toMap) OAIPMH(org.openarchives.oai._2.OAIPMH) TOTAL_RECORDS_PARAM(org.folio.oaipmh.Constants.TOTAL_RECORDS_PARAM) IDENTIFY(org.openarchives.oai._2.VerbType.IDENTIFY) RequestSpecification(io.restassured.specification.RequestSpecification) Spy(org.mockito.Spy) DATE_SRS_ERROR_RESPONSE(org.folio.rest.impl.OkapiMockServer.DATE_SRS_ERROR_RESPONSE) BAD_RESUMPTION_TOKEN(org.openarchives.oai._2.OAIPMHerrorcodeType.BAD_RESUMPTION_TOKEN) TestUtil(org.folio.oaipmh.common.TestUtil) ModuleName(org.folio.rest.tools.utils.ModuleName) REPOSITORY_BASE_URL(org.folio.oaipmh.Constants.REPOSITORY_BASE_URL) INVENTORY_60_INSTANCE_IDS_DATE(org.folio.rest.impl.OkapiMockServer.INVENTORY_60_INSTANCE_IDS_DATE) Assert.fail(org.junit.Assert.fail) DATE_SRS_IDLE_TIMEOUT_ERROR_RESPONSE(org.folio.rest.impl.OkapiMockServer.DATE_SRS_IDLE_TIMEOUT_ERROR_RESPONSE) MethodSource(org.junit.jupiter.params.provider.MethodSource) Predicate(java.util.function.Predicate) LIST_RECORDS(org.openarchives.oai._2.VerbType.LIST_RECORDS) DATE_INVENTORY_STORAGE_ERROR_RESPONSE(org.folio.rest.impl.OkapiMockServer.DATE_INVENTORY_STORAGE_ERROR_RESPONSE) ContentType(io.restassured.http.ContentType) VertxOptions(io.vertx.core.VertxOptions) HttpHeaders(io.vertx.core.http.HttpHeaders) VertxExtension(io.vertx.junit5.VertxExtension) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) REQUEST_ID_PARAM(org.folio.oaipmh.Constants.REQUEST_ID_PARAM) Test(org.junit.jupiter.api.Test) Objects(java.util.Objects) SubfieldatafieldType(gov.loc.marc21.slim.SubfieldatafieldType) Base64(java.util.Base64) List(java.util.List) NO_RECORDS_MATCH(org.openarchives.oai._2.OAIPMHerrorcodeType.NO_RECORDS_MATCH) CollectionUtils.isNotEmpty(org.apache.commons.collections4.CollectionUtils.isNotEmpty) WebClientProvider(org.folio.oaipmh.WebClientProvider) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) OaiIdentifier(org.openarchives.oai._2_0.oai_identifier.OaiIdentifier) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) NameValuePair(org.apache.http.NameValuePair) INSTANCE_ID_WITH_INVALID_ENRICHED_INSTANCE_JSON_DATE(org.folio.rest.impl.OkapiMockServer.INSTANCE_ID_WITH_INVALID_ENRICHED_INSTANCE_JSON_DATE) LIST_NO_REQUIRED_PARAM_ERROR(org.folio.oaipmh.Constants.LIST_NO_REQUIRED_PARAM_ERROR) Json(io.vertx.core.json.Json) RestVerticle(org.folio.rest.RestVerticle) INSTANCE_WITHOUT_SRS_RECORD_DATE(org.folio.rest.impl.OkapiMockServer.INSTANCE_WITHOUT_SRS_RECORD_DATE) THREE_INSTANCES_DATE_WITH_ONE_MARK_DELETED_RECORD(org.folio.rest.impl.OkapiMockServer.THREE_INSTANCES_DATE_WITH_ONE_MARK_DELETED_RECORD) SOURCE_RECORD_STORAGE(org.folio.oaipmh.Constants.SOURCE_RECORD_STORAGE) EnumSource(org.junit.jupiter.params.provider.EnumSource) REPOSITORY_MAX_RECORDS_PER_RESPONSE(org.folio.oaipmh.Constants.REPOSITORY_MAX_RECORDS_PER_RESPONSE) SpringContextUtil(org.folio.spring.SpringContextUtil) SET_PARAM(org.folio.oaipmh.Constants.SET_PARAM) THREE_INSTANCES_DATE_TIME(org.folio.rest.impl.OkapiMockServer.THREE_INSTANCES_DATE_TIME) LIST_IDENTIFIERS(org.openarchives.oai._2.VerbType.LIST_IDENTIFIERS) PostgresClientFactory(org.folio.oaipmh.dao.PostgresClientFactory) SRS_RECORDS_WITH_CYRILLIC_DATA_DATE(org.folio.rest.impl.OkapiMockServer.SRS_RECORDS_WITH_CYRILLIC_DATA_DATE) TWO_RECORDS_WITH_ONE_INCONVERTIBLE_TO_XML(org.folio.rest.impl.OkapiMockServer.TWO_RECORDS_WITH_ONE_INCONVERTIBLE_TO_XML) ElementType(org.purl.dc.elements._1.ElementType) GET_INSTANCES_FORBIDDEN_RESPONSE_DATE(org.folio.rest.impl.OkapiMockServer.GET_INSTANCES_FORBIDDEN_RESPONSE_DATE) GET_INSTANCES_IDS_500_ERROR_RETURNED_FROM_STORAGE_DATE(org.folio.rest.impl.OkapiMockServer.GET_INSTANCES_IDS_500_ERROR_RETURNED_FROM_STORAGE_DATE) Matchers.empty(org.hamcrest.Matchers.empty) GET_RECORD(org.openarchives.oai._2.VerbType.GET_RECORD) UTF_8(java.nio.charset.StandardCharsets.UTF_8) PER_CLASS(org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS) PARTITIONABLE_RECORDS_DATE(org.folio.rest.impl.OkapiMockServer.PARTITIONABLE_RECORDS_DATE) NetworkUtils(org.folio.rest.tools.utils.NetworkUtils) INVALID_IDENTIFIER(org.folio.rest.impl.OkapiMockServer.INVALID_IDENTIFIER) EMPTY_INSTANCES_IDS_DATE(org.folio.rest.impl.OkapiMockServer.EMPTY_INSTANCES_IDS_DATE) ENRICH_INSTANCES_FORBIDDEN_RESPONSE_DATE(org.folio.rest.impl.OkapiMockServer.ENRICH_INSTANCES_FORBIDDEN_RESPONSE_DATE) DeploymentOptions(io.vertx.core.DeploymentOptions) DATE_ERROR_FROM_ENRICHED_INSTANCES_VIEW(org.folio.rest.impl.OkapiMockServer.DATE_ERROR_FROM_ENRICHED_INSTANCES_VIEW) ApplicationConfig(org.folio.config.ApplicationConfig) INVALID_INSTANCE_IDS_JSON_DATE(org.folio.rest.impl.OkapiMockServer.INVALID_INSTANCE_IDS_JSON_DATE) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) RecordType(org.openarchives.oai._2.RecordType) HeaderType(org.openarchives.oai._2.HeaderType) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString)

Example 14 with RecordType

use of net.opengis.cat.csw._3.RecordType in project mod-oai-pmh by folio-org.

the class MarcWithHoldingsRequestHelper method buildRecordsResponse.

private Future<Response> buildRecordsResponse(Request request, String requestId, List<JsonObject> batch, Map<String, JsonObject> srsResponse, boolean firstBatch, String nextInstanceId, boolean deletedRecordSupport) {
    Promise<Response> promise = Promise.promise();
    try {
        List<RecordType> records = buildRecordsList(request, batch, srsResponse, deletedRecordSupport);
        logger.debug("Build records response, instances = {}, instances with srs records = {}.", batch.size(), records.size());
        ResponseHelper responseHelper = getResponseHelper();
        OAIPMH oaipmh = responseHelper.buildBaseOaipmhResponse(request);
        if (records.isEmpty() && nextInstanceId == null && firstBatch) {
            oaipmh.withErrors(createNoRecordsFoundError());
        } else {
            oaipmh.withListRecords(new ListRecordsType().withRecords(records));
        }
        Response response;
        if (oaipmh.getErrors().isEmpty()) {
            if (!firstBatch || nextInstanceId != null) {
                ResumptionTokenType resumptionToken = buildResumptionTokenFromRequest(request, requestId, records.size(), nextInstanceId);
                oaipmh.getListRecords().withResumptionToken(resumptionToken);
            }
            response = responseHelper.buildSuccessResponse(oaipmh);
        } else {
            response = responseHelper.buildFailureResponse(oaipmh, request);
        }
        promise.complete(response);
    } catch (Exception e) {
        handleException(promise, e);
    }
    return promise.future();
}
Also used : Response(javax.ws.rs.core.Response) HttpResponse(io.vertx.ext.web.client.HttpResponse) OAIPMH(org.openarchives.oai._2.OAIPMH) ResumptionTokenType(org.openarchives.oai._2.ResumptionTokenType) RecordType(org.openarchives.oai._2.RecordType) ResponseHelper(org.folio.oaipmh.helpers.response.ResponseHelper) DecodeException(io.vertx.core.json.DecodeException) ListRecordsType(org.openarchives.oai._2.ListRecordsType)

Example 15 with RecordType

use of net.opengis.cat.csw._3.RecordType in project mod-oai-pmh by folio-org.

the class MarcWithHoldingsRequestHelper method buildRecordsList.

private List<RecordType> buildRecordsList(Request request, List<JsonObject> batch, Map<String, JsonObject> srsResponse, boolean deletedRecordSupport) {
    RecordMetadataManager metadataManager = RecordMetadataManager.getInstance();
    final boolean suppressedRecordsProcessing = getBooleanProperty(request.getRequestId(), REPOSITORY_SUPPRESSED_RECORDS_PROCESSING);
    List<RecordType> records = new ArrayList<>();
    batch.stream().filter(instance -> {
        final String instanceId = instance.getString(INSTANCE_ID_FIELD_NAME);
        final JsonObject srsInstance = srsResponse.get(instanceId);
        return Objects.nonNull(srsInstance);
    }).forEach(instance -> {
        final String instanceId = instance.getString(INSTANCE_ID_FIELD_NAME);
        final JsonObject srsInstance = srsResponse.get(instanceId);
        RecordType record = createRecord(request, srsInstance, instanceId);
        JsonObject updatedSrsWithItemsData = metadataManager.populateMetadataWithItemsData(srsInstance, instance, suppressedRecordsProcessing);
        JsonObject updatedSrsInstance = metadataManager.populateMetadataWithHoldingsData(updatedSrsWithItemsData, instance, suppressedRecordsProcessing);
        if (deletedRecordSupport && storageHelper.isRecordMarkAsDeleted(updatedSrsInstance)) {
            record.getHeader().setStatus(StatusType.DELETED);
        }
        String source = storageHelper.getInstanceRecordSource(updatedSrsInstance);
        if (source != null && record.getHeader().getStatus() == null) {
            if (suppressedRecordsProcessing) {
                source = metadataManager.updateMetadataSourceWithDiscoverySuppressedData(source, updatedSrsInstance);
                source = metadataManager.updateElectronicAccessFieldWithDiscoverySuppressedData(source, updatedSrsInstance);
            }
            try {
                record.withMetadata(buildOaiMetadata(request, source));
            } catch (Exception e) {
                logger.error("Error occurred while converting record to xml representation: {}.", e.getMessage(), e);
                logger.debug("Skipping problematic record due the conversion error. Source record id - {}.", storageHelper.getRecordId(srsInstance));
                return;
            }
        }
        if (filterInstance(request, srsInstance)) {
            records.add(record);
        }
    });
    return records;
}
Also used : CONTENT_TYPE(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE) OFFSET_PARAM(org.folio.oaipmh.Constants.OFFSET_PARAM) DecodeException(io.vertx.core.json.DecodeException) Date(java.util.Date) NEXT_INSTANCE_PK_VALUE(org.folio.oaipmh.Constants.NEXT_INSTANCE_PK_VALUE) StatusType(org.openarchives.oai._2.StatusType) Autowired(org.springframework.beans.factory.annotation.Autowired) NEXT_RECORD_ID_PARAM(org.folio.oaipmh.Constants.NEXT_RECORD_ID_PARAM) SEND_REQUEST(org.folio.oaipmh.service.MetricsCollectingService.MetricOperation.SEND_REQUEST) RESUMPTION_TOKEN_TIMEOUT(org.folio.oaipmh.Constants.RESUMPTION_TOKEN_TIMEOUT) Context(io.vertx.core.Context) WorkerExecutor(io.vertx.core.WorkerExecutor) Tuple(io.vertx.sqlclient.Tuple) OAIPMHerrorType(org.openarchives.oai._2.OAIPMHerrorType) ResumptionTokenType(org.openarchives.oai._2.ResumptionTokenType) Request(org.folio.oaipmh.Request) NAME(org.folio.oaipmh.helpers.records.RecordMetadataManager.NAME) OAIPMH(org.openarchives.oai._2.OAIPMH) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) JsonObject(io.vertx.core.json.JsonObject) BigInteger(java.math.BigInteger) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) AbstractHelper(org.folio.oaipmh.helpers.AbstractHelper) UNTIL_PARAM(org.folio.oaipmh.Constants.UNTIL_PARAM) EXPIRATION_DATE_RESUMPTION_TOKEN_PARAM(org.folio.oaipmh.Constants.EXPIRATION_DATE_RESUMPTION_TOKEN_PARAM) OKAPI_TENANT(org.folio.oaipmh.Constants.OKAPI_TENANT) InstancesService(org.folio.oaipmh.service.InstancesService) ITEMS(org.folio.oaipmh.helpers.records.RecordMetadataManager.ITEMS) MetricsCollectingService(org.folio.oaipmh.service.MetricsCollectingService) UUID(java.util.UUID) ITEMS_AND_HOLDINGS_FIELDS(org.folio.oaipmh.helpers.records.RecordMetadataManager.ITEMS_AND_HOLDINGS_FIELDS) Instant(java.time.Instant) Future(io.vertx.core.Future) TenantTool(org.folio.rest.tools.utils.TenantTool) Collectors(java.util.stream.Collectors) PostgresClient(org.folio.rest.persist.PostgresClient) ZoneId(java.time.ZoneId) String.format(java.lang.String.format) RepositoryConfigurationUtil(org.folio.oaipmh.helpers.RepositoryConfigurationUtil) REQUEST_ID_PARAM(org.folio.oaipmh.Constants.REQUEST_ID_PARAM) CALL_NUMBER(org.folio.oaipmh.helpers.records.RecordMetadataManager.CALL_NUMBER) Objects(java.util.Objects) List(java.util.List) Logger(org.apache.logging.log4j.Logger) OffsetDateTime(java.time.OffsetDateTime) Buffer(io.vertx.core.buffer.Buffer) Response(javax.ws.rs.core.Response) WebClientProvider(org.folio.oaipmh.WebClientProvider) RETRY_ATTEMPTS(org.folio.oaipmh.Constants.RETRY_ATTEMPTS) STATUS_MESSAGE(org.folio.oaipmh.Constants.STATUS_MESSAGE) ChronoField(java.time.temporal.ChronoField) HttpResponse(io.vertx.ext.web.client.HttpResponse) SourceStorageSourceRecordsClientWrapper(org.folio.oaipmh.service.SourceStorageSourceRecordsClientWrapper) RequestMetadataLb(org.folio.rest.jooq.tables.pojos.RequestMetadataLb) BodyCodec(io.vertx.ext.web.codec.BodyCodec) INSTANCES_PROCESSING(org.folio.oaipmh.service.MetricsCollectingService.MetricOperation.INSTANCES_PROCESSING) HashMap(java.util.HashMap) OKAPI_TOKEN(org.folio.oaipmh.Constants.OKAPI_TOKEN) REPOSITORY_MAX_RECORDS_PER_RESPONSE(org.folio.oaipmh.Constants.REPOSITORY_MAX_RECORDS_PER_RESPONSE) JsonEvent(io.vertx.core.parsetools.JsonEvent) CollectionUtils(org.apache.commons.collections4.CollectionUtils) SpringContextUtil(org.folio.spring.SpringContextUtil) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) RepositoryConfigurationUtil.getBooleanProperty(org.folio.oaipmh.helpers.RepositoryConfigurationUtil.getBooleanProperty) HttpRequestImpl(io.vertx.ext.web.client.impl.HttpRequestImpl) AsyncResult(io.vertx.core.AsyncResult) STATUS_CODE(org.folio.oaipmh.Constants.STATUS_CODE) Promise(io.vertx.core.Promise) Vertx(io.vertx.core.Vertx) Instances(org.folio.rest.jooq.tables.pojos.Instances) RecordMetadataManager(org.folio.oaipmh.helpers.records.RecordMetadataManager) Maps(com.google.common.collect.Maps) HttpRequest(io.vertx.ext.web.client.HttpRequest) JsonArray(io.vertx.core.json.JsonArray) ResponseHelper(org.folio.oaipmh.helpers.response.ResponseHelper) PgConnection(io.vertx.pgclient.PgConnection) Collectors.toList(java.util.stream.Collectors.toList) RecordType(org.openarchives.oai._2.RecordType) REPOSITORY_SRS_HTTP_REQUEST_RETRY_ATTEMPTS(org.folio.oaipmh.Constants.REPOSITORY_SRS_HTTP_REQUEST_RETRY_ATTEMPTS) ACCEPT(javax.ws.rs.core.HttpHeaders.ACCEPT) LOCATION(org.folio.oaipmh.Constants.LOCATION) REPOSITORY_SUPPRESSED_RECORDS_PROCESSING(org.folio.oaipmh.Constants.REPOSITORY_SUPPRESSED_RECORDS_PROCESSING) ListRecordsType(org.openarchives.oai._2.ListRecordsType) Handler(io.vertx.core.Handler) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) RecordType(org.openarchives.oai._2.RecordType) RecordMetadataManager(org.folio.oaipmh.helpers.records.RecordMetadataManager) ArrayList(java.util.ArrayList) JsonObject(io.vertx.core.json.JsonObject) DecodeException(io.vertx.core.json.DecodeException)

Aggregations

ArrayList (java.util.ArrayList)8 AbstractRecordType (org.geotoolkit.csw.xml.v202.AbstractRecordType)7 BriefRecordType (org.geotoolkit.csw.xml.v202.BriefRecordType)7 RecordType (org.geotoolkit.csw.xml.v202.RecordType)7 SummaryRecordType (org.geotoolkit.csw.xml.v202.SummaryRecordType)7 SimpleLiteral (org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral)7 BoundingBoxType (org.geotoolkit.ows.xml.v100.BoundingBoxType)7 WGS84BoundingBoxType (org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType)7 Test (org.junit.Test)7 List (java.util.List)6 RecordType (org.openarchives.oai._2.RecordType)6 OAIPMH (org.openarchives.oai._2.OAIPMH)5 ResumptionTokenType (org.openarchives.oai._2.ResumptionTokenType)5 StringWriter (java.io.StringWriter)4 Marshaller (javax.xml.bind.Marshaller)4 Property (org.osate.aadl2.Property)4 RecordType (org.osate.aadl2.RecordType)4 JAXBElement (javax.xml.bind.JAXBElement)3 BasicProperty (org.osate.aadl2.BasicProperty)3 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)3