Skip to content

Commit a7399f3

Browse files
committed
ldh:origin renamed to lapp:origin
1 parent 21d2ab0 commit a7399f3

13 files changed

Lines changed: 81 additions & 90 deletions

File tree

config/system.trig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<urn:linkeddatahub:apps/admin> a lapp:Application, lapp:AdminApplication ;
1919
dct:title "LinkedDataHub admin" ;
2020
# ldt:base <https://admin.localhost:4443/> ;
21-
ldh:origin <https://admin.localhost:4443> ;
21+
lapp:origin <https://admin.localhost:4443> ;
2222
ldt:ontology <https://w3id.org/atomgraph/linkeddatahub/admin#> ;
2323
ldt:service <urn:linkeddatahub:services/admin> ;
2424
ac:stylesheet <static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl> ;
@@ -38,7 +38,7 @@
3838
<urn:linkeddatahub:apps/end-user> a lapp:Application, lapp:EndUserApplication ;
3939
dct:title "LinkedDataHub" ;
4040
# ldt:base <https://localhost:4443/> ;
41-
ldh:origin <https://localhost:4443> ;
41+
lapp:origin <https://localhost:4443> ;
4242
ldt:ontology <https://localhost:4443/ns#> ;
4343
ldt:service <urn:linkeddatahub:services/end-user> ;
4444
lapp:adminApplication <urn:linkeddatahub:apps/admin> ;

http-tests/config/system.trig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<urn:linkeddatahub:apps/admin> a lapp:Application, lapp:AdminApplication ;
1919
dct:title "LinkedDataHub admin" ;
2020
# ldt:base <https://admin.localhost:4443/> ;
21-
ldh:origin <https://admin.localhost:4443> ;
21+
lapp:origin <https://admin.localhost:4443> ;
2222
ldt:ontology <https://w3id.org/atomgraph/linkeddatahub/admin#> ;
2323
ldt:service <urn:linkeddatahub:services/admin> ;
2424
ac:stylesheet <static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl> ;
@@ -38,7 +38,7 @@
3838
<urn:linkeddatahub:apps/end-user> a lapp:Application, lapp:EndUserApplication ;
3939
dct:title "LinkedDataHub" ;
4040
# ldt:base <https://localhost:4443/> ;
41-
ldh:origin <https://localhost:4443> ;
41+
lapp:origin <https://localhost:4443> ;
4242
ldt:ontology <https://localhost:4443/ns#> ;
4343
ldt:service <urn:linkeddatahub:services/end-user> ;
4444
lapp:adminApplication <urn:linkeddatahub:apps/admin> ;
@@ -57,7 +57,7 @@
5757

5858
<urn:linkeddatahub:apps/test/admin> a lapp:Application, lapp:AdminApplication ;
5959
dct:title "Test admin" ;
60-
ldh:origin <https://admin.test.localhost:4443> ;
60+
lapp:origin <https://admin.test.localhost:4443> ;
6161
ldt:ontology <https://w3id.org/atomgraph/linkeddatahub/admin#> ;
6262
ldt:service <urn:linkeddatahub:services/test/admin> ;
6363
ac:stylesheet <static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl> ;
@@ -76,7 +76,7 @@
7676

7777
<urn:linkeddatahub:apps/test/end-user> a lapp:Application, lapp:EndUserApplication ;
7878
dct:title "Test" ;
79-
ldh:origin <https://test.localhost:4443> ;
79+
lapp:origin <https://test.localhost:4443> ;
8080
ldt:ontology <https://test.localhost:4443/ns#> ;
8181
ldt:service <urn:linkeddatahub:services/test/end-user> ;
8282
lapp:adminApplication <urn:linkeddatahub:apps/test/admin> ;

platform/select-root-services.rq

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ PREFIX foaf: <http://xmlns.com/foaf/0.1/>
77

