From ef3d38a4a5264b4695b8ed5aba853ef3d08195f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Wed, 16 Sep 2020 11:34:15 +0200 Subject: [PATCH] add system property setting for found config path --- .../org/xbib/content/config/ConfigLoader.java | 5 +- .../org/xbib/content/config/package-info.java | 2 +- .../rdf/io/rdfxml/RdfXmlContentParser.java | 48 +++++++++---------- gradle.properties | 8 ++-- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/content-config/src/main/java/org/xbib/content/config/ConfigLoader.java b/content-config/src/main/java/org/xbib/content/config/ConfigLoader.java index 8b47986..8e7ced8 100644 --- a/content-config/src/main/java/org/xbib/content/config/ConfigLoader.java +++ b/content-config/src/main/java/org/xbib/content/config/ConfigLoader.java @@ -59,7 +59,9 @@ public class ConfigLoader { Arrays.asList(fileNamesWithoutSuffix)); } - private Settings.Builder createClasspathSettings(ClassLoader classLoader, String applicationName, String fileNameWithoutSuffix) + private Settings.Builder createClasspathSettings(ClassLoader classLoader, + String applicationName, + String fileNameWithoutSuffix) throws IOException { for (String suffix : List.of(YML, YAML, JSON)) { InputStream inputStream = classLoader.getResourceAsStream(applicationName + '-' + @@ -83,6 +85,7 @@ public class ConfigLoader { logger.info("trying " + path.toString()); if (Files.exists(path)) { logger.info("found path: " + path); + System.setProperty("config.path", path.getParent().toString()); return createSettingsFromStream(Files.newInputStream(path), suffix); } } diff --git a/content-config/src/main/java/org/xbib/content/config/package-info.java b/content-config/src/main/java/org/xbib/content/config/package-info.java index 1519e35..8a294fe 100644 --- a/content-config/src/main/java/org/xbib/content/config/package-info.java +++ b/content-config/src/main/java/org/xbib/content/config/package-info.java @@ -1,4 +1,4 @@ /** * Classes for configurations. */ -package org.xbib.content.config; \ No newline at end of file +package org.xbib.content.config; diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/io/rdfxml/RdfXmlContentParser.java b/content-rdf/src/main/java/org/xbib/content/rdf/io/rdfxml/RdfXmlContentParser.java index c0ed15b..4fcd802 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/io/rdfxml/RdfXmlContentParser.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/io/rdfxml/RdfXmlContentParser.java @@ -370,24 +370,24 @@ public class RdfXmlContentParser implements RdfConst * @param triple a triple * @throws IOException if yield does not work */ - protected void yield(Triple triple) throws IOException { + protected void yieldTriple(Triple triple) throws IOException { if (builder != null) { builder.receive(triple); } } - private void yield(Object s, Object p, Object o) throws IOException { - yield(new DefaultTriple(resource.newSubject(s), resource.newPredicate(p), resource.newObject(o))); + private void yieldTriple(Object s, Object p, Object o) throws IOException { + yieldTriple(new DefaultTriple(resource.newSubject(s), resource.newPredicate(p), resource.newObject(o))); } // produce a (possibly) reified triple - private void yield(Object s, IRI p, Object o, IRI reified) throws IOException { - yield(s, p, o); + private void yieldTriple(Object s, IRI p, Object o, IRI reified) throws IOException { + yieldTriple(s, p, o); if (reified != null) { - yield(reified, RDF_TYPE, RDF_STATEMENT); - yield(reified, RDF_SUBJECT, s); - yield(reified, RDF_PREDICATE, p); - yield(reified, RDF_OBJECT, o); + yieldTriple(reified, RDF_TYPE, RDF_STATEMENT); + yieldTriple(reified, RDF_SUBJECT, s); + yieldTriple(reified, RDF_PREDICATE, p); + yieldTriple(reified, RDF_OBJECT, o); } } @@ -473,7 +473,7 @@ public class RdfXmlContentParser implements RdfConst // we have the subject if (!iri.equals(RDF_DESCRIPTION)) { // this is a typed node, so assert the type - yield(frame.node, RDF_TYPE, iri); + yieldTriple(frame.node, RDF_TYPE, iri); } // now process attribute-specified predicates for (int i = 0; i < attrs.getLength(); i++) { @@ -481,7 +481,7 @@ public class RdfXmlContentParser implements RdfConst String aUri = attrs.getURI(i) + attrs.getLocalName(i); String aVal = attrs.getValue(i); if (!aUri.startsWith(RDF_STRING) && !aQn.startsWith("xml:")) { - yield(frame.node, IRI.create(aUri), aVal); + yieldTriple(frame.node, IRI.create(aUri), aVal); } } // is this node the value of some enclosing predicate? @@ -492,7 +492,7 @@ public class RdfXmlContentParser implements RdfConst ppFrame.collection.add(frame.node); } else { // not a collection // this subject is the value of its enclosing predicate - yield(ancestorSubject(stack), parentPredicate(stack), frame.node); + yieldTriple(ancestorSubject(stack), parentPredicate(stack), frame.node); } } } @@ -515,7 +515,7 @@ public class RdfXmlContentParser implements RdfConst // parse attrs to see if the value of this pred is a uriref IRI object = getObjectNode(stack, attrs); if (object != null) { - yield(ancestorSubject(stack), frame.node, object, frame.reification); + yieldTriple(ancestorSubject(stack), frame.node, object, frame.reification); } else { // this predicate encloses pcdata, prepare to accumulate pcdata = new StringBuilder(); @@ -526,7 +526,7 @@ public class RdfXmlContentParser implements RdfConst switch (parseType) { case "Resource": object = object == null ? blankNode().id() : object; - yield(ancestorSubject(stack), frame.node, object, frame.reification); + yieldTriple(ancestorSubject(stack), frame.node, object, frame.reification); // perform surgery on the current frame frame.node = object; frame.isSubject = true; @@ -562,13 +562,13 @@ public class RdfXmlContentParser implements RdfConst && !aQn.startsWith("xml:")) { if (object == null) { object = blankNode().id(); - yield(ancestorSubject(stack), frame.node, object); + yieldTriple(ancestorSubject(stack), frame.node, object); } if (aUri.equals(RDF_TYPE)) { - yield(object, RDF_TYPE, aVal); + yieldTriple(object, RDF_TYPE, aVal); } else { Literal value = withLanguageTag(new DefaultLiteral(aVal), stack); - yield(object, aUri, value); + yieldTriple(object, aUri, value); } } } @@ -601,35 +601,35 @@ public class RdfXmlContentParser implements RdfConst // this is a predicate closing if (xmlLiteral != null) { // it was an XMLLiteral Literal value = new DefaultLiteral(xmlLiteral.toString()).type(RDF_XMLLITERAL); - yield(ancestorSubject(stack), parentPredicate(stack), value); + yieldTriple(ancestorSubject(stack), parentPredicate(stack), value); xmlLiteral = null; } else if (pcdata != null) { // we have an RDF literal IRI u = ppFrame.datatype == null ? null : IRI.create(ppFrame.datatype); Literal value = withLanguageTag(new DefaultLiteral(pcdata.toString()).type(u), stack); // deal with reification IRI reification = ppFrame.reification; - yield(ancestorSubject(stack), ppFrame.node, value, reification); + yieldTriple(ancestorSubject(stack), ppFrame.node, value, reification); // no longer collect pcdata pcdata = null; } else if (ppFrame.isCollection) { // deal with collections if (ppFrame.collection.isEmpty()) { // in this case, the value of this property is rdf:nil - yield(ppFrame.collectionHead.subject(), + yieldTriple(ppFrame.collectionHead.subject(), ppFrame.collectionHead.predicate(), resource.newObject(RDF_NIL)); } else { - yield(ppFrame.collectionHead); + yieldTriple(ppFrame.collectionHead); Object prevNode = null; Object node = ppFrame.collectionHead.object(); for (IRI item : ppFrame.collection) { if (prevNode != null) { - yield(prevNode, RDF_REST, node); + yieldTriple(prevNode, RDF_REST, node); } - yield(node, RDF_FIRST, item); + yieldTriple(node, RDF_FIRST, item); prevNode = node; node = blankNode().id(); } - yield(prevNode, RDF_REST, RDF_NIL); + yieldTriple(prevNode, RDF_REST, RDF_NIL); } } } diff --git a/gradle.properties b/gradle.properties index a9b2e21..fdcf5d2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,13 @@ group = org.xbib name = content -version = 2.5.0 +version = 2.5.1 gradle.wrapper.version = 6.6.1 xbib.net.version = 2.1.0 -jackson.version = 2.11.1 -jackson.databind.version = 2.11.1 +jackson.version = 2.11.2 +jackson.databind.version = 2.11.2 woodstox.version = 6.2.1 -snakeyaml.version = 1.26 +snakeyaml.version = 1.27 xbib-datastructures-tiny.version = 0.0.1 mockito.version = 3.3.3 asciidoclet.version = 1.5.6