From a5b5b75d023762e0576e98df77dc54624130f005 Mon Sep 17 00:00:00 2001 From: Martynas Date: Mon, 2 Oct 2023 09:41:40 +0200 Subject: [PATCH] SNAPSHOT bump Web-Client SNAPSHOT bump Server SNAPSHOT bump Replaced `ac:uri()`/`ldh:href()` usages with `base-uri()`/`ldh:base-uri(.)` where possible. Should be possible to remove `ldh:base-uri` when SaxonJS 2.6 is out and correctly implements `base-uri()` client-side. `XsltExecutableFilter` sets `systemId` (base URI) only on successful documents, not on error responses --- docker-compose.yml | 2 +- .../admin/model/create-property-constraint.sh | 2 +- pom.xml | 16 +++- .../filter/response/XsltExecutableFilter.java | 36 ++++++++ .../linkeddatahub/writer/XSLTWriterBase.java | 26 ++++-- .../xsl/bootstrap/2.3.2/admin/layout.xsl | 6 +- .../bootstrap/2.3.2/admin/request-access.xsl | 48 +++++----- .../xsl/bootstrap/2.3.2/admin/signup.xsl | 54 +++++------ .../xsl/bootstrap/2.3.2/client/chart.xsl | 8 +- .../bootstrap/2.3.2/client/constructor.xsl | 6 +- .../xsl/bootstrap/2.3.2/client/container.xsl | 8 +- .../xsl/bootstrap/2.3.2/client/content.xsl | 54 ++++++----- .../xsl/bootstrap/2.3.2/client/form.xsl | 22 ++--- .../xsl/bootstrap/2.3.2/client/functions.xsl | 24 +++-- .../xsl/bootstrap/2.3.2/client/map.xsl | 6 +- .../xsl/bootstrap/2.3.2/client/modal.xsl | 20 ++-- .../xsl/bootstrap/2.3.2/client/navigation.xsl | 4 +- .../xsl/bootstrap/2.3.2/client/sparql.xsl | 10 +- .../xsl/bootstrap/2.3.2/document.xsl | 31 ++++--- .../xsl/bootstrap/2.3.2/imports/default.xsl | 29 ++++-- .../xsl/bootstrap/2.3.2/imports/rdf.xsl | 2 +- .../xsl/bootstrap/2.3.2/imports/sioc.xsl | 3 +- .../xsl/bootstrap/2.3.2/layout.xsl | 92 +++++++------------ .../xsl/bootstrap/2.3.2/resource.xsl | 31 +++---- .../atomgraph/linkeddatahub/xsl/client.xsl | 73 +++++---------- 25 files changed, 321 insertions(+), 292 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index de4c8df2f..3c89f19cb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -97,7 +97,7 @@ services: - VARNISH_HTTP_PORT=6060 - BACKEND_HOST=linkeddatahub - BACKEND_PORT=7070 - - CLIENT_HOST=linkeddatahub + - CLIENT_HOST=localhost - VARNISH_TTL=86400 - VARNISH_SIZE=1G entrypoint: /bin/sh -c "cp /etc/varnish/default.vcl.template /etc/varnish/default.vcl && sed -i 's|$${BACKEND_HOST}|'"$$BACKEND_HOST"'|g' /etc/varnish/default.vcl && sed -i 's|$${BACKEND_PORT}|'"$$BACKEND_PORT"'|g' /etc/varnish/default.vcl && sed -i 's|$${CLIENT_HOST}|'"$$CLIENT_HOST"'|g' /etc/varnish/default.vcl && /usr/local/bin/docker-varnish-entrypoint" diff --git a/http-tests/admin/model/create-property-constraint.sh b/http-tests/admin/model/create-property-constraint.sh index 77e6eb483..d2164e260 100755 --- a/http-tests/admin/model/create-property-constraint.sh +++ b/http-tests/admin/model/create-property-constraint.sh @@ -60,7 +60,7 @@ curl -k -f -s -N \ "$namespace_doc" \ | grep "$constraint" > /dev/null -# check that creating an instance of the class without sioc:content returns Bad Request due to missing sioc:content +# check that creating an instance of the class without sioc:content returns 422 Unprocessable Entity due to missing sioc:content pushd . > /dev/null && cd "$SCRIPT_ROOT" diff --git a/pom.xml b/pom.xml index 4c46e736c..daa017e23 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.atomgraph linkeddatahub - 4.0.9-SNAPSHOT + 4.1.0-SNAPSHOT ${packaging.type} AtomGraph LinkedDataHub @@ -53,6 +53,12 @@ ossrh https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + apache-repo-releases @@ -129,18 +135,18 @@ ${project.groupId} server - 4.1.3 + 4.1.5-SNAPSHOT ${project.groupId} client - 4.0.5 + 4.0.7-SNAPSHOT classes ${project.groupId} client - 4.0.5 + 4.0.7-SNAPSHOT war @@ -210,7 +216,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.0 + 3.10.1 17 17 diff --git a/src/main/java/com/atomgraph/linkeddatahub/server/filter/response/XsltExecutableFilter.java b/src/main/java/com/atomgraph/linkeddatahub/server/filter/response/XsltExecutableFilter.java index 25391c5f0..920182755 100644 --- a/src/main/java/com/atomgraph/linkeddatahub/server/filter/response/XsltExecutableFilter.java +++ b/src/main/java/com/atomgraph/linkeddatahub/server/filter/response/XsltExecutableFilter.java @@ -18,6 +18,7 @@ import com.atomgraph.client.vocabulary.AC; import com.atomgraph.linkeddatahub.MediaType; +import static com.atomgraph.linkeddatahub.writer.XSLTWriterBase.SYSTEM_ID_PROPERTY; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -36,6 +37,7 @@ import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.UriInfo; +import java.net.URISyntaxException; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import net.sf.saxon.s9api.SaxonApiException; @@ -72,6 +74,24 @@ public void filter(ContainerRequestContext req, ContainerResponseContext resp) t if (stylesheet != null) req.setProperty(AC.stylesheet.getURI(), getXsltExecutable(stylesheet)); else req.setProperty(AC.stylesheet.getURI(), getSystem().getXsltExecutable()); + + // systemId (base URI) is only set on successful documents, not on error responses + if (resp.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) + { + final URI systemId; + + try + { + if (getURI() != null) systemId = getURI(); + else systemId = req.getUriInfo().getRequestUri(); + + req.setProperty(SYSTEM_ID_PROPERTY, systemId); + } + catch (URISyntaxException ex) + { + throw new InternalServerErrorException(ex); + } + } } } @@ -178,6 +198,22 @@ public Source getSource(String url) throws IOException return null; } + public URI getURI() throws URISyntaxException + { + return getURIParam(getUriInfo(), AC.uri.getLocalName()); + } + + public URI getURIParam(UriInfo uriInfo, String name) throws URISyntaxException + { + if (uriInfo == null) throw new IllegalArgumentException("UriInfo cannot be null"); + if (name == null) throw new IllegalArgumentException("String cannot be null"); + + if (uriInfo.getQueryParameters().containsKey(name)) + return new URI(uriInfo.getQueryParameters().getFirst(name)); + + return null; + } + /** * Returns HTTP client. * diff --git a/src/main/java/com/atomgraph/linkeddatahub/writer/XSLTWriterBase.java b/src/main/java/com/atomgraph/linkeddatahub/writer/XSLTWriterBase.java index 4f0632e9c..3b11070e3 100644 --- a/src/main/java/com/atomgraph/linkeddatahub/writer/XSLTWriterBase.java +++ b/src/main/java/com/atomgraph/linkeddatahub/writer/XSLTWriterBase.java @@ -80,6 +80,7 @@ public abstract class XSLTWriterBase extends com.atomgraph.client.writer.XSLTWri private static final Set NAMESPACES; /** The relative URL of the RDF file with localized labels */ public static final String TRANSLATIONS_PATH = "static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf"; + public static final String SYSTEM_ID_PROPERTY = "com.atomgraph.linkeddatahub.writer.XSLTWriterBase.systemId"; static { @@ -121,11 +122,10 @@ public Map getParameters(MultivaluedMap", app); params.put(new QName("ldt", LDT.base.getNameSpace(), LDT.base.getLocalName()), new XdmAtomicValue(app.getBaseURI())); @@ -278,6 +278,20 @@ public StreamSource getSource(Model model) throws IOException } } + /** + * Returns the base URI of the main RDF/XML document being transformed. + * + * @return base URL + */ + @Override + public String getSystemId() + { + if (getContainerRequestContext().hasProperty(SYSTEM_ID_PROPERTY)) + return getContainerRequestContext().getProperty(SYSTEM_ID_PROPERTY).toString(); + + return null; + } + /** * Returns system application. * @@ -319,12 +333,6 @@ public jakarta.inject.Provider getDataManagerProvider() { return dataManager; } - - @Override - public URI getURI() throws URISyntaxException - { - return getURIParam(getUriInfo(), AC.uri.getLocalName()); - } @Override public String getQuery() diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl index 6e061467d..32d7d8344 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl @@ -59,6 +59,7 @@ exclude-result-prefixes="#all"> +