Search in sources :

Example 1 with GmlEnvelopeConverter

use of org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlEnvelopeConverter in project ddf by codice.

the class XStreamWfs11FeatureTransformer method apply.

@Override
public Optional<Metacard> apply(InputStream document, WfsMetadata<FeatureTypeType> metadata) {
    XStream xStream = new XStream(new WstxDriver());
    xStream.addPermission(NoTypePermission.NONE);
    xStream.allowTypeHierarchy(Metacard.class);
    xStream.setClassLoader(this.getClass().getClassLoader());
    xStream.registerConverter(new GmlGeometryConverter());
    xStream.registerConverter(new GmlEnvelopeConverter());
    xStream.alias(metadata.getActiveFeatureMemberNodeName(), Metacard.class);
    FeatureTypeType featureType = null;
    for (FeatureTypeType ft : metadata.getDescriptors()) {
        if (ft.getName() != null && metadata.getActiveFeatureMemberNodeName().equals(ft.getName().getLocalPart())) {
            featureType = ft;
        }
    }
    lookupFeatureConverter(metadata, featureType).ifPresent(xStream::registerConverter);
    Metacard metacard = null;
    try {
        metacard = (Metacard) xStream.fromXML(document);
    } catch (XStreamException e) {
        LOGGER.trace("Failed to parse FeatureMember into Metacard", e);
    }
    return Optional.ofNullable(metacard);
}
Also used : WstxDriver(com.thoughtworks.xstream.io.xml.WstxDriver) FeatureTypeType(net.opengis.wfs.v_1_1_0.FeatureTypeType) Metacard(ddf.catalog.data.Metacard) XStreamException(com.thoughtworks.xstream.XStreamException) GmlGeometryConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlGeometryConverter) XStream(com.thoughtworks.xstream.XStream) GmlEnvelopeConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlEnvelopeConverter)

Aggregations

XStream (com.thoughtworks.xstream.XStream)1 XStreamException (com.thoughtworks.xstream.XStreamException)1 WstxDriver (com.thoughtworks.xstream.io.xml.WstxDriver)1 Metacard (ddf.catalog.data.Metacard)1 FeatureTypeType (net.opengis.wfs.v_1_1_0.FeatureTypeType)1 GmlEnvelopeConverter (org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlEnvelopeConverter)1 GmlGeometryConverter (org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlGeometryConverter)1