use of org.codice.ddf.spatial.ogc.csw.catalog.converter.XstreamPathValueTracker in project ddf by codice.
the class GmdTransformer method handleTransform.
private Metacard handleTransform(InputStream inputStream, String id) throws CatalogTransformerException {
String xml;
XstreamPathValueTracker pathValueTracker;
try (TemporaryFileBackedOutputStream temporaryFileBackedOutputStream = new TemporaryFileBackedOutputStream()) {
IOUtils.copy(inputStream, temporaryFileBackedOutputStream);
byteArray = temporaryFileBackedOutputStream.asByteSource();
try (InputStream xmlSourceInputStream = getSourceInputStream()) {
xml = IOUtils.toString(xmlSourceInputStream);
}
argumentHolder.put(XstreamPathConverter.PATH_KEY, buildPaths());
XMLStreamReader streamReader = xmlFactory.createXMLStreamReader(new StringReader(xml));
HierarchicalStreamReader reader = new StaxReader(new QNameMap(), streamReader);
pathValueTracker = (XstreamPathValueTracker) xstream.unmarshal(reader, null, argumentHolder);
Metacard metacard = toMetacard(pathValueTracker, id);
metacard.setAttribute(new AttributeImpl(Core.METADATA, xml));
return metacard;
} catch (XStreamException | XMLStreamException | IOException e) {
throw new CatalogTransformerException(TRANSFORM_EXCEPTION_MSG, e);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
Aggregations