From d5bf3d17a2d7dbfb5c4af095b0de0930c0ded83d Mon Sep 17 00:00:00 2001 From: Maged Elaasar Date: Wed, 18 Sep 2024 15:17:49 -0700 Subject: [PATCH] improve error reporting in owl load --- build.gradle | 2 +- .../io/opencaesar/owl/load/OwlLoadApp.java | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index d0b072a..2e12d55 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ subprojects { group = 'io.opencaesar.owl' - version = '2.11.0' + version = '2.12.0' ext.versions = [ owl: '5.1.17', diff --git a/owl-load/src/main/java/io/opencaesar/owl/load/OwlLoadApp.java b/owl-load/src/main/java/io/opencaesar/owl/load/OwlLoadApp.java index 9fab263..487542e 100755 --- a/owl-load/src/main/java/io/opencaesar/owl/load/OwlLoadApp.java +++ b/owl-load/src/main/java/io/opencaesar/owl/load/OwlLoadApp.java @@ -323,8 +323,13 @@ private Collection getMappedIris(Collection files, OwlCatalog cata private Collection getLoadedIris(RDFConnection conn) { var iris = new HashSet(); - var rs = conn.query("select ?g { graph ?g { ?o a } }").execSelect(); - rs.forEachRemaining(s -> iris.add(s.getResource("g").getURI())); + try { + var rs = conn.query("select ?g { graph ?g { ?o a } }").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; } @@ -403,8 +408,8 @@ private Set 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)) { @@ -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); } } @@ -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)) { @@ -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); } } @@ -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); } }