88
SELECT ?endUserApp ?endUserOrigin ?endUserQuadStore ?endUserEndpoint ?endUserAuthUser ?endUserAuthPwd ?endUserMaker ?adminApp ?adminOrigin ?adminQuadStore ?adminEndpoint ?adminAuthUser ?adminAuthPwd ?adminMaker
99
{
10-
?endUserApp ldh:origin ?endUserOrigin ;
10+
?endUserApp lapp:origin ?endUserOrigin ;
1111
ldt:service ?endUserService ;
1212
lapp:adminApplication ?adminApp .
1313
?adminApp ldt:service ?adminService ;
14-
ldh:origin ?adminOrigin .
14+
lapp:origin ?adminOrigin .
1515
?endUserService a:quadStore ?endUserQuadStore ;
1616
sd:endpoint ?endUserEndpoint .
1717
?adminService a:quadStore ?adminQuadStore ;

src/main/java/com/atomgraph/linkeddatahub/Application.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,9 +1309,9 @@ public Resource getAppByOrigin(Model model, Resource type, URI absolutePath)
13091309
Resource app = it.next();
13101310

13111311
// Use origin-based matching - return immediately on match since origins are unique
1312-
if (app.hasProperty(LDH.origin))
1312+
if (app.hasProperty(LAPP.origin))
13131313
{
1314-
URI appOriginURI = URI.create(app.getPropertyResourceValue(LDH.origin).getURI());
1314+
URI appOriginURI = URI.create(app.getPropertyResourceValue(LAPP.origin).getURI());
13151315
String normalizedAppOrigin = normalizeOrigin(appOriginURI);
13161316

13171317
if (requestOrigin.equals(normalizedAppOrigin)) return app;

src/main/java/com/atomgraph/linkeddatahub/apps/model/impl/ApplicationImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.atomgraph.linkeddatahub.model.Service;
2222
import com.atomgraph.linkeddatahub.vocabulary.FOAF;
2323
import com.atomgraph.linkeddatahub.vocabulary.LAPP;
24-
import com.atomgraph.linkeddatahub.vocabulary.LDH;
2524
import com.atomgraph.server.vocabulary.LDT;
2625
import jakarta.ws.rs.core.UriBuilder;
2726
import org.apache.jena.enhanced.EnhGraph;
@@ -69,7 +68,7 @@ public URI getBaseURI()
6968
@Override
7069
public Resource getOrigin()
7170
{
72-
return getPropertyResourceValue(LDH.origin);
71+
return getPropertyResourceValue(LAPP.origin);
7372
}
7473

7574
@Override

src/main/java/com/atomgraph/linkeddatahub/vocabulary/LAPP.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,7 @@ public static String getURI()
8282
/** Read-only property */
8383
public static final DatatypeProperty allowRead = m_model.createDatatypeProperty( NS + "allowRead" );
8484

85+
/** Origin property for subdomain-based application matching */
86+
public static final ObjectProperty origin = m_model.createObjectProperty(NS + "origin");
87+
8588
}

src/main/java/com/atomgraph/linkeddatahub/vocabulary/LDH.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ public static String getURI()
101101
/** Service property */
102102
public static final ObjectProperty service = m_model.createObjectProperty( NS + "service" );
103103

104-
/** Origin property for subdomain-based application matching */
105-
public static final ObjectProperty origin = m_model.createObjectProperty( NS + "origin" );
106-
107104
/**
108105
* For shape property */
109106
public static final ObjectProperty forShape = m_model.createObjectProperty( NS + "forShape" );

src/main/java/com/atomgraph/linkeddatahub/writer/XSLTWriterBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public <T extends XdmValue> Map<QName, XdmValue> getParameters(MultivaluedMap<St
138138
com.atomgraph.linkeddatahub.apps.model.Application app = appOpt.get();
139139
if (log.isDebugEnabled()) log.debug("Passing $lapp:Application to XSLT: <{}>", app);
140140
params.put(new QName("ldt", LDT.base.getNameSpace(), LDT.base.getLocalName()), new XdmAtomicValue(app.getBaseURI()));
141-
params.put(new QName("ldh", LDH.origin.getNameSpace(), LDH.origin.getLocalName()), new XdmAtomicValue(app.getOriginURI()));
141+
params.put(new QName("lapp", LAPP.origin.getNameSpace(), LAPP.origin.getLocalName()), new XdmAtomicValue(app.getOriginURI()));
142142
params.put(new QName("ldt", LDT.ontology.getNameSpace(), LDT.ontology.getLocalName()), new XdmAtomicValue(URI.create(app.getOntology().getURI())));
143143
params.put(new QName("lapp", LAPP.Application.getNameSpace(), LAPP.Application.getLocalName()),
144144
getXsltExecutable().getProcessor().newDocumentBuilder().build(getSource(getAppModel(app, true))));

src/main/resources/com/atomgraph/linkeddatahub/lapp.ttl

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,22 @@
8282
:Application a rdfs:Class, owl:Class ;
8383
rdfs:subClassOf ldt:Application ;
8484
spin:constructor :ApplicationConstructor ;
85-
spin:constraint :OneBasePerHostName, :StartsWithHTTPS,
85+
spin:constraint :StartsWithHTTPS, :ValidOrigin,
8686
[ a ldh:MissingPropertyValue ;
87-
rdfs:label "Missing base URI" ;
88-
sp:arg1 ldt:base
87+
rdfs:label "Missing origin URI" ;
88+
sp:arg1 :origin
8989
] ;
9090
rdfs:label "Application" ;
91-
rdfs:comment "An application represents a data space identified by its base URI, in which application resource URIs are relative to the base URI. The only application interface (API) is read-write RESTful Linked data, backed by an RDF dataset accessible as a SPARQL 1.1 service. Application structure is defined in an ontology, which can import other ontologies." ;
91+
rdfs:comment "An application represents a data space identified by its origin URI, in which application resource URIs are relative to the origin URI. The only application interface (API) is read-write RESTful Linked data, backed by an RDF dataset accessible as a SPARQL 1.1 service. Application structure is defined in an ontology, which can import other ontologies." ;
9292
rdfs:isDefinedBy : .
9393

9494
:ApplicationConstructor a ldh:Constructor ;
9595
sp:text """
96-
PREFIX ldt: <https://www.w3.org/ns/ldt#>
96+
PREFIX lapp: <https://w3id.org/atomgraph/linkeddatahub/apps#>
9797
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
9898
9999
CONSTRUCT {
100-
$this ldt:base [ a rdfs:Resource ] .
100+
$this lapp:origin [ a rdfs:Resource ] .
101101
}
102102
WHERE {
103103
}""" ;
@@ -166,66 +166,56 @@
166166
# CONSTRAINTS
167167

168168
:StartsWithHTTPS a sp:Construct ;
169-
rdfs:label "ldt:base starts with https://" ;
170-
sp:text """
171-
PREFIX ldt: <https://www.w3.org/ns/ldt#>
172-
PREFIX spin: <http://spinrdf.org/spin#>
173-
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
174-
175-
CONSTRUCT {
176-
_:c0 a spin:ConstraintViolation .
177-
_:c0 spin:violationRoot ?this .
178-
_:c0 spin:violationPath ldt:base .
179-
_:c0 rdfs:label "Application base URI must start with https://" .
180-
}
181-
WHERE {
182-
?this ldt:base ?base
183-
FILTER ( ! strstarts(str(?base), "https://") )
184-
}""" ;
185-
rdfs:isDefinedBy : .
186-
187-
:BasePathMatchesRegex a sp:Construct ;
188-
rdfs:label "Base URI path does not match regex" ;
169+
rdfs:label "lapp:origin starts with https://" ;
189170
sp:text """
190-
PREFIX ldt: <https://www.w3.org/ns/ldt#>
171+
PREFIX lapp: <https://w3id.org/atomgraph/linkeddatahub/apps#>
191172
PREFIX spin: <http://spinrdf.org/spin#>
192173
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
193174
194175
CONSTRUCT {
195176
_:c0 a spin:ConstraintViolation .
196177
_:c0 spin:violationRoot ?this .
197-
_:c0 spin:violationPath ldt:base .
178+
_:c0 spin:violationPath lapp:origin .
179+
_:c0 rdfs:label "Application origin URI must start with https://" .
198180
}
199181
WHERE {
200-
?this ldt:base ?base
201-
BIND(strafter(strafter(str(?base), "//"), "/") AS ?path)
202-
FILTER (!regex(?path, ?arg1, "i"))
182+
?this lapp:origin ?origin
183+
FILTER ( ! strstarts(str(?origin), "https://") )
203184
}""" ;
204185
rdfs:isDefinedBy : .
205186

206-
:OneBasePerHostName a sp:Construct ; # TO-DO: turn into spin:Template
207-
rdfs:label "One ldt:base per hostname" ;
187+
:ValidOrigin a sp:Construct ;
188+
rdfs:label "Origin must not have trailing slash and must have hostname" ;
208189
sp:text """
209-
PREFIX ldt: <https://www.w3.org/ns/ldt#>
190+
PREFIX lapp: <https://w3id.org/atomgraph/linkeddatahub/apps#>
210191
PREFIX spin: <http://spinrdf.org/spin#>
211192
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
212193
213194
CONSTRUCT
214195
{
215196
_:c0 a spin:ConstraintViolation .
216197
_:c0 spin:violationRoot ?this .
217-
_:c0 spin:violationPath ldt:base .
218-
_:c0 rdfs:label "Only one base per hostname is allowed" .
198+
_:c0 spin:violationPath lapp:origin .
199+
_:c0 rdfs:label ?message .
219200
}
220201
WHERE
221-
{ ?this ldt:base ?base
222-
{ SELECT ?this
223-
WHERE
224-
{ ?this ldt:base ?base
225-
BIND(strbefore(strafter(str(?base), "//"), "/") AS ?hostname)
226-
}
227-
GROUP BY ?this ?hostname
228-
HAVING ( COUNT(?hostname) > 1 )
229-
}
230-
}""" ;
202+
{
203+
?this lapp:origin ?origin .
204+
205+
BIND(STRAFTER(str(?origin), "//") AS ?afterScheme)
206+
BIND(IF(CONTAINS(?afterScheme, "/"),
207+
STRBEFORE(?afterScheme, "/"),
208+
?afterScheme) AS ?hostname)
209+
210+
BIND(
211+
IF(STRENDS(str(?origin), "/"),
212+
"Origin URL must not end with a trailing slash",
213+
IF(?hostname = "",
214+
"Origin URL must have a non-empty hostname",
215+
"")) AS ?message
216+
)
217+
218+
FILTER(?message != "")
219+
}
220+
""" ;
231221
rdfs:isDefinedBy : .

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/functions.xsl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE xsl:stylesheet [
3+
<!ENTITY lapp "https://w3id.org/atomgraph/linkeddatahub/apps#">
34
<!ENTITY def "https://w3id.org/atomgraph/linkeddatahub/default#">
45
<!ENTITY ldh "https://w3id.org/atomgraph/linkeddatahub#">
56
<!ENTITY ac "https://w3id.org/atomgraph/client#">
@@ -22,6 +23,7 @@ xmlns:map="http://www.w3.org/2005/xpath-functions/map"
2223
xmlns:json="http://www.w3.org/2005/xpath-functions"
2324
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
2425
xmlns:fn="http://www.w3.org/2005/xpath-functions"
26+
xmlns:lapp="&lapp;"
2527
xmlns:ac="&ac;"
2628
xmlns:ldh="&ldh;"
2729
xmlns:rdf="&rdf;"
@@ -53,15 +55,15 @@ exclude-result-prefixes="#all"
5355
</xsl:choose>
5456
</xsl:function>
5557

56-
<xsl:function name="ldh:origin" as="xs:anyURI">
58+
<xsl:function name="lapp:origin" as="xs:anyURI">
5759
<xsl:param name="uri" as="xs:anyURI"/>
5860

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

6365
<xsl:function name="ldt:base" as="xs:anyURI">
64-
<xsl:sequence select="xs:anyURI(ldh:origin(xs:anyURI(ixsl:location())) || '/')"/>
66+
<xsl:sequence select="xs:anyURI(lapp:origin(xs:anyURI(ixsl:location())) || '/')"/>
6567
</xsl:function>
6668

6769
<xsl:function name="acl:mode" as="xs:anyURI*">

0 commit comments

Comments
 (0)