plainTextSink.getOutputStream(), UTF8));
boolean textExtracted = false; //used to detect if some text was extracted
try {
MGraph g = new SimpleMGraph(); //first add to a temporary graph
while (it.hasNext()) {
Statement oneStmt = it.next();
//we need to treat triples that provide the plain/text
//version differently. Such Objects need to be added to
//the plain text Blob!
if(oneStmt.getSubject().equals(docId) &&
oneStmt.getPredicate().equals(NIE_PLAINTEXT_PROPERTY)){
String text = oneStmt.getObject().toString();
if(text != null && !text.isEmpty()){
try {
out.write(oneStmt.getObject().toString());
} catch (IOException e) {
throw new EngineException("Unable to write extracted" +
"plain text to Blob (blob impl: "
+ plainTextSink.getBlob().getClass()+")",e);
}
textExtracted = true;
if (includeText) {
NonLiteral subject = (NonLiteral) asClerezzaResource(oneStmt.getSubject(), blankNodeMap);
UriRef predicate = (UriRef) asClerezzaResource(oneStmt.getPredicate(), blankNodeMap);
Resource object = asClerezzaResource(oneStmt.getObject(), blankNodeMap);
g.add(new TripleImpl(subject, predicate, object));
}
}
} else { //add metadata to the metadata of the contentItem
NonLiteral subject = (NonLiteral) asClerezzaResource(oneStmt.getSubject(), blankNodeMap);
UriRef predicate = (UriRef) asClerezzaResource(oneStmt.getPredicate(), blankNodeMap);
Resource object = asClerezzaResource(oneStmt.getObject(), blankNodeMap);
if (null != subject && null != predicate && null != object) {
Triple t = new TripleImpl(subject, predicate, object);
g.add(t);
log.debug("added " + t.toString());