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

Commit 3f19055

Browse files
committed
several small fixes
1 parent de84636 commit 3f19055

30 files changed

+409
-438
lines changed

src/main/java/authentication/web/HttpRequestManager.java

Lines changed: 207 additions & 230 deletions
Large diffs are not rendered by default.

src/main/java/rdf/RdfStoreManagerImpl.java

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,48 @@
22

33
import java.net.URLEncoder;
44

5+
import org.apache.log4j.Logger;
6+
57
import authentication.web.HttpRequestManager;
68

79
public class RdfStoreManagerImpl implements RdfStoreManager {
8-
protected static String encoding = "UTF-8";
9-
10-
protected String endpoint;
11-
12-
public RdfStoreManagerImpl(String endpoint) {
13-
this.endpoint = endpoint;
14-
}
15-
16-
@Override
17-
public void createGraph(String graph) throws Exception {
18-
execute("CREATE SILENT GRAPH <" + graph + ">", null);
19-
}
20-
21-
@Override
22-
public void dropGraph(String graph) throws Exception {
23-
execute("DROP SILENT GRAPH <" + graph + ">", null);
24-
}
25-
26-
@Override
27-
public String execute(String sparqlQuery, String responseFormat) throws Exception {
28-
// TODO: replace with logging tool
29-
// System.out.println("[DEBUG] Rdf store manager for " + endpoint +
30-
// ": execute query " + sparqlQuery);
31-
String format = responseFormat == null ? URLEncoder.encode("application/sparql-results+json",
32-
encoding) : URLEncoder.encode(responseFormat, encoding);
33-
String urlParameters = "format=" + format + "&query="
34-
+ URLEncoder.encode(sparqlQuery, encoding);
35-
return executePost(endpoint, urlParameters);
36-
}
37-
38-
protected String executePost(String endpoint, String urlParameters) throws Exception {
39-
return HttpRequestManager.executePost(endpoint, urlParameters);
40-
}
10+
11+
private static final Logger log = Logger.getLogger(RdfStoreManagerImpl.class);
12+
13+
protected static String encoding = "UTF-8";
14+
15+
protected String endpoint;
16+
17+
public RdfStoreManagerImpl(String endpoint) {
18+
this.endpoint = endpoint;
19+
}
20+
21+
@Override
22+
public void createGraph(String graph) throws Exception {
23+
execute("CREATE SILENT GRAPH <" + graph + ">", null);
24+
}
25+
26+
@Override
27+
public void dropGraph(String graph) throws Exception {
28+
execute("DROP SILENT GRAPH <" + graph + ">", null);
29+
}
30+
31+
@Override
32+
public String execute(String sparqlQuery, String responseFormat) throws Exception {
33+
log.debug("Rdf store manager for " + endpoint + ": execute query " + sparqlQuery);
34+
35+
String format = responseFormat == null ? URLEncoder.encode(
36+
"application/sparql-results+json", encoding) : URLEncoder.encode(responseFormat,
37+
encoding);
38+
String urlParameters = "format=" + format + "&query="
39+
+ URLEncoder.encode(sparqlQuery, encoding);
40+
String response = executePost(endpoint, urlParameters);
41+
42+
log.debug(response);
43+
return response;
44+
}
45+
46+
protected String executePost(String endpoint, String urlParameters) throws Exception {
47+
return HttpRequestManager.executePost(endpoint, urlParameters);
48+
}
4149
}

src/main/java/rest/WorkbenchSetup.java

