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