@@ -48,6 +48,7 @@ public class FrameworkConfiguration {
4848 private String settingsGraph = "" ;
4949 private String initialSettingsGraph = "" ;
5050 private String groupsGraph = "" ;
51+ private String frameworkUri ;
5152
5253 private static FrameworkConfiguration instance ;
5354
@@ -75,7 +76,7 @@ public static synchronized FrameworkConfiguration getInstance(ServletContext con
7576 String accountsOntologyFile = "framework-accounts-ontology.ttl" ;
7677
7778 // initialize parameters from context
78- String frameworkUri = context .getInitParameter ("framework-uri" );
79+ instance . frameworkUri = context .getInitParameter ("framework-uri" );
7980
8081 instance .setFrameworkOntologyNS (context .getInitParameter ("framework-ontology-ns" ));
8182 instance .setAccountsOntologyNamespace (context .getInitParameter ("accounts-ns" ));
@@ -96,11 +97,10 @@ public static synchronized FrameworkConfiguration getInstance(ServletContext con
9697 } catch (RiotException e ) {
9798 throw new IOException ("Malformed " + configurationFile + " file" );
9899 }
99- // get and set the properties framework configuration (endpoints and
100- // credentials)
100+ // get the endpoint URL to use for the framework
101101 String query = "PREFIX lds: <http://stack.linkeddata.org/ldis-schema/> "
102- + " SELECT ?endpoint WHERE {" + " <" + frameworkUri + "> lds:integrates ?component ."
103- + " ?component lds:providesService ?service ."
102+ + " SELECT ?endpoint WHERE {" + " <" + instance . getFrameworkUri ()
103+ + "> lds:integrates ?component ." + " ?component lds:providesService ?service ."
104104 + " ?service a lds:SPARQLEndPointService ." + " ?service lds:serviceUrl ?endpoint }" ;
105105
106106 QueryExecution qexec = QueryExecutionFactory .create (query , configurationModel );
@@ -113,8 +113,9 @@ public static synchronized FrameworkConfiguration getInstance(ServletContext con
113113 }
114114 qexec .close ();
115115
116+ // get the endpoint for authenticated users, and user and password of the system framework
116117 query = "PREFIX lds: <http://stack.linkeddata.org/ldis-schema/>"
117- + " SELECT ?endpoint ?user ?password WHERE {" + " <" + frameworkUri
118+ + " SELECT ?endpoint ?user ?password WHERE {" + " <" + instance . getFrameworkUri ()
118119 + "> lds:integrates ?component ." + " ?component lds:providesService ?service ."
119120 + " ?service a lds:SecuredSPARQLEndPointService ."
120121 + " ?service lds:serviceUrl ?endpoint ." + " ?service lds:user ?user ."
@@ -134,7 +135,7 @@ public static synchronized FrameworkConfiguration getInstance(ServletContext con
134135
135136 // get and set the database configuration (Virtuoso)
136137 query = "PREFIX lds: <http://stack.linkeddata.org/ldis-schema/>"
137- + " SELECT ?connectionString ?user ?password WHERE {" + " <" + frameworkUri
138+ + " SELECT ?connectionString ?user ?password WHERE {" + " <" + instance . getFrameworkUri ()
138139 + "> lds:integrates ?component ." + " ?component lds:providesService ?service ."
139140 + " ?service a lds:StorageService ."
140141 + " ?service lds:connectionString ?connectionString ." + " ?service lds:user ?user ."
@@ -151,12 +152,11 @@ public static synchronized FrameworkConfiguration getInstance(ServletContext con
151152 }
152153 qexec .close ();
153154
154- // get and set the named graphs
155+ // get and set the system named graphs
155156 query = "PREFIX sd: <http://www.w3.org/ns/sparql-service-description#> "
156157 + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " + "SELECT ?name ?label "
157158 + "WHERE "
158159 + "{ ?s sd:namedGraph ?o . ?o sd:name ?name . ?o sd:graph ?g . ?g rdfs:label ?label } " ;
159-
160160 qexec = QueryExecutionFactory .create (query , configurationModel );
161161 results = qexec .execSelect ();
162162 if (!results .hasNext ())
@@ -193,7 +193,10 @@ else if ("groups".equals(soln.get("label").asLiteral().getString()))
193193 userManager .createUser (instance .getAuthSparqlUser (), instance .getAuthSparqlPassword ());
194194 userManager .setDefaultRdfPermissions (instance .getAuthSparqlUser (), 3 );
195195 userManager .grantRole (instance .getAuthSparqlUser (), "SPARQL_UPDATE" );
196+ userManager .grantLOLook (instance .getAuthSparqlUser ());
197+ // TODO: check if we still need to grant these to SPARQL user
196198 userManager .grantRole ("SPARQL" , "SPARQL_UPDATE" );
199+ userManager .grantLOLook ("SPARQL" );
197200
198201 System .out .println ("[INFO] System User was created " );
199202 } catch (Exception e ) {
@@ -226,13 +229,13 @@ else if ("groups".equals(soln.get("label").asLiteral().getString()))
226229 System .out .println ("[INFO] Default Graphs creation/configuration " );
227230
228231 // Read configuration files
229- Model datrasetModel = ModelFactory .createDefaultModel ();
232+ Model datasetModel = ModelFactory .createDefaultModel ();
230233 Model componentsModel = ModelFactory .createDefaultModel ();
231234 Model ontologyModel = ModelFactory .createDefaultModel ();
232235 Model ontologyAccountsModel = ModelFactory .createDefaultModel ();
233236
234237 try {
235- datrasetModel .read (datasetsFile );
238+ datasetModel .read (datasetsFile );
236239 componentsModel .read (componentsFile );
237240 ontologyModel .read (ontologyFile );
238241 ontologyAccountsModel .read (accountsOntologyFile );
@@ -258,10 +261,32 @@ else if ("groups".equals(soln.get("label").asLiteral().getString()))
258261 userManager .setRdfGraphPermissions (instance .getAuthSparqlUser (), instance
259262 .getInitialSettingsGraph (), 3 );
260263
264+ // join the settings files
261265 Model settingsModel = ModelFactory .createDefaultModel ();
262- settingsModel .add (datrasetModel );
266+ settingsModel .add (datasetModel );
263267 settingsModel .add (componentsModel );
264268 settingsModel .add (ontologyModel );
269+
270+ // add to settings virtuoso component without users/passwords
271+ queryString = "PREFIX foaf:<http://xmlns.com/foaf/0.1/> "
272+ + "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
273+ + "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
274+ + "PREFIX lds:<http://stack.linkeddata.org/ldis-schema/>" + " CONSTRUCT { <"
275+ + instance .getFrameworkUri () + "> ?p ?o . " + "<" + instance .getFrameworkUri ()
276+ + "> lds:integrates ?component ."
277+ + "?component rdfs:label ?label . ?component rdf:type ?type . "
278+ + "?component lds:providesService ?service . ?service rdf:type ?servicetype ."
279+ + "?service lds:serviceUrl ?serviceUrl .} " + " WHERE { <"
280+ + instance .getFrameworkUri () + "> ?p ?o ." + "<" + instance .getFrameworkUri ()
281+ + "> lds:integrates ?component ."
282+ + "?component rdfs:label ?label . ?component rdf:type ?type . "
283+ + "?component lds:providesService ?service . ?service rdf:type ?servicetype ."
284+ + "?service lds:serviceUrl ?serviceUrl .}" ;
285+ qexec = QueryExecutionFactory .create (queryString , configurationModel );
286+ Model triples = qexec .execConstruct ();
287+ settingsModel .add (triples );
288+ qexec .close ();
289+
265290 // write the initial settings model (default settings for new
266291 // users)
267292 ByteArrayOutputStream os = new ByteArrayOutputStream ();
@@ -485,4 +510,13 @@ public String getFrameworkOntologyNS() {
485510 public void setFrameworkOntologyNS (String frameworkOntologyNS ) {
486511 this .frameworkOntologyNS = frameworkOntologyNS ;
487512 }
513+
514+ public String getFrameworkUri () {
515+ return frameworkUri ;
516+ }
517+
518+ public void setFrameworkUri (String frameworkUri ) {
519+ this .frameworkUri = frameworkUri ;
520+ }
521+
488522}
0 commit comments