Skip to content

Commit

Permalink
improve error reporting in owl load
Browse files Browse the repository at this point in the history
  • Loading branch information
melaasar committed Sep 18, 2024
1 parent ff69b47 commit d5bf3d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
subprojects {
group = 'io.opencaesar.owl'
version = '2.11.0'
version = '2.12.0'

ext.versions = [
owl: '5.1.17',
Expand Down
23 changes: 14 additions & 9 deletions owl-load/src/main/java/io/opencaesar/owl/load/OwlLoadApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,13 @@ private Collection<String> getMappedIris(Collection<File> files, OwlCatalog cata

private Collection<String> getLoadedIris(RDFConnection conn) {
var iris = new HashSet<String>();
var rs = conn.query("select ?g { graph ?g { ?o a <http://www.w3.org/2002/07/owl#Ontology> } }").execSelect();
rs.forEachRemaining(s -> iris.add(s.getResource("g").getURI()));
try {
var rs = conn.query("select ?g { graph ?g { ?o a <http://www.w3.org/2002/07/owl#Ontology> } }").execSelect();
rs.forEachRemaining(s -> iris.add(s.getResource("g").getURI()));
} catch(Exception e) {
LOGGER.error("Error accessing endpoint "+endpointURL+"/"+queryService+": "+e.getMessage());
throw e;
}
return iris;
}

Expand Down Expand Up @@ -403,8 +408,8 @@ private Set<String> getIrisFromPath() throws Exception {

private void loadToDefault(RDFConnection conn, OwlCatalog catalog, String iri) {
LOGGER.info("Loading "+iri);
String documentIRI = catalog.resolveURI(iri);
String documentFile = new File(URI.create(documentIRI)).toString();
String documentURI = catalog.resolveURI(iri);
String documentFile = new File(URI.create(documentURI)).toString();
try {
Lang lang = RDFLanguages.filenameToLang(documentFile);
if (RDFLanguages.isQuads(lang)) {
Expand All @@ -416,7 +421,7 @@ private void loadToDefault(RDFConnection conn, OwlCatalog catalog, String iri) {
}
conn.commit();
} catch (Exception e) {
throw new RuntimeException("Error occurred loading ontology '" + documentIRI + "' to default graph: "+e.getMessage(), e);
throw new RuntimeException("Error loading '" + documentURI + "' to default graph: "+e.getMessage(), e);
}
}

Expand All @@ -432,8 +437,8 @@ private void removeAllFromDefault(RDFConnection conn) {

private void put(RDFConnection conn, OwlCatalog catalog, String iri) {
LOGGER.info("Loading " + iri);
String documentIRI = catalog.resolveURI(iri);
String documentFile = new File(URI.create(documentIRI)).toString();
String documentURI = catalog.resolveURI(iri);
String documentFile = new File(URI.create(documentURI)).toString();
try {
Lang lang = RDFLanguages.filenameToLang(documentFile);
if (RDFLanguages.isQuads(lang)) {
Expand All @@ -443,7 +448,7 @@ private void put(RDFConnection conn, OwlCatalog catalog, String iri) {
}
conn.commit();
} catch (Exception e) {
throw new RuntimeException("Error loading graph '" + documentIRI + "'", e);
throw new RuntimeException("Error loading '" + documentURI + "' to named graph: "+e.getMessage(), e);
}
}

Expand All @@ -453,7 +458,7 @@ private void delete(RDFConnection conn, String iri) {
conn.delete(iri);
conn.commit();
} catch (Exception e) {
throw new RuntimeException("Error unloading graph '" + iri + "'", e);
throw new RuntimeException("Error unloading graph '" + iri + "': "+e.getMessage(), e);
}
}

Expand Down

0 comments on commit d5bf3d1

Please sign in to comment.