Skip to content

Commit

Permalink
fixed dockerfile sh*t
Browse files Browse the repository at this point in the history
  • Loading branch information
langens-jonathan committed Sep 3, 2016
1 parent 2bf2ac9 commit e7577a5
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 17 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<Context path="" docBase="scopes" debug="0" reloadable="true"></Context>
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -99,7 +99,7 @@ public String calculateGraphToQuery()
clearMetaInfoQuery += "?uuid <http://mu.semte.ch/vocabularies/core/hasGraph> ?gname .\n}";
clearMetaInfoQuery += "WHERE\n{\n?user <http://mu.semte.ch/vocabularies/core/uuid> \"" + this.name + "\" .\n}";
try {
SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", clearMetaInfoQuery);
SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), clearMetaInfoQuery);
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -110,7 +110,7 @@ public String calculateGraphToQuery()
setMetaInfoQuery += "<http://mu.semte.ch/vocabularies/core/InstanceGraph/" + UUID + "> <http://mu.semte.ch/vocabularies/core/hasGraph> \"" + instanceGraph + "\".\n}";
setMetaInfoQuery += "WHERE\n{\n?user <http://mu.semte.ch/vocabularies/core/uuid> \"" + this.name + "\" .\n}";
try {
SPARQLService.getInstance().postSPARQLResponse("http://localhost:8890/sparql", setMetaInfoQuery);
SPARQLService.getInstance().postSPARQLResponse(SPARQLService.getLocalURL(), setMetaInfoQuery);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -193,6 +194,10 @@ protected void deleteQuery(String query)
@SuppressWarnings("unchecked")
public List<Triple> getTriplesViaGet(String url) throws MalformedURLException, IOException
{
if(url == null)
url = SPARQLService.getLocalURL();


URL u = new URL(url);
HttpURLConnection connection = (HttpURLConnection) u.openConnection();

Expand Down Expand Up @@ -265,6 +270,10 @@ public List<Triple> 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();

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/
Expand All @@ -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<String> ping(HttpServletRequest request, HttpServletResponse response, @RequestBody(required = false) String body)
{
return new ResponseEntity<String>("pong", HttpStatus.OK);
return new ResponseEntity<String>(System.getenv("SPARQLENDPOINT"), HttpStatus.OK);
}

@RequestMapping(value = "/sparql")
Expand Down Expand Up @@ -87,7 +91,7 @@ public ResponseEntity<String> preProcessQuery(HttpServletRequest request, HttpSe
cb.printStackTrace();
}*/
}
String url = "http://localhost:8890/sparql";
String url = this.localSPARQLURL;

String userUUID = this.userUUID;

Expand Down Expand Up @@ -134,7 +138,7 @@ private String getGraphName(String userUUID)
askGraphInstanceName += "?instanceuri <http://mu.semte.ch/vocabularies/core/hasGraph> ?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();
Expand Down Expand Up @@ -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<String, Object> jsonMap = mapper.readValue(jsonString, Map.class);
Map<String, ScopeNode> nodeMap = new HashMap<String, ScopeNode>();
Expand Down Expand Up @@ -212,7 +216,7 @@ private Scope buildScopeForUser(String userUUID)
String getNodeParent = "WITH <http://mu.semte.ch/application> SELECT ?parent WHERE { ";
getNodeParent += "<" + node + "> <http://mu.semte.ch/vocabularies/core/hasParent> ?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<String, Object> jsonMapP = mapperP.readValue(jsonStringP, Map.class);

Expand Down
Binary file modified target/SCOPES-ENDPOINT-1.0-SNAPSHOT.war
Binary file not shown.

0 comments on commit e7577a5

Please sign in to comment.