Lines changed: 49 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ public class WorkbenchSetup {
2525

2626
private static final Logger log = Logger.getLogger(WorkbenchSetup.class);
2727

28-
private @Context
29-
ServletContext context;
28+
private @Context ServletContext context;
3029

3130
/**
3231
* Get the status of the setup
@@ -36,10 +35,9 @@ public class WorkbenchSetup {
3635
@GET
3736
@Produces(MediaType.TEXT_PLAIN)
3837
public Response isSetuUp() {
39-
RDFStoreSetupManager setupManager = new RDFStoreSetupManager(
40-
context.getInitParameter("framework-setup-path"));
41-
return Response.ok(setupManager.isSetUp(), MediaType.TEXT_PLAIN)
42-
.build();
38+
RDFStoreSetupManager setupManager = new RDFStoreSetupManager(context
39+
.getInitParameter("framework-setup-path"));
40+
return Response.ok(setupManager.isSetUp(), MediaType.TEXT_PLAIN).build();
4341
}
4442

4543
/**
@@ -50,26 +48,24 @@ public Response isSetuUp() {
5048
*/
5149
@POST
5250
public Response reset(@Context ServletContext context) {
53-
RDFStoreSetupManager setupManager = new RDFStoreSetupManager(
54-
context.getInitParameter("framework-setup-path"));
55-
FrameworkConfiguration frameworkConfiguration = null;
56-
try {
57-
frameworkConfiguration = FrameworkConfiguration
58-
.getInstance(context);
59-
setupManager.setUp(frameworkConfiguration, true);
60-
} catch (Exception e) {
61-
log.error(e);
62-
e.printStackTrace();
63-
if (e.getClass().getName()
64-
.equals("virtuoso.jdbc4.VirtuosoException"))
65-
return Response.status(Response.Status.SERVICE_UNAVAILABLE)
66-
.entity(e.getMessage()).build();
67-
else
68-
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
69-
.entity(e.getMessage()).build();
70-
}
71-
log.info("System was reseted successfully.");
72-
return Response.ok().entity("System reseted successfully").build();
51+
RDFStoreSetupManager setupManager = new RDFStoreSetupManager(context
52+
.getInitParameter("framework-setup-path"));
53+
FrameworkConfiguration frameworkConfiguration = null;
54+
try {
55+
frameworkConfiguration = FrameworkConfiguration.getInstance(context);
56+
setupManager.setUp(frameworkConfiguration, true);
57+
} catch (Exception e) {
58+
log.error(e);
59+
e.printStackTrace();
60+
if (e.getClass().getName().equals("virtuoso.jdbc4.VirtuosoException"))
61+
return Response.status(Response.Status.SERVICE_UNAVAILABLE).entity(e.getMessage())
62+
.build();
63+
else
64+
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
65+
.entity(e.getMessage()).build();
66+
}
67+
log.info("System was reseted successfully.");
68+
return Response.ok().entity("System reseted successfully").build();
7369
}
7470

7571
/**
@@ -80,35 +76,33 @@ public Response reset(@Context ServletContext context) {
8076
*/
8177
@PUT
8278
public Response initialize(@Context ServletContext context) {
83-
RDFStoreSetupManager setupManager = new RDFStoreSetupManager(
84-
context.getInitParameter("framework-setup-path"));
79+
RDFStoreSetupManager setupManager = new RDFStoreSetupManager(context
80+
.getInitParameter("framework-setup-path"));
81+
82+
if (setupManager.isSetUp()) {
83+
log.info("System is already set up. To reset system use PUT method");
84+
return Response.status(Response.Status.CONFLICT).entity(
85+
"System is already set up. To reset system use PUT method").build();
86+
} else {
87+
FrameworkConfiguration frameworkConfiguration = null;
88+
try {
89+
frameworkConfiguration = FrameworkConfiguration.getInstance(context);
90+
} catch (Exception e) {
91+
log.error(e);
92+
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
93+
.entity(e.getMessage()).build();
94+
}
95+
try {
96+
setupManager.setUp(frameworkConfiguration, false);
97+
} catch (Exception e) {
98+
log.error(e);
99+
e.printStackTrace();
100+
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
101+
.entity(e.getMessage()).build();
102+
}
103+
log.info("System was set up successfully.");
104+
return Response.ok().entity("System initialized successfully").build();
105+
}
85106

86-
if (setupManager.isSetUp()) {
87-
log.info("System is already set up. To reset system use PUT method");
88-
return Response
89-
.status(Response.Status.CONFLICT)
90-
.entity("System is already set up. To reset system use PUT method")
91-
.build();
92-
} else {
93-
FrameworkConfiguration frameworkConfiguration = null;
94-
try {
95-
frameworkConfiguration = FrameworkConfiguration
96-
.getInstance(context);
97-
} catch (Exception e) {
98-
log.error(e);
99-
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
100-
.entity(e.getMessage()).build();
101-
}
102-
try {
103-
setupManager.setUp(frameworkConfiguration, false);
104-
} catch (Exception e) {
105-
log.error(e);
106-
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
107-
.entity(e.getMessage()).build();
108-
}
109-
log.info("System was set up successfully.");
110-
return Response.ok().entity("System initialized successfully")
111-
.build();
112-
}
113107
}
114108
}

src/main/java/setup/RDFStoreSetupManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void setUp(FrameworkConfiguration config, boolean reset) throws Exception
125125
// e.printStackTrace();
126126
}
127127

128-
log.info(" Default Graphs creation and configuration ");
128+
log.info(" Default Graphs creation and configuration at " + config.getAuthSparqlEndpoint());
129129
SecureRdfStoreManagerImpl frameworkRdfStoreManager = new SecureRdfStoreManagerImpl(config
130130
.getAuthSparqlEndpoint(), config.getAuthSparqlUser(), config
131131
.getAuthSparqlPassword());

