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 }""" ;
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 #>
191172PREFIX spin: <http://spinrdf.org/spin#>
192173PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
193174
194175CONSTRUCT {
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}
199181WHERE {
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 #>
210191PREFIX spin: <http://spinrdf.org/spin#>
211192PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
212193
213194CONSTRUCT
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 }
220201WHERE
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 : .
0 commit comments