Search in sources :

Example 31 with DescribeRecordResponseType

use of net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType in project ddf by codice.

the class CswEndpoint method buildDescribeRecordResponseFromTypes.

private DescribeRecordResponseType buildDescribeRecordResponseFromTypes(List<QName> types) throws CswException {
    validator.validateFullyQualifiedTypes(types);
    DescribeRecordResponseType response = new DescribeRecordResponseType();
    List<SchemaComponentType> schemas = new ArrayList<>();
    String schemaLocation;
    String schema;
    if (types.isEmpty()) {
        List<String> typeNames = getTypeNames();
        for (String typeName : typeNames) {
            schema = schemaTransformerManager.getTransformerSchemaForId(typeName);
            schemaLocation = schemaTransformerManager.getTransformerSchemaLocationForId(typeName);
            if (StringUtils.isNotBlank(schema) && StringUtils.isNotBlank(schemaLocation)) {
                schemas.add(getSchemaComponentType(schema, schemaLocation));
            }
        }
    } else {
        for (QName type : types) {
            String typeName = StringUtils.isNotBlank(type.getPrefix()) ? type.getPrefix() + CswConstants.NAMESPACE_DELIMITER : "";
            typeName += type.getLocalPart();
            schema = schemaTransformerManager.getTransformerSchemaForId(typeName);
            if (schema != null && schema.equals(type.getNamespaceURI())) {
                schemaLocation = schemaTransformerManager.getTransformerSchemaLocationForId(typeName);
                if (StringUtils.isNotBlank(schemaLocation)) {
                    schemas.add(getSchemaComponentType(schema, schemaLocation));
                }
            }
        }
        if (types.contains(new QName(CswConstants.EBRIM_SCHEMA, CswConstants.EBRIM_RECORD_LOCAL_NAME))) {
            schemas.add(getSchemaComponentType(CswConstants.EBRIM_SCHEMA, "csw-ebrim.1.0.2/csw-ebrim.xsd"));
        }
    }
    response.setSchemaComponent(schemas);
    return response;
}
Also used : SchemaComponentType(net.opengis.cat.csw.v_2_0_2.SchemaComponentType) DescribeRecordResponseType(net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList)

Example 32 with DescribeRecordResponseType

use of net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType in project ddf by codice.

the class CswEndpointTest method testPostDescribeRecordRequestGMDTypePassed.

@Test
public void testPostDescribeRecordRequestGMDTypePassed() {
    DescribeRecordType drt = createDefaultDescribeRecordType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(GmdConstants.GMD_NAMESPACE, GmdConstants.GMD_LOCAL_NAME, GmdConstants.GMD_PREFIX));
    drt.setTypeName(typeNames);
    when(mockSchemaManager.getTransformerSchemaForId(GMD_PREFIX_LOCAL_TYPE)).thenReturn(GmdConstants.GMD_NAMESPACE);
    when(mockSchemaManager.getTransformerSchemaLocationForId(GMD_PREFIX_LOCAL_TYPE)).thenReturn(GMD_SCHEMA_LOCATION);
    DescribeRecordResponseType drrt = null;
    try {
        drrt = csw.describeRecord(drt);
    } catch (CswException e) {
        fail("CswException caught during describeRecord POST request: " + e.getMessage());
    }
    assertThat(drrt, notNullValue());
    assertThat(drrt.getSchemaComponent(), notNullValue());
    List<SchemaComponentType> schemaComponents = drrt.getSchemaComponent();
    assertThat(schemaComponents.size(), is(1));
}
Also used : DescribeRecordType(net.opengis.cat.csw.v_2_0_2.DescribeRecordType) SchemaComponentType(net.opengis.cat.csw.v_2_0_2.SchemaComponentType) QName(javax.xml.namespace.QName) DescribeRecordResponseType(net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType) ArrayList(java.util.ArrayList) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Example 33 with DescribeRecordResponseType

use of net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType in project ddf by codice.

the class CswEndpointTest method testPostDescribeRecordRequestNoTypesPassed.