src/main/java/workflow/BatchAdminClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class BatchAdminClient {
4646

4747
private static final Logger log = Logger.getLogger(BatchAdminClient.class);
4848

49-
private static String serviceUrl = "http://localhost:9999/spring-batch-admin-geoknow";
49+
private static String serviceUrl = "http://localhost:8080/spring-batch-admin-geoknow";
5050

5151
/**
5252
* Get the service URL

src/main/java/workflow/JobFactory.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public class JobFactory {
3636
private static org.springframework.schema.beans.ObjectFactory beanFactory;
3737

3838
// TODO: this directory should stay outside of the webappp
39-
private static String files_dir = "batch-jobs/";
39+
private static String files_dir = "/etc/generator/batch-jobs";
4040

4141
private static JobFactory instance;
4242

43-
public static JobFactory getInstance() {
43+
public static JobFactory getInstance() throws Exception {
4444

4545
if (instance != null)
4646
return instance;
@@ -50,8 +50,11 @@ public static JobFactory getInstance() {
5050

5151
File seshdir = new File(files_dir);
5252
if (!seshdir.exists()) {
53-
seshdir.mkdirs();
54-
log.info("creating jobs directory: " + seshdir.getAbsolutePath());
53+
if (!seshdir.mkdirs()) {
54+
log.error("Couldnt create jobs directory: " + seshdir.getAbsolutePath());
55+
throw new Exception("Couldnt create jobs directory: " + seshdir.getAbsolutePath());
56+
} else
57+
log.info("creating jobs directory: " + seshdir.getAbsolutePath());
5558
}
5659

5760
instance = new JobFactory();

src/main/java/workflow/rest/Jobs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,10 @@ public Response create(@CookieParam(value = "user") Cookie userc,
392392
.build();
393393
}
394394

395-
JobFactory.getInstance();
396395
Registration job = null;
397396
File file;
398397
try {
398+
JobFactory.getInstance();
399399
file = JobFactory.createOneStepServiceJobFile(serviceJob);
400400
// register job in the batch-admin
401401
job = BatchAdminClient.registerJob(serviceJob.getName(), file);

src/main/resources/framework-components.ttl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
foaf:homepage <http://aksw.org/Projects/LIMES.html> .
7373
:LimesService
7474
a lds:InterlinkingService ;
75-
lds:serviceUrl <http://localhost:8080/limes-service> .
75+
lds:serviceUrl <http://generator.geoknow.eu:8080/limes-service/> .
7676

7777
:TripleGeo
7878
a lds:StackComponent ;
@@ -102,7 +102,7 @@
102102
foaf:homepage <http://aksw.org/Projects/OntoWiki.html> .
103103
:OntoWikiService
104104
a lds:AuthoringService ;
105-
lds:serviceUrl <http://192.168.2.18/ontowiki> .
105+
lds:serviceUrl <http://generator.geoknow.eu/ontowiki> .
106106

107107
:Mappify
108108
a lds:StackComponent ;
@@ -122,7 +122,7 @@
122122
foaf:homepage <https://github.com/GeoKnow/spring-batch-admin> .
123123
:SpringBatchAdminService
124124
a lds:BatchProcessingService ;
125-
lds:serviceUrl <http://localhost:9999/spring-batch-admin-geoknow/> .
125+
lds:serviceUrl <http://localhost:8080/spring-batch-admin-geoknow/> .
126126

127127
:UserManager
128128
a lds:StackComponent ;
@@ -177,5 +177,10 @@ a lds:BatchProcessingService ;
177177
a gkg:RouteRestriction;
178178
gkg:partialUrl "/workbench/classification-and-enrichment/geolift"^^xsd:string;
179179
gkg:requiredService :GeoLiftService .
180+
181+
:DashboardRestriction
182+
a gkg:RouteRestriction;
183+
gkg:partialUrl "/workbench"^^xsd:string;
184+
gkg:requiredService :SpringBatchAdminService .
180185

181186

src/main/resources/log4j.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1
99

1010
#log4j.logger.rdf=DEBUG
1111
#log4j.logger.rest=DEBUG
12-
log4j.logger.workflow=DEBUG
12+
#log4j.logger.workflow=DEBUG
1313
#log4j.logger.authentication.web=DEBUG

src/main/webapp/js/directives.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ app.directive("modalIframe", function ($compile) {
1212
restrict: 'E',
1313
link: function (scope, elm, attr) {
1414

15+
scope.closeModal = function(){
16+
$('#fullModal').modal('hide');
17+
};
18+
1519
scope.openModal = function(){
1620
// $('#modal').modal({
1721
// width:'100%',
1822
// height : $(window).height() - 165
1923
// });
20-
//console.log("URL:" + scope.url);
24+
console.log("URL:" + scope.url);
2125

2226
$('#fullModal').css({
2327
width: $(window).width() ,

0 commit comments

Comments
 (0)