throw new RuntimeException(e);
}
Date now = new Date();
Model logEntryModel = ModelFactory.createDefaultModel();
Resource downloadAttempt = logEntryModel
.createResource(AGGREGATOR.DownloadAttempt);
downloadAttempt.addProperty(AGGREGATOR.time, new W3CDateFormat()
.format(now), XSDDatatype.XSDdateTime);
downloadAttempt.addProperty(AGGREGATOR.aggregatedSource, logEntryModel
.createResource(aggregatedSource.getURIRef()));
downloadAttempt.addProperty(AGGREGATOR.aggregator, logEntryModel
.createResource(identity.getURIRef()));
Graph logEntryGraph = JenaUtil.getGraphFromModel(logEntryModel, true);
final StringWriter aggregationWarningWriter = new StringWriter();
final StringWriter aggregationErrorWriter = new StringWriter();
try {
Model model = ModelFactory.createDefaultModel();
// model.read(url.toString());
JenaReader jenaReader = new JenaReader();
jenaReader.setErrorHandler(new RDFErrorHandler() {
public void error(Exception e) {
aggregationErrorWriter.write(e.getMessage());
}
public void fatalError(Exception e) {
aggregationErrorWriter.write("FATAL: ");
aggregationErrorWriter.write(e.getMessage());
log.info("Fatal Error aggregating "+aggregatedSource, e);
throw new AllreadyLoggedRuntimeException(e);
}
public void warning(Exception e) {
aggregationWarningWriter.write(e.getMessage());
}
});
jenaReader.read(model, url.toString());
String errorMessage = aggregationErrorWriter.toString();
if (errorMessage.equals("")) {
Graph graph = JenaUtil.getGraphFromModel(model, true);
store.updateGraph(aggregatedSource, new FCAGraphImpl(graph));
} else {
if (!errorMessage.equals("")) {
downloadAttempt.addProperty(AGGREGATOR.errorMessage, errorMessage);
}
}
} catch (Throwable th) {
if (!(th instanceof AllreadyLoggedRuntimeException)) {
String errorMessage = th.getMessage();
if (errorMessage == null) {
errorMessage = th.toString();
}
downloadAttempt.addProperty(AGGREGATOR.errorMessage, errorMessage);
}
}
String warningMessage = aggregationWarningWriter.toString();
if (!warningMessage.equals("")) {
downloadAttempt.addProperty(AGGREGATOR.warningMessage, warningMessage);
}
updateWorkingGraph(store, identity, now, aggregatedSource, logEntryGraph);
//store.assertGraph(identity, new FCAGraphImpl(logEntryGraph), now);
}