/** * Replaces the graph node resouce with the specified <code>BlankNodeOrIRI</code>. * The resource is only replaced where it is either subject or object. * @param replacement * @return a GraphNode representing the replecement node */ public GraphNode replaceWith(BlankNodeOrIRI replacement) { return replaceWith(replacement, false); }
/** * Replaces the graph node resouce with the specified <code>BlankNodeOrIRI</code>. * The resource is only replaced where it is either subject or object. * @param replacement * @return a GraphNode representing the replecement node */ public GraphNode replaceWith(BlankNodeOrIRI replacement) { return replaceWith(replacement, false); }
@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(); } } }