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 + "]");
}
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);
}
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());
}
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));
}
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);
}
Aggregations