Skip to content
This repository was archived by the owner on Apr 22, 2022. It is now read-only.

Commit cf44155

Browse files
committed
updated virtuoso driver, and some small modifs
1 parent 4fec952 commit cf44155

File tree

9 files changed

+103
-95
lines changed

9 files changed

+103
-95
lines changed

facete-theme-gkg.zip

-2.31 KB
Binary file not shown.

src/main/java/authentication/web/RdfStoreProxy.java

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import java.io.FileNotFoundException;
44
import java.io.IOException;
5+
import java.net.ConnectException;
56

67
import javax.servlet.ServletConfig;
78
import javax.servlet.ServletException;
89
import javax.servlet.http.HttpServlet;
910
import javax.servlet.http.HttpServletRequest;
1011
import javax.servlet.http.HttpServletResponse;
12+
import javax.ws.rs.WebApplicationException;
1113

1214
import org.apache.log4j.Logger;
1315
import org.codehaus.jackson.map.ObjectMapper;
@@ -38,68 +40,69 @@ public class RdfStoreProxy extends HttpServlet {
3840

3941
@Override
4042
public void init(ServletConfig config) throws ServletException {
41-
super.init(config);
42-
FrameworkConfiguration frameworkConf;
43-
try {
44-
// TODO: parameterize from client the to reset configuration
45-
frameworkConf = FrameworkConfiguration
46-
.getInstance(getServletContext());
47-
frameworkUserManager = frameworkConf.getFrameworkUserManager();
48-
frameworkRdfStoreManager = new SecureRdfStoreManagerImpl(
49-
frameworkConf.getAuthSparqlEndpoint(),
50-
frameworkConf.getAuthSparqlUser(),
51-
frameworkConf.getAuthSparqlPassword());
52-
} catch (FileNotFoundException e) {
53-
throw new ServletException(e.getLocalizedMessage(), e);
54-
} catch (Exception e) {
55-
throw new ServletException(e.getLocalizedMessage(), e);
56-
}
43+
super.init(config);
44+
FrameworkConfiguration frameworkConf;
45+
try {
46+
// TODO: parameterize from client the to reset configuration
47+
frameworkConf = FrameworkConfiguration.getInstance(getServletContext());
48+
frameworkUserManager = frameworkConf.getFrameworkUserManager();
49+
frameworkRdfStoreManager = new SecureRdfStoreManagerImpl(frameworkConf
50+
.getAuthSparqlEndpoint(), frameworkConf.getAuthSparqlUser(), frameworkConf
51+
.getAuthSparqlPassword());
52+
} catch (FileNotFoundException e) {
53+
throw new ServletException(e.getLocalizedMessage(), e);
54+
} catch (Exception e) {
55+
throw new ServletException(e.getLocalizedMessage(), e);
56+
}
5757

5858
}
5959

6060
@Override
6161
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
62-
throws ServletException, IOException {
63-
doGet(req, resp);
62+
throws ServletException, IOException {
63+
doGet(req, resp);
6464
}
6565

6666
@Override
67-
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
68-
throws ServletException, IOException {
69-
String responseFormat = req.getParameter("format");
70-
String username = req.getParameter("username");
71-
String token = HttpUtils.getCookieValue(req, "token");
72-
String mode = req.getParameter("mode");
73-
String query = req.getParameter("query");
67+
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
68+
IOException {
69+
String responseFormat = req.getParameter("format");
70+
String username = req.getParameter("username");
71+
String token = HttpUtils.getCookieValue(req, "token");
72+
String mode = req.getParameter("mode");
73+
String query = req.getParameter("query");
7474

75-
log.debug("mode " + mode);
76-
log.debug("username " + username);
75+
log.debug("mode " + mode);
76+
log.debug("username " + username);
7777

78-
try {
79-
RdfStoreManager rdfStoreManager;
80-
if ("settings".equals(mode)) { // framework manages settings graphs
81-
// (public setting for unauthorized
82-
// user)
83-
rdfStoreManager = frameworkRdfStoreManager;
84-
} else if (username != null && !username.isEmpty()) {
85-
System.out.println("username:" + username);
86-
boolean valid = frameworkUserManager
87-
.checkToken(username, token);
88-
if (!valid)
89-
throw new ServletException("invalid token");
90-
rdfStoreManager = frameworkUserManager
91-
.getRdfStoreManager(username);
92-
} else {
93-
System.out.println("new RdfStoreManagerImpl");
94-
rdfStoreManager = new RdfStoreManagerImpl(
95-
FrameworkConfiguration.getInstance(getServletContext())
96-
.getPublicSparqlEndpoint());
97-
}
98-
String result = rdfStoreManager.execute(query, responseFormat);
99-
resp.setContentType(responseFormat);
100-
resp.getWriter().print(result);
101-
} catch (Exception e) {
102-
throw new ServletException(e);
103-
}
78+
try {
79+
RdfStoreManager rdfStoreManager;
80+
if ("settings".equals(mode)) { // framework manages settings graphs
81+
// (public setting for unauthorized
82+
// user)
83+
rdfStoreManager = frameworkRdfStoreManager;
84+
} else if (username != null && !username.isEmpty()) {
85+
System.out.println("username:" + username);
86+
boolean valid = frameworkUserManager.checkToken(username, token);
87+
if (!valid)
88+
throw new ServletException("invalid token");
89+
rdfStoreManager = frameworkUserManager.getRdfStoreManager(username);
90+
} else {
91+
System.out.println("new RdfStoreManagerImpl");
92+
rdfStoreManager = new RdfStoreManagerImpl(FrameworkConfiguration.getInstance(
93+
getServletContext()).getPublicSparqlEndpoint());
94+
}
95+
String result = rdfStoreManager.execute(query, responseFormat);
96+
resp.setContentType(responseFormat);
97+
resp.getWriter().print(result);
98+
} catch (ConnectException e) {
99+
// 503 Service Unavailable
100+
log.error(e);
101+
throw new WebApplicationException(503);
102+
} catch (Exception e) {
103+
log.error(e);
104+
e.printStackTrace();
105+
throw new WebApplicationException(500);
106+
}
104107
}
105108
}

src/main/resources/framework-configuration-template.ttl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
gkg:publicEndpoint :VirtuosoEndpoint ;
3030
gkg:authEndpoint :VirtuosoAuthSPARQLEndpoint ;
3131
lds:integrates :Virtuoso ;
32-
foaf:homepage <http://** GENERATOR ***:8080/generator> .
32+
foaf:homepage <http://localhost:8080/generator> . # require IP for external access
3333

3434
:Virtuoso
3535
a lds:StackComponent ;
@@ -40,24 +40,24 @@
4040

4141
:VirtuosoConductor
4242
a lds:StorageService ;
43-
lds:password "***Virtuoso Endpoint***"^^xsd:string ;
44-
lds:serviceUrl <http://***Virtuoso Endpoint***:8890/conductor> ;
45-
lds:connectionString "jdbc:virtuoso://***Virtuoso Endpoint***:1111/"^^xsd:string;
46-
lds:user "***Virtuoso Endpoint***"^^xsd:string .
43+
lds:password "***REMOVED***"^^xsd:string ;
44+
lds:serviceUrl <http://***REMOVED***:8890/conductor> ;
45+
lds:connectionString "jdbc:virtuoso://***REMOVED***:1111/"^^xsd:string;
46+
lds:user "***REMOVED***"^^xsd:string .
4747

4848
:VirtuosoAuthSPARQLEndpoint
4949
a lds:SecuredSPARQLEndPointService, void:Dataset , gkg:SPARQLEndpoint , gkg:DataSource ;
5050
rdfs:label "Workbench Authenticated Endpoint" ;
5151
lds:password "***REMOVED***"^^xsd:string ;
52-
void:sparqlEndpoint <http://***Virtuoso Endpoint***:8890/sparql-auth> ;
53-
lds:serviceUrl <http://***Virtuoso Endpoint***:8890/sparql-auth> ;
52+
void:sparqlEndpoint <http://***REMOVED***:8890/sparql-auth> ;
53+
lds:serviceUrl <http://***REMOVED***:8890/sparql-auth> ;
5454
lds:user "***REMOVED***"^^xsd:string .
5555

5656
:VirtuosoEndpoint
5757
a lds:SPARQLEndPointService, void:Dataset , gkg:SPARQLEndpoint , gkg:DataSource ;
5858
rdfs:label "Workbench public Endpoint" ;
59-
lds:serviceUrl <http://***Virtuoso Endpoint***:8890/sparql> ;
60-
void:sparqlEndpoint <http://***Virtuoso Endpoint***:8890/sparql> .
59+
lds:serviceUrl <http://***REMOVED***:8890/sparql> ;
60+
void:sparqlEndpoint <http://***REMOVED***:8890/sparql> .
6161

6262

6363
# #######################################################################################
89.3 KB
Binary file not shown.

src/main/webapp/js/login-controller.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,29 @@ function LoginCtrl($q, $scope, $location, flash, AccountService, LoginService, S
2121
$scope.isRegistering = false;
2222

2323
// get the application settings and initalize scope variables
24-
ConfigurationService.getSettings().then(function(settings){
25-
26-
$scope.currentAccount = AccountService.getAccount();
27-
// retrive default role if no user logged in
28-
if($scope.currentAccount.getRole() == undefined){
29-
console.log("assign readNotLoggedInRole");
30-
UsersService.readNotLoggedInRole().then(function(response) {
31-
$scope.currentAccount.setRole(response);
32-
});
33-
}
34-
35-
$scope.isUserAuthenticated = function () {
36-
return AccountService.getAccount().getUsername() != undefined;
37-
};
24+
ConfigurationService.getSettings().then(
25+
//success
26+
function(settings){
27+
$scope.currentAccount = AccountService.getAccount();
28+
// retrive default role if no user logged in
29+
if($scope.currentAccount.getRole() == undefined){
30+
console.log("assign readNotLoggedInRole");
31+
UsersService.readNotLoggedInRole().then(function(response) {
32+
$scope.currentAccount.setRole(response);
33+
});
34+
}
35+
36+
$scope.isUserAuthenticated = function () {
37+
return AccountService.getAccount().getUsername() != undefined;
38+
};
3839

39-
$scope.isAdminLogged = function () {
40-
return AccountService.getAccount().isAdmin();
41-
};
42-
43-
});
40+
$scope.isAdminLogged = function () {
41+
return AccountService.getAccount().isAdmin();
42+
};
43+
// error
44+
},function(response){
45+
flash.error = ServerErrorResponse.getMessage(response);
46+
});
4447
}
4548

4649
$scope.login = function() {

src/main/webapp/js/services/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ angular.module("app.configuration", [])
245245
+ "ORDER BY ?s ?p ?o",
246246
mode: "settings"
247247
};
248-
console.log(SETTINGS_GRAPH);
248+
console.log("reading settings from " + SETTINGS_GRAPH);
249249

250250
return $http.post("RdfStoreProxy", $.param(requestData)).then(function (response) {
251251
settings = parseSparqlResults(response.data);
@@ -316,6 +316,8 @@ angular.module("app.configuration", [])
316316
mode: "settings"
317317
};
318318

319+
console.log("writting settings to " + SETTINGS_GRAPH);
320+
319321
return $http.post("RdfStoreProxy", $.param(requestData)).then(function (response) {
320322
return response;
321323
});

src/main/webapp/js/services/services.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ module.factory('ServerErrorResponse', function() {
5252
case 500:
5353
statusText = 'Internal Server Error' + ( response.data =! ''? ': ' + response.data : '') ;
5454
break;
55+
case 503:
56+
statusText = 'Service Unavailable' + ( response.data =! ''? ': ' + response.data : '') ;
57+
break;
5558
default:
5659
statusText = 'An '+ response.status +' error occurred ' +( response.data =! ''? ': ' + response.data : '') ;
5760
};
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
'use strict';
22

33
function ComponentCtrl($scope, ConfigurationService){
4-
$scope.components = ConfigurationService.getAllComponents();
5-
}
64

5+
ConfigurationService.getSettings().then(function(settings){
6+
$scope.components = ConfigurationService.getAllComponents();
77

8-
function ComponentServicesCtrl($scope, ConfigurationService){
9-
10-
$scope.services = [];
8+
$scope.getServices = function(uri){
9+
$scope.services = ConfigurationService.getComponentServices(uri);
10+
};
1111

12-
$scope.getServices = function(uri){
13-
$scope.services = ConfigurationService.getComponentServices(uri);
14-
};
12+
});
1513

1614
}
15+

src/main/webapp/js/settings/components/components.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,19 @@ <h3 class="green bold">Components Management</h3>
99
<tr>
1010
<th>URI</th>
1111
<th>Name</th>
12-
<th>Homepage</th>
1312
<th>Services</th>
1413
<th>Version</th>
1514
</tr>
1615
</thead>
1716
<tbody>
1817
<tr ng-repeat="component in components">
1918
<td>{{component.uri}}</td>
20-
<td>{{component.label}}</td>
21-
<td>{{component.homepage}}</td>
19+
<td><a href="{{component.homepage}}" target="_blanc">{{component.label}}</a></td>
2220
<td>
23-
<div ng-controller="ComponentServicesCtrl" ng-init="getServices(component.uri)">
21+
<div ng-init="getServices(component.uri)">
2422
<ul ng-repeat="service in services">
2523
<li>{{service.type}}</li>
26-
<li tooltip="{{service.description}}">{{service.serviceUrl}}</li>
24+
<li tooltip="service.description">{{service.serviceUrl}}</li>
2725
</ul>
2826
</div>
2927
</td>

0 commit comments

Comments
 (0)