Skip to content

Commit

Permalink
SNAPSHOT bump
Browse files Browse the repository at this point in the history
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
  • Loading branch information
namedgraph committed Oct 11, 2023
1 parent 1a17545 commit a5b5b75
Show file tree
Hide file tree
Showing 25 changed files with 321 additions and 292 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion http-tests/admin/model/create-property-constraint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
16 changes: 11 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.atomgraph</groupId>
<artifactId>linkeddatahub</artifactId>
<version>4.0.9-SNAPSHOT</version>
<version>4.1.0-SNAPSHOT</version>
<packaging>${packaging.type}</packaging>

<name>AtomGraph LinkedDataHub</name>
Expand Down Expand Up @@ -53,6 +53,12 @@
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>apache-repo-releases</id>
Expand Down Expand Up @@ -129,18 +135,18 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>server</artifactId>
<version>4.1.3</version>
<version>4.1.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>client</artifactId>
<version>4.0.5</version>
<version>4.0.7-SNAPSHOT</version>
<classifier>classes</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>client</artifactId>
<version>4.0.5</version>
<version>4.0.7-SNAPSHOT</version>
<type>war</type>
</dependency>
<!-- required by jsonld-java - version same as Jersey's HTTP Client -->
Expand Down Expand Up @@ -210,7 +216,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.0</version>
<version>3.10.1</version>
<configuration>
<source>17</source>
<target>17</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
}

Expand Down Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public abstract class XSLTWriterBase extends com.atomgraph.client.writer.XSLTWri
private static final Set<String> 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
{
Expand Down Expand Up @@ -121,11 +122,10 @@ public <T extends XdmValue> Map<QName, XdmValue> getParameters(MultivaluedMap<St

try
{
params.put(new QName("ldh", LDH.absolutePath.getNameSpace(), LDH.absolutePath.getLocalName()), new XdmAtomicValue(getAbsolutePath()));
params.put(new QName("ldh", LDH.requestUri.getNameSpace(), LDH.requestUri.getLocalName()), new XdmAtomicValue(getRequestURI()));
if (getURI() != null) params.put(new QName("ac", AC.uri.getNameSpace(), AC.uri.getLocalName()), new XdmAtomicValue(getURI()));
else params.put(new QName("ac", AC.uri.getNameSpace(), AC.uri.getLocalName()), new XdmAtomicValue(getAbsolutePath()));

else params.put(new QName("ac", AC.uri.getNameSpace(), AC.uri.getLocalName()), new XdmAtomicValue(getRequestURI()));
com.atomgraph.linkeddatahub.apps.model.Application app = getApplication().get();
if (log.isDebugEnabled()) log.debug("Passing $lapp:Application to XSLT: <{}>", app);
params.put(new QName("ldt", LDT.base.getNameSpace(), LDT.base.getLocalName()), new XdmAtomicValue(app.getBaseURI()));
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -319,12 +333,6 @@ public jakarta.inject.Provider<DataManager> getDataManagerProvider()
{
return dataManager;
}

@Override
public URI getURI() throws URISyntaxException
{
return getURIParam(getUriInfo(), AC.uri.getLocalName());
}

@Override
public String getQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ exclude-result-prefixes="#all">
<xsl:template match="rdf:RDF[$foaf:Agent]" mode="bs2:Create" priority="1">
<xsl:param name="classes" as="element()*"/>
<xsl:param name="create-graph" select="false()" as="xs:boolean"/>
<xsl:param name="base-uri" select="base-uri()" as="xs:anyURI"/>

<div class="btn-group pull-left">
<button type="button" title="{ac:label(key('resources', 'create-instance-title', document('../translations.rdf')))}">
Expand All @@ -74,6 +75,7 @@ exclude-result-prefixes="#all">

<ul class="dropdown-menu">
<xsl:apply-templates select="$classes" mode="bs2:ConstructorListItem">
<xsl:with-param name="base-uri" select="$base-uri" tunnel="yes"/>
<xsl:with-param name="create-graph" select="$create-graph"/>
<xsl:sort select="ac:label(.)"/>
</xsl:apply-templates>
Expand Down Expand Up @@ -137,8 +139,8 @@ exclude-result-prefixes="#all">
</xsl:template>

<!-- add sp:Construct to the creatable class list below the form. Needs to pass parameters from signup.xsl and request-access.xsl!!! -->
<xsl:template match="rdf:RDF[$ac:method = 'GET']" mode="bs2:RowForm" use-when="system-property('xsl:product-name') = 'SAXON'">
<xsl:param name="action" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ac:build-uri(ac:uri(), map{ '_method': 'PUT', 'mode': for $mode in $ac:mode return string($mode) }))" as="xs:anyURI"/>
<xsl:template match="rdf:RDF[base-uri()][$ac:method = 'GET']" mode="bs2:RowForm" use-when="system-property('xsl:product-name') = 'SAXON'">
<xsl:param name="action" select="ldh:href($ldt:base, ldh:absolute-path(base-uri()), map{}, ac:build-uri(ldh:absolute-path(base-uri()), map{ '_method': 'PUT', 'mode': for $mode in $ac:mode return string($mode) }))" as="xs:anyURI"/>
<xsl:param name="enctype" select="'multipart/form-data'" as="xs:string?"/>
<xsl:param name="create-resource" select="true()" as="xs:boolean"/>
<!-- TO-DO: generate ontology classes from the OWL vocabulary -->
Expand Down
Loading

0 comments on commit a5b5b75

Please sign in to comment.