This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
commit 9d2b004a0799e9e0b3505b84c07d81e0b1c9f5ad Author: Andy Seaborne <[email protected]> AuthorDate: Wed Apr 17 19:18:13 2024 +0100 Check for web.xml --- .../apache/jena/sparql/AbstractTestAdditional.java | 22 +++++--- .../apache/jena/fuseki/main/TestConfigFile.java | 16 +++--- .../main/examples/ExFuseki_05_CustomFunction.java | 13 ++--- .../apache/jena/fuseki/cmd/JettyFusekiWebapp.java | 11 +++- .../main/java/org/apache/jena/shacl/lib/ShLib.java | 25 +++++---- .../java/org/apache/jena/shacl/validation/VR.java | 64 +++++++++++----------- 6 files changed, 81 insertions(+), 70 deletions(-) diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/AbstractTestAdditional.java b/jena-arq/src/test/java/org/apache/jena/sparql/AbstractTestAdditional.java index 0ad7e29be1..6e558d8364 100644 --- a/jena-arq/src/test/java/org/apache/jena/sparql/AbstractTestAdditional.java +++ b/jena-arq/src/test/java/org/apache/jena/sparql/AbstractTestAdditional.java @@ -43,17 +43,21 @@ public abstract class AbstractTestAdditional { /** Check substitution into patterns. */ @Test public void substitute_1() { Dataset dataset = dataset(); - String resultsStr = StrUtils.strjoinNL("(resultset (?s ?p ?o)" - , "(row (?s :s1) (?p :p) (?o :o))" - ,")" ); + String resultsStr = """ + (resultset (?s ?p ?o) + (row (?s :s1) (?p :p) (?o :o)) + ) + """; RowSetRewindable expected = SSE.parseRowSet(resultsStr).rewindable(); Txn.executeWrite(dataset, ()->{ - String data = StrUtils.strjoinNL("(dataset" - ," (:g1 :s1 :p :o)" - ," (:g1 :s2 :p :o)" - ," (:g2 :s1 :p :o)" - ," (:g2 :s2 :p :o)" - ,")"); + String data = """ + (dataset + (:g1 :s1 :p :o) + (:g1 :s2 :p :o) + (:g2 :s1 :p :o) + (:g2 :s2 :p :o) + ) + """; DatasetGraph dsg = SSE.parseDatasetGraph(data); dataset.asDatasetGraph().addAll(dsg); String qs = PREFIXES+"SELECT * { VALUES ?s { :s1 } GRAPH <"+Quad.unionGraph.getURI()+"> { ?s ?p ?o } }"; diff --git a/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/TestConfigFile.java b/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/TestConfigFile.java index a1d524ecba..bb891b7916 100644 --- a/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/TestConfigFile.java +++ b/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/TestConfigFile.java @@ -25,7 +25,6 @@ import static org.junit.Assert.*; import java.io.IOException; import org.apache.jena.atlas.io.IO; -import org.apache.jena.atlas.lib.StrUtils; import org.apache.jena.atlas.web.TypedInputStream; import org.apache.jena.base.Sys; import org.apache.jena.graph.Graph; @@ -42,13 +41,14 @@ public class TestConfigFile { private static final String DIR = "testing/Config/"; - private static final String PREFIXES = StrUtils.strjoinNL - ("PREFIX afn: <http://jena.apache.org/ARQ/function#>" - ,"PREFIX fuseki: <http://jena.apache.org/fuseki#>" - ,"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" - ,"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>" - , "" - ); + private static final String PREFIXES = """ + PREFIX afn: <http://jena.apache.org/ARQ/function#> + PREFIX fuseki: <http://jena.apache.org/fuseki#> + PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> + PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + + """; + private static RDFConnection namedServices(String baseURL) { return RDFConnectionRemote.newBuilder() diff --git a/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples/ExFuseki_05_CustomFunction.java b/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples/ExFuseki_05_CustomFunction.java index a1d16d072c..3b3134c387 100644 --- a/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples/ExFuseki_05_CustomFunction.java +++ b/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples/ExFuseki_05_CustomFunction.java @@ -18,7 +18,6 @@ package org.apache.jena.fuseki.main.examples; -import org.apache.jena.atlas.lib.StrUtils; import org.apache.jena.atlas.web.WebLib; import org.apache.jena.fuseki.main.FusekiServer; import org.apache.jena.fuseki.system.FusekiLogging; @@ -69,12 +68,12 @@ public class ExFuseki_05_CustomFunction { server.start(); // -- Call the server - String queryString = StrUtils.strjoinNL( - "SELECT * { " - , " VALUES ?Z { 123 'abc'}" - , " BIND (<http://my/num>(?Z) AS ?X )" - ,"}" - ); + String queryString = """ + SELECT * { + VALUES ?Z { 123 'abc'} + BIND (<http://my/num>(?Z) AS ?X ) + } + """; try { String url = "http://localhost:"+PORT+"/ds"; diff --git a/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/cmd/JettyFusekiWebapp.java b/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/cmd/JettyFusekiWebapp.java index 825359e1d0..02578d5a3a 100644 --- a/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/cmd/JettyFusekiWebapp.java +++ b/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/cmd/JettyFusekiWebapp.java @@ -21,6 +21,8 @@ package org.apache.jena.fuseki.cmd; import static java.lang.String.format; import static org.apache.jena.fuseki.Fuseki.serverLog; +import java.nio.file.Path; + import jakarta.servlet.ServletContext; import org.apache.jena.atlas.lib.DateTimeUtils; import org.apache.jena.atlas.lib.FileOps; @@ -183,9 +185,14 @@ public class JettyFusekiWebapp { throw new FusekiException("Failed to start"); } - webapp.setDescriptor(baseResource+"/WEB-INF/web.xml"); + String web_xml = baseResource+"/WEB-INF/web.xml"; + if ( ! FileOps.exists(web_xml) ) + Fuseki.serverLog.warn("Can't find WEB-INF/web.xml in "+baseResource); + webapp.setDescriptor(web_xml); webapp.setContextPath(contextPath); - webapp.getContext().getServletContextHandler().setBaseResourceAsString(baseResource); + // Avoid BaseResource aliasing warnings. + Path absBaseResource = Path.of(baseResource).toAbsolutePath(); + webapp.getContext().getServletContextHandler().setBaseResourceAsPath(absBaseResource); //-- Jetty setup for the ServletContext logger. // The name of the Jetty-allocated slf4j/log4j logger is diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/lib/ShLib.java b/jena-shacl/src/main/java/org/apache/jena/shacl/lib/ShLib.java index 117f77eb8b..1df2840ddb 100644 --- a/jena-shacl/src/main/java/org/apache/jena/shacl/lib/ShLib.java +++ b/jena-shacl/src/main/java/org/apache/jena/shacl/lib/ShLib.java @@ -150,18 +150,19 @@ public class ShLib { String qs = StrUtils.strjoinNL (PREFIXES - ,"SELECT * {" - //, " [ a sh:ValidationReport ; sh:result ?R ] - , " [] sh:result ?R ." - , " ?R" - , " sh:focusNode ?focusNode ;" - , " sh:resultMessage ?message ;" - , " sh:resultSeverity ?severity ; " - , " ." - , " OPTIONAL { ?R sh:sourceConstraintComponent ?component }" - , " OPTIONAL { ?R sh:sourceShape ?sourceShape }" - , " OPTIONAL { ?R sh:resultPath ?path}" - ,"}"); + ,""" + SELECT * { + #[ a sh:ValidationReport ; sh:result ?R ] + [] sh:result ?R . + ?R sh:focusNode ?focusNode ; + sh:resultMessage ?message ; + sh:resultSeverity ?severity ; + . + OPTIONAL { ?R sh:sourceConstraintComponent ?component } + OPTIONAL { ?R sh:sourceShape ?sourceShape } + OPTIONAL { ?R sh:resultPath ?path} + } + """); try ( QueryExecution qExec = QueryExecutionFactory.create(qs, report.getModel()) ) { ResultSet rs = qExec.execSelect(); if ( ! rs.hasNext() ) { diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/validation/VR.java b/jena-shacl/src/main/java/org/apache/jena/shacl/validation/VR.java index b1ce002654..e130b071fc 100644 --- a/jena-shacl/src/main/java/org/apache/jena/shacl/validation/VR.java +++ b/jena-shacl/src/main/java/org/apache/jena/shacl/validation/VR.java @@ -107,38 +107,38 @@ public class VR { private static String qs = StrUtils.strjoinNL - (PREFIXES - ,"CONSTRUCT {" - , " ?X a sh:ValidationReport ;" - , " sh:conforms ?conforms ;" - , " sh:result ?R" - , " ." - , " ?R" - , " sh:focusNode ?focusNode ;" - , " sh:resultMessage ?message ;" - , " sh:resultSeverity ?severity ; " - , " sh:sourceConstraint ?constraint ;" - , " sh:sourceConstraintComponent ?component ;" - , " sh:sourceShape ?sourceShape ;" - , " sh:resultPath ?path ;" - , " sh:value ?value ;" - , "." - ,"}" - ," WHERE {" - , " ?X a sh:ValidationReport ;" - , " sh:result ?R" - , " OPTIONAL { ?X sh:conforms ?conforms }" - , " ?R" - , " sh:focusNode ?focusNode ;" - , " sh:resultSeverity ?severity ; " - , " ." - , " OPTIONAL { ?R sh:resultMessage ?message }" - , " OPTIONAL { ?R sh:sourceConstraintComponent ?component }" - , " OPTIONAL { ?R sh:sourceConstraint ?constraint }" - , " OPTIONAL { ?R sh:sourceShape ?sourceShape }" - , " OPTIONAL { ?R sh:resultPath ?path }" - , " OPTIONAL { ?R sh:value ?value }" - ,"}"); + (PREFIXES, + """ + CONSTRUCT { + ?X a sh:ValidationReport ; + sh:conforms ?conforms ; + sh:result ?R + . + ?R sh:focusNode ?focusNode ; + sh:resultMessage ?message ; + sh:resultSeverity ?severity ; + sh:sourceConstraint ?constraint ; + sh:sourceConstraintComponent ?component ; + sh:sourceShape ?sourceShape ; + sh:resultPath ?path ; + sh:value ?value ; + . + } + WHERE { + ?X a sh:ValidationReport ; + sh:result ?R + OPTIONAL { ?X sh:conforms ?conforms } + ?R sh:focusNode ?focusNode ; + sh:resultSeverity ?severity ; + . + OPTIONAL { ?R sh:resultMessage ?message } + OPTIONAL { ?R sh:sourceConstraintComponent ?component } + OPTIONAL { ?R sh:sourceConstraint ?constraint } + OPTIONAL { ?R sh:sourceShape ?sourceShape } + OPTIONAL { ?R sh:resultPath ?path } + OPTIONAL { ?R sh:value ?value } + } + """); private static Query query = QueryFactory.create(qs); public static Model strip(Model model) {
