Skip to content

Commit ff3b0ad

Browse files
committed
documentOwnerQuery moved to web.xml
1 parent e4af21b commit ff3b0ad

4 files changed

Lines changed: 71 additions & 48 deletions

File tree

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public class Application extends ResourceConfig
258258
private final Map<String, OntModelSpec> endUserOntModelSpecs;
259259
private final MediaTypes mediaTypes;
260260
private final Client client, externalClient, importClient, noCertClient;
261-
private final Query documentTypeQuery, aclQuery, ownerAclQuery, webIDQuery, agentQuery, userAccountQuery, ontologyQuery; // no relative URIs
261+
private final Query documentTypeQuery, documentOwnerQuery, aclQuery, ownerAclQuery, webIDQuery, agentQuery, userAccountQuery, ontologyQuery; // no relative URIs
262262
private final Integer maxGetRequestSize;
263263
private final boolean preemptiveAuth;
264264
private final Processor xsltProc = new Processor(false);
@@ -313,6 +313,7 @@ public Application(@Context ServletConfig servletConfig) throws URISyntaxExcepti
313313
servletConfig.getServletContext().getInitParameter(LDHC.clientTrustStore.getURI()) != null ? servletConfig.getServletContext().getInitParameter(LDHC.clientTrustStore.getURI()) : null,
314314
servletConfig.getServletContext().getInitParameter(LDHC.clientTrustStorePassword.getURI()) != null ? servletConfig.getServletContext().getInitParameter(LDHC.clientTrustStorePassword.getURI()) : null,
315315
servletConfig.getServletContext().getInitParameter(LDHC.documentTypeQuery.getURI()) != null ? servletConfig.getServletContext().getInitParameter(LDHC.documentTypeQuery.getURI()) : null,
316+
servletConfig.getServletContext().getInitParameter(LDHC.documentOwnerQuery.getURI()) != null ? servletConfig.getServletContext().getInitParameter(LDHC.documentOwnerQuery.getURI()) : null,
316317
servletConfig.getServletContext().getInitParameter(LDHC.aclQuery.getURI()) != null ? servletConfig.getServletContext().getInitParameter(LDHC.aclQuery.getURI()) : null,
317318
servletConfig.getServletContext().getInitParameter(LDHC.ownerAclQuery.getURI()) != null ? servletConfig.getServletContext().getInitParameter(LDHC.ownerAclQuery.getURI()) : null,
318319
servletConfig.getServletContext().getInitParameter(LDHC.webIDQuery.getURI()) != null ? servletConfig.getServletContext().getInitParameter(LDHC.webIDQuery.getURI()) : null,
@@ -371,6 +372,7 @@ public Application(@Context ServletConfig servletConfig) throws URISyntaxExcepti
371372
* @param clientTrustStoreURIString location of the client's truststore
372373
* @param clientTrustStorePassword client truststore's password
373374
* @param documentTypeQueryString SPARQL string of the document type query
375+
* @param documentOwnerQueryString SPARQL string of the document owner query
374376
* @param aclQueryString SPARQL string of the ACL query
375377
* @param ownerAclQueryString SPARQL string of the owner's ACL query
376378
* @param webIDQueryString SPARQL string of the WebID validation query
@@ -407,7 +409,8 @@ public Application(final ServletConfig servletConfig, final MediaTypes mediaType
407409
final String clientKeyStoreURIString, final String clientKeyStorePassword,
408410
final String secretaryCertAlias,
409411
final String clientTrustStoreURIString, final String clientTrustStorePassword,
410-
final String documentTypeQueryString, final String aclQueryString, final String ownerAclQueryString, final String webIDQueryString, final String agentQueryString, final String userAccountQueryString, final String ontologyQueryString,
412+
final String documentTypeQueryString, final String documentOwnerQueryString, final String aclQueryString, final String ownerAclQueryString,
413+
final String webIDQueryString, final String agentQueryString, final String userAccountQueryString, final String ontologyQueryString,
411414
final String baseURIString, final String proxyScheme, final String proxyHostname, final Integer proxyPort,
412415
final String uploadRootString, final boolean invalidateCache,
413416
final Integer cookieMaxAge, final boolean enableLinkedDataProxy, final Integer maxContentLength,
@@ -434,13 +437,19 @@ public Application(final ServletConfig servletConfig, final MediaTypes mediaType
434437
throw new ConfigurationException(LDHC.clientTrustStore);
435438
}
436439

437-
438440
if (documentTypeQueryString == null)
439441
{
440442
if (log.isErrorEnabled()) log.error("Document type SPARQL query is not configured properly");
441443
throw new ConfigurationException(LDHC.documentTypeQuery);
442444
}
443445
this.documentTypeQuery = QueryFactory.create(documentTypeQueryString);
446+
447+
if (documentOwnerQueryString == null)
448+
{
449+
if (log.isErrorEnabled()) log.error("Document owner SPARQL query is not configured properly");
450+
throw new ConfigurationException(LDHC.documentOwnerQuery);
451+
}
452+
this.documentOwnerQuery = QueryFactory.create(documentOwnerQueryString);
444453

445454
if (aclQueryString == null)
446455
{
@@ -1660,14 +1669,25 @@ public URI getSecretaryWebIDURI()
16601669

16611670
/**
16621671
* Returns the document type query.
1663-
* Used to the document type and owner metadata.
1672+
* Used to retrieve the document type metadata.
16641673
*
16651674
* @return query object
16661675
*/
16671676
public Query getDocumentTypeQuery()
16681677
{
16691678
return documentTypeQuery.cloneQuery();
16701679
}
1680+
1681+
/**
1682+
* Returns the document owner query.
1683+
* Used to retrieve the document owner metadata.
1684+
*
1685+
* @return query object
1686+
*/
1687+
public Query getDocumentOwnerQuery()
1688+
{
1689+
return documentOwnerQuery.cloneQuery();
1690+
}
16711691

16721692
/**
16731693
* Returns the authorization query.

src/main/java/com/atomgraph/linkeddatahub/resource/acl/Access.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class Access extends com.atomgraph.core.model.impl.SPARQLEndpointImpl
6868
private final UriInfo uriInfo;
6969
private final Application application;
7070
private final Optional<AgentContext> agentContext;
71-
private final ParameterizedSparqlString documentTypeQuery, aclQuery, ownerAclQuery;
71+
private final ParameterizedSparqlString documentTypeQuery, documentOwnerQuery, aclQuery, ownerAclQuery;
7272

7373
/**
7474
* Constructs endpoint from the in-memory ontology model.
@@ -95,6 +95,7 @@ public Access(@Context Request request, @Context UriInfo uriInfo,
9595
this.application = application;
9696
this.agentContext = agentContext;
9797
documentTypeQuery = new ParameterizedSparqlString(system.getDocumentTypeQuery().toString());
98+
documentOwnerQuery = new ParameterizedSparqlString(system.getDocumentOwnerQuery().toString());
9899
aclQuery = new ParameterizedSparqlString(system.getACLQuery().toString());
99100
ownerAclQuery = new ParameterizedSparqlString(system.getOwnerACLQuery().toString());
100101
}
@@ -245,46 +246,45 @@ public Optional<AgentContext> getAgentContext()
245246
}
246247

247248
/**
248-
* Returns authorization query.
249-
* Used on end-user applications.
249+
* Returns a query that loads document type metadata.
250250
*
251251
* @return SPARQL string
252252
*/
253-
public ParameterizedSparqlString getACLQuery()
253+
public ParameterizedSparqlString getDocumentTypeQuery()
254254
{
255-
return aclQuery.copy();
255+
return documentTypeQuery.copy();
256256
}
257257

258258
/**
259-
* Returns owner authorization query.
260-
* Used on admin applications.
259+
* Returns a query that loads document owner metadata.
261260
*
262261
* @return SPARQL string
263-
*/
264-
public ParameterizedSparqlString getOwnerACLQuery()
262+
*/
263+
public ParameterizedSparqlString getDocumentOwnerQuery()
265264
{
266-
return ownerAclQuery.copy();
265+
return documentOwnerQuery.copy();
267266
}
268267

269268
/**
270-
* Returns a query that loads document type and owner metadata.
269+
* Returns authorization query.
270+
* Used on end-user applications.
271271
*
272272
* @return SPARQL string
273273
*/
274-
public ParameterizedSparqlString getDocumentTypeQuery()
274+
public ParameterizedSparqlString getACLQuery()
275275
{
276-
return documentTypeQuery.copy();
276+
return aclQuery.copy();
277277
}
278-
279-
public ParameterizedSparqlString getDocumentOwnerQuery()
278+
279+
/**
280+
* Returns owner authorization query.
281+
* Used on admin applications.
282+
*
283+
* @return SPARQL string
284+
*/
285+
public ParameterizedSparqlString getOwnerACLQuery()
280286
{
281-
return new ParameterizedSparqlString("PREFIX acl: <http://www.w3.org/ns/auth/acl#>\n" +
282-
"\n" +
283-
"SELECT ?owner\n" +
284-
"WHERE\n" +
285-
" { GRAPH $this\n" +
286-
" { $this acl:owner ?owner }\n" +
287-
" }");
287+
return ownerAclQuery.copy();
288288
}
289289

290290
}

src/main/java/com/atomgraph/linkeddatahub/server/filter/request/AuthorizationFilter.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class AuthorizationFilter implements ContainerRequestFilter
8686
@Inject jakarta.inject.Provider<com.atomgraph.linkeddatahub.apps.model.Application> app;
8787
@Inject jakarta.inject.Provider<Optional<com.atomgraph.linkeddatahub.apps.model.Dataset>> dataset;
8888

89-
private ParameterizedSparqlString documentTypeQuery, aclQuery, ownerAclQuery;
89+
private ParameterizedSparqlString documentTypeQuery, documentOwnerQuery, aclQuery, ownerAclQuery;
9090

9191
/**
9292
* Post-construct initialization.
@@ -95,6 +95,7 @@ public class AuthorizationFilter implements ContainerRequestFilter
9595
public void init()
9696
{
9797
documentTypeQuery = new ParameterizedSparqlString(system.getDocumentTypeQuery().toString());
98+
documentOwnerQuery = new ParameterizedSparqlString(system.getDocumentOwnerQuery().toString());
9899
aclQuery = new ParameterizedSparqlString(getSystem().getACLQuery().toString());
99100
ownerAclQuery = new ParameterizedSparqlString(getSystem().getOwnerACLQuery().toString());
100101
}
@@ -349,27 +350,6 @@ public Resource createOwnerAuthorization(Resource accessTo, Resource agent)
349350
addProperty(ACL.mode, ACL.Write).
350351
addProperty(ACL.mode, ACL.Append);
351352
}
352-
353-
/**
354-
* Returns a query that loads document type and owner metadata.
355-
*
356-
* @return SPARQL string
357-
*/
358-
public ParameterizedSparqlString getDocumentTypeQuery()
359-
{
360-
return documentTypeQuery.copy();
361-
}
362-
363-
public ParameterizedSparqlString getDocumentOwnerQuery()
364-
{
365-
return new ParameterizedSparqlString("PREFIX acl: <http://www.w3.org/ns/auth/acl#>\n" +
366-
"\n" +
367-
"SELECT ?owner\n" +
368-
"WHERE\n" +
369-
" { GRAPH $this\n" +
370-
" { $this acl:owner $owner }\n" +
371-
" }");
372-
}
373353

374354
/**
375355
* Returns the SPARQL service for agent data.
@@ -413,6 +393,26 @@ public com.atomgraph.linkeddatahub.Application getSystem()
413393
return system;
414394
}
415395

396+
/**
397+
* Returns a query that loads document type metadata.
398+
*
399+
* @return SPARQL string
400+
*/
401+
public ParameterizedSparqlString getDocumentTypeQuery()
402+
{
403+
return documentTypeQuery.copy();
404+
}
405+
406+
/**
407+
* Returns a query that loads document owner metadata.
408+
*
409+
* @return SPARQL string
410+
*/
411+
public ParameterizedSparqlString getDocumentOwnerQuery()
412+
{
413+
return documentOwnerQuery.copy();
414+
}
415+
416416
/**
417417
* Returns authorization query.
418418
* Used on end-user applications.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public static String getURI()
6565
/** Document type query property */
6666
public static final DatatypeProperty documentTypeQuery = m_model.createDatatypeProperty( NS + "documentTypeQuery" );
6767

68+
/** Document owner query property */
69+
public static final DatatypeProperty documentOwnerQuery = m_model.createDatatypeProperty( NS + "documentOwnerQuery" );
70+
6871
/** ACL query property */
6972
public static final DatatypeProperty aclQuery = m_model.createDatatypeProperty( NS + "aclQuery" );
7073

0 commit comments

Comments
 (0)