Search in sources :

Example 56 with CswException

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

the class TestCswEndpoint method testCapabilitiesFederatedCatalogs.

@Test
public void testCapabilitiesFederatedCatalogs() {
    GetCapabilitiesRequest gcr = createDefaultGetCapabilitiesRequest();
    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(), notNullValue());
    for (Operation operation : ct.getOperationsMetadata().getOperation()) {
        if (StringUtils.equals(operation.getName(), CswConstants.GET_RECORDS)) {
            for (DomainType constraint : operation.getConstraint()) {
                if (StringUtils.equals(constraint.getName(), CswConstants.FEDERATED_CATALOGS)) {
                    assertThat(constraint.getValue().size(), is(3));
                    return;
                }
            }
        }
    }
    fail("Didn't find [" + CswConstants.FEDERATED_CATALOGS + "] in request [" + CswConstants.GET_RECORDS + "]");
}
Also used : GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest) DomainType(net.opengis.ows.v_1_0_0.DomainType) 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) Operation(net.opengis.ows.v_1_0_0.Operation) Test(org.junit.Test)

Example 57 with CswException

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

the class TestCswEndpoint method testGetCapabilitiesTypeNoSections.

@Test
public void testGetCapabilitiesTypeNoSections() {
    // Should return all sections
    GetCapabilitiesType gct = createDefaultGetCapabilitiesType();
    gct.setSections(null);
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gct);
    } 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 : CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) 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 58 with CswException

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

the class TestCswEndpoint method testGetCapabilitiesTypeOperationsMetadata.

@Test
public void testGetCapabilitiesTypeOperationsMetadata() {
    // Should only return the OperationsMetadata section
    GetCapabilitiesType gct = createDefaultGetCapabilitiesType();
    SectionsType stv = new SectionsType();
    stv.setSection(Arrays.asList(CswEndpoint.OPERATIONS_METADATA));
    gct.setSections(stv);
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gct);
    } catch (CswException e) {
        fail("CswException caught during getCapabilities GET request: " + e.getMessage());
    }
    assertThat(ct, notNullValue());
    verifyOperationsMetadata(ct);
    verifyFilterCapabilities(ct);
    assertThat(ct.getServiceIdentification(), nullValue());
    assertThat(ct.getServiceProvider(), nullValue());
}
Also used : SectionsType(net.opengis.ows.v_1_0_0.SectionsType) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) 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 59 with CswException

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

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

the class CswEndpoint method getRecords.

@Override
@POST
@Consumes({ MediaType.TEXT_XML, MediaType.APPLICATION_XML })
@Produces({ MediaType.WILDCARD })
public CswRecordCollection getRecords(GetRecordsType request) throws CswException {
    if (request == null) {
        throw new CswException("GetRecordsType request is null");
    } else {
        LOGGER.debug("{} attempting to get records.", request.getService());
    }
    validator.validateOutputFormat(request.getOutputFormat(), mimeTypeTransformerManager);
    validator.validateOutputSchema(request.getOutputSchema(), schemaTransformerManager);
    if (request.getAbstractQuery() != null) {
        if (!request.getAbstractQuery().getValue().getClass().equals(QueryType.class)) {
            throw new CswException("Unknown QueryType: " + request.getAbstractQuery().getValue().getClass());
        }
        QueryType query = (QueryType) request.getAbstractQuery().getValue();
        validator.validateTypes(query.getTypeNames(), CswConstants.VERSION_2_0_2);
        validator.validateElementNames(query);
        if (query.getConstraint() != null && query.getConstraint().isSetFilter() && query.getConstraint().isSetCqlText()) {
            throw new CswException("A Csw Query can only have a Filter or CQL constraint");
        }
    }
    LOGGER.trace("Exiting getRecords.");
    return queryCsw(request);
}
Also used : CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

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