Search in sources :

Example 16 with SchemaComponentType

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

the class CswEndpointTest method testDescribeRecordMultipleTypesMultipleNamespacesMultiplePrefixes.

@Test
public void testDescribeRecordMultipleTypesMultipleNamespacesMultiplePrefixes() {
    DescribeRecordRequest drr = createDefaultDescribeRecordRequest();
    drr.setTypeName(VALID_PREFIX_LOCAL_TYPE + ",csw2:test4");
    drr.setNamespace("xmlns(" + VALID_PREFIX + "=" + CswConstants.CSW_OUTPUT_SCHEMA + ")" + "," + "xmlns(" + "csw2" + "=" + CswConstants.CSW_OUTPUT_SCHEMA + "2" + ")");
    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 17 with SchemaComponentType

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

the class TestCswEndpoint method testDescribeRecordMultipleTypesMultipleNamespacesMultiplePrefixes.

@Test
public void testDescribeRecordMultipleTypesMultipleNamespacesMultiplePrefixes() {
    DescribeRecordRequest drr = createDefaultDescribeRecordRequest();
    drr.setTypeName(VALID_PREFIX_LOCAL_TYPE + ",csw2:test4");
    drr.setNamespace("xmlns(" + VALID_PREFIX + "=" + CswConstants.CSW_OUTPUT_SCHEMA + ")" + "," + "xmlns(" + "csw2" + "=" + CswConstants.CSW_OUTPUT_SCHEMA + "2" + ")");
    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 18 with SchemaComponentType

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

the class TestCswEndpoint method testDescribeRecordSingleTypeSingleNamespaceNoPrefixes.

@Test
public void testDescribeRecordSingleTypeSingleNamespaceNoPrefixes() {
    DescribeRecordRequest drr = createDefaultDescribeRecordRequest();
    drr.setTypeName(VALID_TYPE);
    drr.setNamespace("xmlns(" + 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 19 with SchemaComponentType

use of net.opengis.cat.csw.v_2_0_2.SchemaComponentType 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 20 with SchemaComponentType

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

the class CswEndpoint method getSchemaComponentType.

private SchemaComponentType getSchemaComponentType(String outputSchema, String schemaLocation) throws CswException {
    SchemaComponentType schemaComponentType = new SchemaComponentType();
    List<Object> listOfObject = new ArrayList<>();
    listOfObject.add(getDocElementFromResourcePath(schemaLocation));
    schemaComponentType.setContent(listOfObject);
    schemaComponentType.setSchemaLanguage(CswConstants.XML_SCHEMA_LANGUAGE);
    schemaComponentType.setTargetNamespace(outputSchema);
    return schemaComponentType;
}
Also used : SchemaComponentType(net.opengis.cat.csw.v_2_0_2.SchemaComponentType) ArrayList(java.util.ArrayList)

Aggregations

SchemaComponentType (net.opengis.cat.csw.v_2_0_2.SchemaComponentType)25 DescribeRecordResponseType (net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType)24 Test (org.junit.Test)22 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)20 ArrayList (java.util.ArrayList)13 DescribeRecordRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.DescribeRecordRequest)12 QName (javax.xml.namespace.QName)10 DescribeRecordType (net.opengis.cat.csw.v_2_0_2.DescribeRecordType)8 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