Search in sources :

Example 51 with CswException

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswException in project ddf by codice.

the class TestCswEndpoint method testCapabilitiesRequestAllSections.

@Test
public void testCapabilitiesRequestAllSections() {
    // Should return all sections
    GetCapabilitiesRequest gcr = createDefaultGetCapabilitiesRequest();
    gcr.setSections(CswEndpoint.SERVICE_IDENTIFICATION + "," + CswEndpoint.SERVICE_PROVIDER + "," + CswEndpoint.OPERATIONS_METADATA + "," + CswEndpoint.FILTER_CAPABILITIES);
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gcr);
    } catch (CswException e) {
        fail("CswException caught during getCapabilities GET request: " + e.getMessage());
    }
    assertThat(ct, notNullValue());
    verifyOperationsMetadata(ct);
    verifyServiceIdentification(ct);
    verifyServiceProvider(ct);
    verifyFilterCapabilities(ct);
}
Also used : GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Example 52 with CswException

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswException in project ddf by codice.

the class CswUnmarshallHelper method convertRecordPropertyToMetacardAttribute.

/**
     * Converts the CSW record property {@code reader} is currently at to the specified Metacard
     * attribute format.
     *
     * @param reader       the reader at the element whose value you want to convert
     * @param cswAxisOrder the order of the coordinates in the XML being read by {@code reader}
     * @return the value that was extracted from {@code reader} and is of the type described by
     * {@code attributeFormat}
     */
public static Serializable convertRecordPropertyToMetacardAttribute(AttributeType.AttributeFormat attributeFormat, HierarchicalStreamReader reader, CswAxisOrder cswAxisOrder) {
    LOGGER.debug("converting csw record property {}", reader.getValue());
    Serializable ser = null;
    switch(attributeFormat) {
        case BOOLEAN:
            ser = Boolean.valueOf(reader.getValue());
            break;
        case DOUBLE:
            ser = Double.valueOf(reader.getValue());
            break;
        case FLOAT:
            ser = Float.valueOf(reader.getValue());
            break;
        case INTEGER:
            ser = Integer.valueOf(reader.getValue());
            break;
        case LONG:
            ser = Long.valueOf(reader.getValue());
            break;
        case SHORT:
            ser = Short.valueOf(reader.getValue());
            break;
        case XML:
        case STRING:
            ser = reader.getValue();
            break;
        case DATE:
            ser = CswUnmarshallHelper.convertStringValueToMetacardValue(attributeFormat, reader.getValue());
            break;
        case GEOMETRY:
            // We pass in cswAxisOrder, so we can determine coord order (LAT/LON vs
            // LON/LAT).
            BoundingBoxReader bboxReader = new BoundingBoxReader(reader, cswAxisOrder);
            try {
                ser = bboxReader.getWkt();
            } catch (CswException cswException) {
                LOGGER.debug("CswUnmarshallHelper.convertRecordPropertyToMetacardAttribute(): could not read BoundingBox.", cswException);
            }
            LOGGER.debug("WKT = {}", ser);
            break;
        case BINARY:
            ser = reader.getValue().getBytes(StandardCharsets.UTF_8);
            break;
        default:
            break;
    }
    return ser;
}
Also used : Serializable(java.io.Serializable) BoundingBoxReader(org.codice.ddf.spatial.ogc.csw.catalog.common.BoundingBoxReader) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)

Example 53 with CswException

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswException in project ddf by codice.

the class TestCswEndpoint method testPostDescribeRecordRequestNoTypesPassed.

@Test
public void testPostDescribeRecordRequestNoTypesPassed() {
    // Should only return the ServiceProvider section
    DescribeRecordType request = createDefaultDescribeRecordType();
    LOGGER.info("Resource directory is {}", this.getClass().getResource(".").getPath());
    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 54 with CswException

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswException 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 55 with CswException

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswException in project ddf by codice.

the class TestCswEndpoint method testCapabilitiesRequestServiceProvider.

@Test
public void testCapabilitiesRequestServiceProvider() {
    // Should only return the ServiceProvider section
    GetCapabilitiesRequest gcr = createDefaultGetCapabilitiesRequest();
    gcr.setSections(CswEndpoint.SERVICE_PROVIDER);
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gcr);
    } catch (CswException e) {
        fail("CswException caught during getCapabilities GET request: " + e.getMessage());
    }
    assertThat(ct, notNullValue());
    assertThat(ct.getOperationsMetadata(), nullValue());
    assertThat(ct.getServiceIdentification(), nullValue());
    verifyFilterCapabilities(ct);
    verifyServiceProvider(ct);
}
Also used : GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Aggregations

CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)84 Test (org.junit.Test)55 CapabilitiesType (net.opengis.cat.csw.v_2_0_2.CapabilitiesType)19 GetCapabilitiesType (net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType)19 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)17 QueryImpl (ddf.catalog.operation.impl.QueryImpl)13 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)13 DescribeRecordResponseType (net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType)13 Matchers.anyString (org.mockito.Matchers.anyString)13 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)11 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)10 ArrayList (java.util.ArrayList)10 SchemaComponentType (net.opengis.cat.csw.v_2_0_2.SchemaComponentType)10 GetCapabilitiesRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest)10 SourceResponse (ddf.catalog.operation.SourceResponse)9 IOException (java.io.IOException)9 DescribeRecordRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.DescribeRecordRequest)9 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)7 Filter (org.opengis.filter.Filter)7 JAXBException (javax.xml.bind.JAXBException)6