graph = new IndexedMGraph();
bindPhysicalOrigin(null);
}
Iterator<String> itf = formats.iterator();
if (!itf.hasNext()) throw new OntologyLoadingException("No suitable format found or defined.");
do {
String f = itf.next();
log.debug("Parsing with format {}", f);
try {
parser.parse((MGraph) graph, content, f);
loaded = true;
log.info("Graph parsed, has {} triples", graph.size());
} catch (UnsupportedFormatException e) {
log.debug("Parsing format {} failed.", f);
} catch (Exception e) {
log.debug("Error parsing format " + f, e);
} finally {
if (!loaded && content.markSupported()) try {
content.reset();
} catch (IOException e) {
log.debug("Failed to reset data stream while parsing format {}.", f);
// No way to retry if the stream cannot be reset. Must recreate it.
break;
}
}
} while (!loaded && itf.hasNext());
if (loaded) {
bindRootOntology(graph);
log.debug("Root ontology is a {}.", getRootOntology().getClass().getCanonicalName());
} else {
// Rollback graph creation, if any
if (tcProvider != null && tcProvider != null) {
tcProvider.deleteTripleCollection(name);
log.error("Parsing failed. Deleting triple collection {}", name);
}
throw new OntologyLoadingException("Parsing failed. Giving up.");
}
log.debug("Input source initialization completed in {} ms.", (System.currentTimeMillis() - before));
}