@Test
public void testPostDescribeRecordRequestNoTypesPassed() {
    // Should only return the ServiceProvider section
    DescribeRecordType request = createDefaultDescribeRecordType();
    LOGGER.info("Resource directory is {}", this.getClass().getResource(".").getPath());
    when(mockSchemaManager.getTransformerSchemaForId(VALID_PREFIX_LOCAL_TYPE)).thenReturn(CswConstants.CSW_OUTPUT_SCHEMA);
    when(mockSchemaManager.getTransformerSchemaLocationForId(VALID_PREFIX_LOCAL_TYPE)).thenReturn(CSW_SCHEMA_LOCATION);
    when(mockSchemaManager.getTransformerSchemaForId(THIRD_PARTY_TYPE_NAME)).thenReturn(SAMPLE_NAME_SPACE);
    when(mockSchemaManager.getTransformerSchemaLocationForId(THIRD_PARTY_TYPE_NAME)).thenReturn(RECORD_SCHEMA_LOCATION);
    DescribeRecordResponseType drrt = null;
    try {
        drrt = csw.describeRecord(request);
    } catch (CswException e) {
        fail("CswException caught during describeRecord POST request: " + e.getMessage());
    }
    assertThat(drrt, notNullValue());
    assertThat(drrt.getSchemaComponent(), notNullValue());
    // Assert that it returned all record types.
    assertThat(drrt.getSchemaComponent().size(), is(2));
    LOGGER.info("got response \n{}\n", drrt.toString());
}
Also used : DescribeRecordType(net.opengis.cat.csw.v_2_0_2.DescribeRecordType) DescribeRecordResponseType(net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Example 34 with DescribeRecordResponseType

use of net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType in project ddf by codice.

the class CswEndpointTest method testDescribeRecordMultipleTypesMultipleNamespacesNominal.

@Test
public void testDescribeRecordMultipleTypesMultipleNamespacesNominal() {
    DescribeRecordRequest drr = createDefaultDescribeRecordRequest();
    drr.setTypeName(VALID_PREFIX_LOCAL_TYPE + ",csw:test");
    drr.setNamespace("xmlns(" + VALID_PREFIX + "=" + CswConstants.CSW_OUTPUT_SCHEMA + ")");
    DescribeRecordResponseType drrt = null;
    try {
        drrt = csw.describeRecord(drr);
    } catch (CswException e) {
        fail("DescribeRecord failed with message '" + e.getMessage() + "'");
    }
    assertThat(drrt, notNullValue());
    assertThat(drrt.getSchemaComponent(), notNullValue());
    List<SchemaComponentType> schemaComponents = drrt.getSchemaComponent();
    assertThat(schemaComponents.size(), is(1));
}
Also used : SchemaComponentType(net.opengis.cat.csw.v_2_0_2.SchemaComponentType) DescribeRecordRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.DescribeRecordRequest) DescribeRecordResponseType(net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Example 35 with DescribeRecordResponseType

use of net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType in project ddf by codice.

the class CswEndpointTest method testPostDescribeRecordValidSchemaLanguage.

@Test
public void testPostDescribeRecordValidSchemaLanguage() {
    DescribeRecordType drt = createDefaultDescribeRecordType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
    drt.setTypeName(typeNames);
    drt.setSchemaLanguage(CswConstants.SCHEMA_LANGUAGE_X_SCHEMA);
    DescribeRecordResponseType drrt = null;
    try {
        drrt = csw.describeRecord(drt);
    } catch (CswException e) {
        fail("DescribeRecord failed with message '" + e.getMessage() + "'");
    }
    assertThat(drrt, notNullValue());
    assertThat(drrt.getSchemaComponent(), notNullValue());
    List<SchemaComponentType> schemaComponents = drrt.getSchemaComponent();
    assertThat(schemaComponents.size(), is(1));
}
Also used : DescribeRecordType(net.opengis.cat.csw.v_2_0_2.DescribeRecordType) SchemaComponentType(net.opengis.cat.csw.v_2_0_2.SchemaComponentType) QName(javax.xml.namespace.QName) DescribeRecordResponseType(net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType) ArrayList(java.util.ArrayList) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Aggregations

DescribeRecordResponseType (net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType)36 Test (org.junit.Test)34 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)26 SchemaComponentType (net.opengis.cat.csw.v_2_0_2.SchemaComponentType)24 DescribeRecordRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.DescribeRecordRequest)20 ArrayList (java.util.ArrayList)14 QName (javax.xml.namespace.QName)12 DescribeRecordType (net.opengis.cat.csw.v_2_0_2.DescribeRecordType)12 StringWriter (java.io.StringWriter)2 JAXBContext (javax.xml.bind.JAXBContext)2 JAXBElement (javax.xml.bind.JAXBElement)2 JAXBException (javax.xml.bind.JAXBException)2 Marshaller (javax.xml.bind.Marshaller)2