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