Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.atomgraph.linkeddatahub.apps.model.Application;
import com.atomgraph.linkeddatahub.apps.model.Dataset;
import com.atomgraph.linkeddatahub.model.auth.Agent;
import com.atomgraph.linkeddatahub.server.model.impl.Dispatcher;
import com.atomgraph.linkeddatahub.server.security.AuthorizationContext;
import com.atomgraph.linkeddatahub.vocabulary.ACL;
import java.io.IOException;
Expand Down Expand Up @@ -77,27 +78,17 @@ public void filter(ContainerRequestContext request, ContainerResponseContext res
List<Object> linkValues = response.getHeaders().get(HttpHeaders.LINK);
List<Link> links = parseLinkHeaderValues(linkValues);

// check whether Link rel=ldt:base is not already set. Link headers might be forwarded by ProxyResourceBase
if (getLinksByRel(links, LDT.base.getURI()).isEmpty())
{
// add Link rel=ldt:base
response.getHeaders().add(HttpHeaders.LINK, new Link(getApplication().getBaseURI(), LDT.base.getURI(), null));
if (getLinksByRel(links, SD.endpoint.getURI()).isEmpty())
// add Link rel=sd:endpoint.
// TO-DO: The external SPARQL endpoint URL is different from the internal one currently specified as sd:endpoint in the context dataset
response.getHeaders().add(HttpHeaders.LINK, new Link(request.getUriInfo().getBaseUriBuilder().path("sparql").build(), SD.endpoint.getURI(), null));
// add Link rel=ldt:ontology, if the ontology URI is specified
if (getApplication().getOntology() != null)
response.getHeaders().add(HttpHeaders.LINK, new Link(URI.create(getApplication().getOntology().getURI()), LDT.ontology.getURI(), null));
// add Link rel=ac:stylesheet, if the stylesheet URI is specified
if (getApplication().getStylesheet() != null)
response.getHeaders().add(HttpHeaders.LINK, new Link(URI.create(getApplication().getStylesheet().getURI()), AC.stylesheet.getURI(), null));
}
else
{
// add Link rel=sd:endpoint.
if (getLinksByRel(links, SD.endpoint.getURI()).isEmpty() && getDataset().isPresent() && getDataset().get().getService() != null)
response.getHeaders().add(HttpHeaders.LINK, new Link(URI.create(getDataset().get().getService().getSPARQLEndpoint().getURI()), SD.endpoint.getURI(), null));
}
response.getHeaders().add(HttpHeaders.LINK, new Link(request.getUriInfo().getBaseUriBuilder().path(Dispatcher.class, "getSPARQLEndpoint").build(), SD.endpoint.getURI(), null));

// add Link rel=ldt:ontology, if the ontology URI is specified
if (getApplication().getOntology() != null)
response.getHeaders().add(HttpHeaders.LINK, new Link(URI.create(getApplication().getOntology().getURI()), LDT.ontology.getURI(), null));
// add Link rel=ac:stylesheet, if the stylesheet URI is specified
if (getApplication().getStylesheet() != null)
response.getHeaders().add(HttpHeaders.LINK, new Link(URI.create(getApplication().getStylesheet().getURI()), AC.stylesheet.getURI(), null));

if (response.getHeaders().get(HttpHeaders.LINK) != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exclude-result-prefixes="#all">

<xsl:template match="*[rdf:type/@rdf:resource = '&lacl;AuthorizationRequest']" priority="1">
<xsl:param name="method" select="'post'" as="xs:string"/>
<xsl:param name="action" select="ldh:href(resolve-uri(ac:uuid() || '/', resolve-uri('acl/authorizations/', $ldt:base)), map{ '_method': 'PUT' })" as="xs:anyURI"/> <!-- create new authorization document -->
<xsl:param name="action" select="ldh:href(resolve-uri(ac:uuid() || '/', resolve-uri('acl/authorizations/', $ldt:base)), map{ '_method': 'PUT' })" as="xs:anyURI" tunnel="yes"/> <!-- create new authorization document -->
<xsl:param name="id" select="concat('form-', generate-id())" as="xs:string?"/>
<xsl:param name="class" select="'form-horizontal'" as="xs:string?"/>
<xsl:param name="accept-charset" select="'UTF-8'" as="xs:string?"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ exclude-result-prefixes="#all">
<xsl:param name="id" select="concat('form-', generate-id())" as="xs:string?"/>
<xsl:param name="class" select="'row-fluid'" as="xs:string?"/>
<xsl:param name="method" select="'patch'" as="xs:string"/>
<xsl:param name="action" select="ldh:href(ac:build-uri(ac:absolute-path(ldh:base-uri(.)), map{ '_method': 'PUT' }))" as="xs:anyURI"/>
<xsl:param name="action" select="ldh:href(ac:build-uri(ac:absolute-path(ldh:base-uri(.)), map{ '_method': 'PUT' }))" as="xs:anyURI" tunnel="yes"/>
<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 All @@ -114,7 +114,7 @@ exclude-result-prefixes="#all">
<xsl:with-param name="id" select="$id"/>
<xsl:with-param name="class" select="$class"/>
<xsl:with-param name="method" select="$method"/>
<xsl:with-param name="action" select="$action"/>
<xsl:with-param name="action" select="$action" tunnel="yes"/>
<xsl:with-param name="enctype" select="$enctype"/>
<xsl:with-param name="create-resource" select="$create-resource"/>
<xsl:with-param name="classes" select="$classes"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ exclude-result-prefixes="#all">
<xsl:apply-templates select="ldh:construct(map{ xs:anyURI('&foaf;Person'): $constructors//srx:result[srx:binding[@name = 'Type'] = '&foaf;Person']/srx:binding[@name = 'construct']/srx:literal/string() })" mode="bs2:RowForm">
<xsl:with-param name="id" select="'form-signup'"/>
<xsl:with-param name="method" select="'post'"/> <!-- don't use PATCH which is the default -->
<xsl:with-param name="action" select="ac:absolute-path(base-uri($main-doc))"/>
<xsl:with-param name="action" select="ac:absolute-path(base-uri($main-doc))" tunnel="yes"/>
<xsl:with-param name="enctype" select="()"/> <!-- don't use 'multipart/form-data' which is the default -->
<xsl:with-param name="create-resource" select="false()"/>
<xsl:with-param name="base-uri" select="ac:absolute-path(base-uri($main-doc))" tunnel="yes"/> <!-- base-uri() is empty on constructed documents -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ exclude-result-prefixes="#all"
<xsl:apply-templates select="$constructed-doc" mode="bs2:RowForm">
<xsl:with-param name="about" select="()"/> <!-- don't set @about on the container until after the resource is saved -->
<xsl:with-param name="method" select="$method"/>
<xsl:with-param name="action" select="ldh:href($doc-uri, map{})" as="xs:anyURI"/>
<xsl:with-param name="action" select="ldh:href($doc-uri, map{})" as="xs:anyURI" tunnel="yes"/>
<xsl:with-param name="type-metadata" select="$type-metadata" tunnel="yes"/>
<xsl:with-param name="property-metadata" select="$property-metadata" tunnel="yes"/>
<xsl:with-param name="constructor" select="$constructed-doc" tunnel="yes"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ exclude-result-prefixes="#all"

<xsl:template match="*[@typeof = ('&sp;Ask', '&sp;Select', '&sp;Describe', '&sp;Construct')][descendant::*[@property = '&sp;text'][pre/text()]]" mode="ldh:RenderRow" as="function(item()?) as map(*)" priority="2 "> <!-- prioritize above block.xsl -->
<xsl:param name="block" select="ancestor-or-self::div[contains-token(@class, 'block')][1]" as="element()"/>
<xsl:param name="about" select="$block/@about" as="xs:anyURI"/>
<xsl:param name="block-uri" select="$about" as="xs:anyURI"/>
<xsl:param name="container" select="." as="element()"/>
<xsl:param name="graph" select="descendant::*[@property = '&ldh;graph']/@resource" as="xs:anyURI?"/>
<xsl:param name="mode" select="descendant::*[@property = '&ac;mode']/@resource" as="xs:anyURI?"/>
Expand Down Expand Up @@ -513,7 +511,7 @@ exclude-result-prefixes="#all"

<ixsl:set-style name="cursor" select="'progress'" object="ixsl:page()//body"/>

<!-- abort the previous request, if any -->
<!-- abort the previous request, if any
<xsl:if test="ixsl:contains(ixsl:get(ixsl:window(), 'LinkedDataHub'), 'request')">
<xsl:message>Aborting HTTP request that has already been sent</xsl:message>
<xsl:sequence select="ixsl:call(ixsl:get(ixsl:window(), 'LinkedDataHub.request'), 'abort', [])"/>
Expand All @@ -527,8 +525,22 @@ exclude-result-prefixes="#all"
</ixsl:schedule-action>
</xsl:variable>

<!-- store the new request object -->
<ixsl:set-property name="request" select="$request" object="ixsl:get(ixsl:window(), 'LinkedDataHub')"/>
store the new request object
<ixsl:set-property name="request" select="$request" object="ixsl:get(ixsl:window(), 'LinkedDataHub')"/>-->

<xsl:variable name="request" select="map{ 'method': 'GET', 'href': $href, 'headers': map{ 'Accept': 'application/xhtml+xml' } }" as="map(*)"/>
<xsl:variable name="context" select="
map{
'request': $request,
'href': $href,
'push-state': true()
}" as="map(*)"/>
<ixsl:promise select="
ixsl:http-request($context('request'))
=> ixsl:then(ldh:rethread-response($context, ?))
=> ixsl:then(ldh:handle-response#1)
=> ixsl:then(ldh:xhtml-document-loaded#1)
" on-failure="ldh:promise-failure#1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ WHERE
<xsl:template match="div[@about]//button[contains-token(@class, 'btn-edit')][not(contains-token(@class, 'disabled'))]" mode="ixsl:onclick">
<xsl:param name="block" select="ancestor::div[contains-token(@class, 'block')][1]" as="element()"/>
<xsl:param name="about" select="$block/@about" as="xs:anyURI"/>
<!-- <xsl:param name="graph" as="xs:anyURI?"/>-->

<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
<ixsl:set-style name="cursor" select="'progress'" object="ixsl:page()//body"/>
Expand Down Expand Up @@ -328,7 +327,7 @@ WHERE
<xsl:variable name="block" select="id($block-id, ixsl:page())" as="element()"/>

<!-- if the URI is external, dereference it through the proxy -->
<xsl:variable name="request-uri" select="ldh:href(ac:absolute-path(ldh:base-uri(.)), map{})" as="xs:anyURI"/>
<xsl:variable name="request-uri" select="ldh:href($about)" as="xs:anyURI"/>
<xsl:variable name="request" select="map{ 'method': 'GET', 'href': $request-uri, 'headers': map{ 'Accept': 'application/rdf+xml' } }" as="map(*)"/>
<xsl:variable name="context" as="map(*)" select="
map{
Expand Down Expand Up @@ -519,7 +518,7 @@ WHERE
<xsl:apply-templates select="$document" mode="bs2:Form"> <!-- document level template -->
<xsl:with-param name="about" select="()"/> <!-- don't set @about on the container until after the resource is saved -->
<xsl:with-param name="method" select="$method"/>
<xsl:with-param name="action" select="$action"/>
<xsl:with-param name="action" select="$action" tunnel="yes"/>
<xsl:with-param name="form-actions-class" select="'form-actions modal-footer'"/>
<xsl:with-param name="classes" select="()"/>
<xsl:with-param name="type-metadata" select="$type-metadata" tunnel="yes"/>
Expand Down Expand Up @@ -980,31 +979,6 @@ WHERE
<ixsl:set-style name="cursor" select="'default'" object="ixsl:page()//body"/>
</xsl:for-each>
</xsl:function>

<xsl:function name="ldh:modal-form-submit-success" ixsl:updating="yes">
<xsl:param name="context" as="map(*)"/>
<xsl:variable name="response" select="$context('response')" as="map(*)"/>

<xsl:message>ldh:modal-form-submit-success</xsl:message>

<xsl:for-each select="$response">
<xsl:variable name="href" select="ac:absolute-path(xs:anyURI(ixsl:location()))" as="xs:anyURI"/> <!-- TO-DO: pass $context?base-uri -->
<xsl:variable name="request" select="map{ 'method': 'GET', 'href': $href, 'headers': map{ 'Accept': 'application/xhtml+xml' } }" as="map(*)"/>
<xsl:variable name="context" select="map:merge((
$context,
map{
'request': $request,
'href': $href
}
), map{ 'duplicates': 'use-last' })" as="map(*)"/>
<ixsl:promise select="
ixsl:http-request($context('request'))
=> ixsl:then(ldh:rethread-response($context, ?))
=> ixsl:then(ldh:handle-response#1)
=> ixsl:then(ldh:xhtml-document-loaded#1)
" on-failure="ldh:promise-failure#1"/>
</xsl:for-each>
</xsl:function>

<xsl:function name="ldh:form-submit-created" ixsl:updating="yes">
<xsl:param name="context" as="map(*)"/>
Expand All @@ -1018,7 +992,8 @@ WHERE
<xsl:variable name="context" as="map(*)" select="
map{
'request': $request,
'href': $href
'href': $href,
'push-state': true()
}"/>
<ixsl:promise select="
ixsl:http-request($context('request'))
Expand Down Expand Up @@ -1074,7 +1049,7 @@ WHERE
<xsl:apply-templates select="." mode="bs2:Form"> <!-- document level template -->
<xsl:with-param name="about" select="()"/> <!-- don't set @about on the container until after the resource is saved -->
<xsl:with-param name="method" select="$form/@method"/>
<xsl:with-param name="action" select="$form/@action" as="xs:anyURI"/>
<xsl:with-param name="action" select="$form/@action" as="xs:anyURI" tunnel="yes"/>
<xsl:with-param name="form-actions-class" select="'form-actions modal-footer'" as="xs:string?"/>
<xsl:with-param name="classes" select="()"/>
<xsl:with-param name="type-metadata" select="$type-metadata" tunnel="yes"/>
Expand Down Expand Up @@ -1223,15 +1198,6 @@ WHERE
<xsl:variable name="constructed-doc" select="ldh:construct-forClass($forClass)" as="document-node()"/>
<xsl:variable name="doc-uri" select="resolve-uri(ac:uuid() || '/', ac:absolute-path(ldh:base-uri(.)))" as="xs:anyURI"/> <!-- build a relative URI for the child document -->
<xsl:variable name="this" select="$doc-uri" as="xs:anyURI"/>
<!-- set document URI instead of blank node -->
<xsl:variable name="constructed-doc" as="document-node()">
<xsl:document>
<xsl:apply-templates select="$constructed-doc" mode="ldh:SetResourceID">
<xsl:with-param name="forClass" select="$forClass" tunnel="yes"/>
<xsl:with-param name="about" select="$this" tunnel="yes"/>
</xsl:apply-templates>
</xsl:document>
</xsl:variable>
<xsl:variable name="classes" select="()" as="element()*"/>

<xsl:for-each select="$content-body">
Expand All @@ -1255,7 +1221,7 @@ WHERE
<xsl:apply-templates select="$constructed-doc" mode="bs2:Form"> <!-- document level template -->
<xsl:with-param name="about" select="()"/> <!-- don't set @about on the container until after the resource is saved -->
<xsl:with-param name="method" select="'put'"/>
<xsl:with-param name="action" select="ldh:href($doc-uri, map{})" as="xs:anyURI"/>
<xsl:with-param name="action" select="ldh:href($doc-uri)" as="xs:anyURI" tunnel="yes"/>
<xsl:with-param name="form-actions-class" select="'form-actions modal-footer'" as="xs:string?"/>
<xsl:with-param name="classes" select="$classes"/>
<xsl:with-param name="type-metadata" select="$type-metadata" tunnel="yes"/>
Expand Down Expand Up @@ -1351,7 +1317,7 @@ WHERE
<xsl:apply-templates select="$constructed-doc" mode="bs2:RowForm">
<xsl:with-param name="about" select="()"/> <!-- don't set @about on the container until after the resource is saved -->
<xsl:with-param name="method" select="$method"/>
<xsl:with-param name="action" select="ldh:href($doc-uri, map{})" as="xs:anyURI"/>
<xsl:with-param name="action" select="ldh:href($doc-uri)" as="xs:anyURI" tunnel="yes"/>
<xsl:with-param name="type-metadata" select="$type-metadata" tunnel="yes"/>
<xsl:with-param name="property-metadata" select="$property-metadata" tunnel="yes"/>
<xsl:with-param name="constructor" select="$constructed-doc" tunnel="yes"/>
Expand Down Expand Up @@ -1612,7 +1578,7 @@ WHERE

<xsl:apply-templates select="$resource" mode="bs2:Form">
<xsl:with-param name="method" select="'post'"/>
<xsl:with-param name="action" select="ldh:href($doc-uri, map{})" as="xs:anyURI"/>
<xsl:with-param name="action" select="ldh:href($doc-uri)" as="xs:anyURI" tunnel="yes"/>
<xsl:with-param name="classes" select="$classes"/>
<xsl:with-param name="type-metadata" select="$type-metadata" tunnel="yes"/>
<xsl:with-param name="property-metadata" select="$property-metadata" tunnel="yes"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ exclude-result-prefixes="#all"
</xsl:choose>
</xsl:function>

<xsl:function name="ldh:origin" as="xs:anyURI">
<xsl:param name="uri" as="xs:anyURI"/>

<!-- no trailing slash -->
<xsl:sequence select="xs:anyURI(replace($uri, '^(https?://[^/]+).*$', '$1'))"/>
</xsl:function>

<xsl:function name="ldt:base" as="xs:anyURI">
<xsl:sequence select="xs:anyURI(ixsl:get(ixsl:window(), 'LinkedDataHub.base'))"/>
<xsl:sequence select="xs:anyURI(ldh:origin(xs:anyURI(ixsl:location())) || '/')"/>
</xsl:function>

<xsl:function name="acl:mode" as="xs:anyURI*">
Expand Down
Loading
Loading