use of org.apache.tika.parser.image.xmp.XMPPacketScanner in project stanbol by apache.
the class XmpExtractorEngine method computeEnhancements.
@Override
public void computeEnhancements(ContentItem ci) throws EngineException {
InputStream in = ci.getBlob().getStream();
XMPPacketScanner scanner = new XMPPacketScanner();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
scanner.parse(in, baos);
} catch (IOException e) {
throw new EngineException(e);
}
byte[] bytes = baos.toByteArray();
if (bytes.length > 0) {
Graph model = new IndexedGraph();
parser.parse(model, new ByteArrayInputStream(bytes), "application/rdf+xml");
GraphNode gn = new GraphNode(new IRI("http://relative-uri.fake/"), model);
gn.replaceWith(ci.getUri());
ci.getLock().writeLock().lock();
try {
LOG.info("Model: {}", model);
ci.getMetadata().addAll(model);
} finally {
ci.getLock().writeLock().unlock();
}
}
}
Aggregations