diff --git a/Dockerfile b/Dockerfile
index 525088a..57e6f0c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,9 @@
-FROM tomcat
+FROM tomcat:9.0.0.M9-jre8-alpine
-COPY target/SCOPES-ENDPOINT-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/scopes.war
+RUN rm -rf /usr/local/tomcat/webapps/ROOT
+
+COPY context.xml /usr/local/tomcat/conf/context.xml
+
+COPY target/SCOPES-ENDPOINT-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/ROOT.war
EXPOSE 8080
diff --git a/context.xml b/context.xml
new file mode 100644
index 0000000..f57b43f
--- /dev/null
+++ b/context.xml
@@ -0,0 +1,19 @@
+
+
+
+
diff --git a/src/main/java/scopes_service/query_pre_processor/Scopes/Scope.java b/src/main/java/scopes_service/query_pre_processor/Scopes/Scope.java
index e1eecea..76811a1 100644
--- a/src/main/java/scopes_service/query_pre_processor/Scopes/Scope.java
+++ b/src/main/java/scopes_service/query_pre_processor/Scopes/Scope.java
@@ -44,7 +44,7 @@ public String calculateGraphToQuery()
// clear the instance graph
String clearQuery = "WITH <" + instanceGraph + ">\nDELETE\n{\n ?s ?p ?o .\n}\nWHERE\n{\n ?s ?p ?o .\n}";
try {
- SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", clearQuery);
+ SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), clearQuery);
} catch (IOException e) {
e.printStackTrace();
}
@@ -75,7 +75,7 @@ public String calculateGraphToQuery()
String pullInInsertsQuery = "INSERT\n{\n GRAPH <" + instanceGraph + ">\n {\n ?s ?p ?o .\n }\n}";
pullInInsertsQuery += "WHERE\n{\n GRAPH <" + name + "/instance>\n {\n ?s ?p ?o.\n }\n}";
try {
- SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", pullInInsertsQuery);
+ SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), pullInInsertsQuery);
} catch (IOException e) {
e.printStackTrace();
}
@@ -87,7 +87,7 @@ public String calculateGraphToQuery()
String pullInDeletesQuery = "DELETE\n{\n GRAPH <" + instanceGraph + ">\n {\n ?s ?p ?o .\n }\n}";
pullInDeletesQuery += "WHERE\n{\n GRAPH <" + name + "/delete>\n {\n ?s ?p ?o.\n }\n}";
try {
- SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", pullInDeletesQuery);
+ SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), pullInDeletesQuery);
} catch (IOException e) {
e.printStackTrace();
}
@@ -99,7 +99,7 @@ public String calculateGraphToQuery()
clearMetaInfoQuery += "?uuid ?gname .\n}";
clearMetaInfoQuery += "WHERE\n{\n?user \"" + this.name + "\" .\n}";
try {
- SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", clearMetaInfoQuery);
+ SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), clearMetaInfoQuery);
} catch (IOException e) {
e.printStackTrace();
}
@@ -110,7 +110,7 @@ public String calculateGraphToQuery()
setMetaInfoQuery += " \"" + instanceGraph + "\".\n}";
setMetaInfoQuery += "WHERE\n{\n?user \"" + this.name + "\" .\n}";
try {
- SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", setMetaInfoQuery);
+ SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), setMetaInfoQuery);
} catch (IOException e) {
e.printStackTrace();
}
diff --git a/src/main/java/scopes_service/query_pre_processor/Scopes/ScopeNode.java b/src/main/java/scopes_service/query_pre_processor/Scopes/ScopeNode.java
index 151b56f..49c02ca 100644
--- a/src/main/java/scopes_service/query_pre_processor/Scopes/ScopeNode.java
+++ b/src/main/java/scopes_service/query_pre_processor/Scopes/ScopeNode.java
@@ -1,5 +1,6 @@
package scopes_service.query_pre_processor.Scopes;
+import org.openrdf.model.vocabulary.SP;
import scopes_service.query_pre_processor.query.SPARQLService;
import java.io.IOException;
@@ -84,7 +85,7 @@ public String calculateScopes()
// clear the instance graph
String clearQuery = "WITH <" + instanceGraph + ">\nDELETE\n{\n ?s ?p ?o .\n}\nWHERE\n{\n ?s ?p ?o .\n}";
try {
- SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", clearQuery);
+ SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), clearQuery);
} catch (IOException e) {
e.printStackTrace();
}
@@ -96,7 +97,7 @@ public String calculateScopes()
String pullInChildGraphQuery = "INSERT\n{\n GRAPH <" + instanceGraph + ">\n {\n ?s ?p ?o .\n }\n}";
pullInChildGraphQuery += "WHERE\n{\n GRAPH <" + childgraphname + ">\n {\n ?s ?p ?o.\n }\n}";
try {
- SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", pullInChildGraphQuery);
+ SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), pullInChildGraphQuery);
} catch (IOException e) {
e.printStackTrace();
}
@@ -106,7 +107,7 @@ public String calculateScopes()
String pullInInsertsQuery = "INSERT\n{\n GRAPH <" + instanceGraph + ">\n {\n ?s ?p ?o .\n }\n}";
pullInInsertsQuery += "WHERE\n{\n GRAPH <" + getInsertName(this.getUUID()) + ">\n {\n ?s ?p ?o.\n }\n}";
try {
- SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", pullInInsertsQuery);
+ SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), pullInInsertsQuery);
} catch (IOException e) {
e.printStackTrace();
}
@@ -115,7 +116,7 @@ public String calculateScopes()
String pullInDeletesQuery = "DELETE\n{\n GRAPH <" + instanceGraph + ">\n {\n ?s ?p ?o .\n }\n}";
pullInDeletesQuery += "WHERE\n{\n GRAPH <" + getDeleteName(this.getUUID()) + ">\n {\n ?s ?p ?o.\n }\n}";
try {
- SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", pullInDeletesQuery);
+ SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), pullInDeletesQuery);
} catch (IOException e) {
e.printStackTrace();
}
diff --git a/src/main/java/scopes_service/query_pre_processor/query/SPARQLService.java b/src/main/java/scopes_service/query_pre_processor/query/SPARQLService.java
index 715804c..81e32d0 100644
--- a/src/main/java/scopes_service/query_pre_processor/query/SPARQLService.java
+++ b/src/main/java/scopes_service/query_pre_processor/query/SPARQLService.java
@@ -7,6 +7,7 @@
import org.openrdf.query.Update;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.manager.SystemRepository;
import virtuoso.sesame4.driver.VirtuosoRepository;
import java.io.BufferedReader;
@@ -193,6 +194,10 @@ protected void deleteQuery(String query)
@SuppressWarnings("unchecked")
public List getTriplesViaGet(String url) throws MalformedURLException, IOException
{
+ if(url == null)
+ url = SPARQLService.getLocalURL();
+
+
URL u = new URL(url);
HttpURLConnection connection = (HttpURLConnection) u.openConnection();
@@ -265,6 +270,10 @@ public List getTriplesViaGet(String url) throws MalformedURLException, I
@SuppressWarnings("unchecked")
public String getSPARQLResponse(String url) throws MalformedURLException, IOException
{
+ if(url == null)
+ url = SPARQLService.getLocalURL();
+
+
URL u = new URL(url);
HttpURLConnection connection = (HttpURLConnection) u.openConnection();
@@ -294,6 +303,9 @@ public String getSPARQLResponse(String url) throws MalformedURLException, IOExce
@SuppressWarnings("unchecked")
public String postSPARQLResponse(String url, String query) throws MalformedURLException, IOException
{
+ if(url == null)
+ url = SPARQLService.getLocalURL();
+
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
@@ -335,4 +347,12 @@ public static SPARQLService getInstance()
}
return SPARQLService.instance;
}
+
+ public static String getLocalURL()
+ {
+ if(System.getenv("SPARQLENDPOINT") != null && !System.getenv("SPARQLENDPOINT").isEmpty())
+ return System.getenv("SPARQLENDPOINT");
+ else
+ return "http://localhost/sparql";
+ }
}
\ No newline at end of file
diff --git a/src/main/java/scopes_service/query_pre_processor/web/RootController.java b/src/main/java/scopes_service/query_pre_processor/web/RootController.java
index cfccc96..bdfa844 100644
--- a/src/main/java/scopes_service/query_pre_processor/web/RootController.java
+++ b/src/main/java/scopes_service/query_pre_processor/web/RootController.java
@@ -35,6 +35,8 @@ public class RootController {
private String userUUID = "JONATHANUUID";
+ private String localSPARQLURL = "http://localhost:8890/sparql";
+
/**
* initializes the callback service with 2 call back sets (allDifferences and effectiveDifferences)
*/
@@ -43,12 +45,14 @@ public void init()
{
this.callBackService.addCallBackSet("allDifferences");
this.callBackService.addCallBackSet("effectiveDifferences");
+ if(System.getenv("SPARQLENDPOINT") != null && !System.getenv("SPARQLENDPOINT").isEmpty())
+ this.localSPARQLURL = System.getenv("SPARQLENDPOINT");
}
- @RequestMapping(value="/setUser?")
+ @RequestMapping(value="/ping")
public ResponseEntity ping(HttpServletRequest request, HttpServletResponse response, @RequestBody(required = false) String body)
{
- return new ResponseEntity("pong", HttpStatus.OK);
+ return new ResponseEntity(System.getenv("SPARQLENDPOINT"), HttpStatus.OK);
}
@RequestMapping(value = "/sparql")
@@ -87,7 +91,7 @@ public ResponseEntity preProcessQuery(HttpServletRequest request, HttpSe
cb.printStackTrace();
}*/
}
- String url = "http://localhost:8890/sparql";
+ String url = this.localSPARQLURL;
String userUUID = this.userUUID;
@@ -134,7 +138,7 @@ private String getGraphName(String userUUID)
askGraphInstanceName += "?instanceuri ?instance .\n}";
try {
- String jsonString = this.queryService.sparqlService.getSPARQLResponse("http://localhost:8890/sparql?query=" + URLEncoder.encode(askGraphInstanceName, "UTF-8"));
+ String jsonString = this.queryService.sparqlService.getSPARQLResponse(this.localSPARQLURL + "?query=" + URLEncoder.encode(askGraphInstanceName, "UTF-8"));
String instanceName = "";
ObjectMapper mapper = new ObjectMapper();
@@ -176,7 +180,7 @@ private Scope buildScopeForUser(String userUUID)
Scope scope = new Scope(userUUID);
try {
- String jsonString = this.queryService.sparqlService.getSPARQLResponse("http://localhost:8890/sparql?query=" + URLEncoder.encode(getNodeInfo, "UTF-8"));
+ String jsonString = this.queryService.sparqlService.getSPARQLResponse(this.localSPARQLURL + "?query=" + URLEncoder.encode(getNodeInfo, "UTF-8"));
ObjectMapper mapper = new ObjectMapper();
Map jsonMap = mapper.readValue(jsonString, Map.class);
Map nodeMap = new HashMap();
@@ -212,7 +216,7 @@ private Scope buildScopeForUser(String userUUID)
String getNodeParent = "WITH SELECT ?parent WHERE { ";
getNodeParent += "<" + node + "> ?parent .\n}";
- String jsonStringP = this.queryService.sparqlService.getSPARQLResponse("http://localhost:8890/sparql?query=" + URLEncoder.encode(getNodeParent, "UTF-8"));
+ String jsonStringP = this.queryService.sparqlService.getSPARQLResponse(this.localSPARQLURL + "?query=" + URLEncoder.encode(getNodeParent, "UTF-8"));
ObjectMapper mapperP = new ObjectMapper();
Map jsonMapP = mapperP.readValue(jsonStringP, Map.class);
diff --git a/target/SCOPES-ENDPOINT-1.0-SNAPSHOT.war b/target/SCOPES-ENDPOINT-1.0-SNAPSHOT.war
index c293b2f..61b4787 100644
Binary files a/target/SCOPES-ENDPOINT-1.0-SNAPSHOT.war and b/target/SCOPES-ENDPOINT-1.0-SNAPSHOT.war differ