From 32c95ba91bce580bb850e5e01b65710310474e59 Mon Sep 17 00:00:00 2001 From: Luca Roffia Date: Tue, 26 Nov 2024 18:02:51 +0100 Subject: [PATCH 1/3] config: new Dockerfile for JMX --- Dockerfile | 7 ++- .../sepa/engine/gates/http/HttpUtilities.java | 51 ++++++++++++++++++- .../protocol/sparql11/SPARQL11Handler.java | 6 ++- 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0e017c7c..d216805a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,8 +25,11 @@ RUN chmod 600 /jmxremote.password EXPOSE 8000 EXPOSE 9000 -EXPOSE 7090 # MUST BE SET WITH THE HOST NAME (e.g. vaimee.com , vaimee.org, ...) +#ENV JMX_ARGS="-Dcom.sun.management.jmxremote.rmi.port=7090 -Dcom.sun.management.jmxremote.port=7090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote" ENV JMX_HOSTNAME=0.0.0.0 -ENTRYPOINT java -Djava.rmi.server.hostname=${JMX_HOSTNAME} -Dcom.sun.management.jmxremote.rmi.port=7090 -Dcom.sun.management.jmxremote.port=7090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote -jar engine.jar \ No newline at end of file +ENV JMX_PORT=7999 +EXPOSE ${JMX_PORT} +ENTRYPOINT ["sh","-c","java -Djava.rmi.server.hostname=${JMX_HOSTNAME} -Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT} -Dcom.sun.management.jmxremote.port=${JMX_PORT} -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote -jar engine.jar"] +#ENTRYPOINT ["sh","-c","\"java -Djava.rmi.server.hostname=${JMX_HOSTNAME} -Dcom.sun.management.jmxremote.rmi.port=7090 -Dcom.sun.management.jmxremote.port=7090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote -jar engine.jar\""] \ No newline at end of file diff --git a/engine/src/main/java/it/unibo/arces/wot/sepa/engine/gates/http/HttpUtilities.java b/engine/src/main/java/it/unibo/arces/wot/sepa/engine/gates/http/HttpUtilities.java index 3de02724..fda13d4b 100644 --- a/engine/src/main/java/it/unibo/arces/wot/sepa/engine/gates/http/HttpUtilities.java +++ b/engine/src/main/java/it/unibo/arces/wot/sepa/engine/gates/http/HttpUtilities.java @@ -90,7 +90,54 @@ private static JsonPrimitive getRequestBodyJSON(HttpRequest request) { } public static Map> splitQuery(String query) throws UnsupportedEncodingException { - Map> query_pairs = new LinkedHashMap>(); + /* + * query (exactly 1) + * default-graph-uri (0 or more) + * named-graph-uri (0 or more) + * + * using-graph-uri (0 or more) + * using-named-graph-uri (0 or more) + * */ + Map> query_pairs = new LinkedHashMap>(); + int query_index = query.indexOf("query="); + int update_index = query.indexOf("update="); + + int index = (query_index != -1 ? query_index : update_index); + + int content_index = query.indexOf('=',index); + String keyString = URLDecoder.decode(query.substring(0, content_index), "UTF-8"); + String valueString = URLDecoder.decode(query.substring(content_index + 1), "UTF-8"); + if (!query_pairs.containsKey(keyString)) query_pairs.put(keyString, new HashSet()); + query_pairs.get(keyString).add(valueString); + + /*int default_graph_uri_index = query.indexOf("default-graph-uri="); + int named_graph_uri_index = query.indexOf("named-graph-uri="); + + int using_graph_uri_index = query.indexOf("using-graph-uri="); + int using_named_graph_uri_index = query.indexOf("using-named-graph-uri="); + + if (query_index!=-1) { + int query_content_index = query.indexOf('=',query_index); + + if (default_graph_uri_index==-1 && named_graph_uri_index==-1) { + String keyString = URLDecoder.decode(query.substring(0, query_content_index), "UTF-8"); + String valueString = URLDecoder.decode(query.substring(query_content_index + 1), "UTF-8"); + if (!query_pairs.containsKey(keyString)) query_pairs.put(keyString, new HashSet()); + query_pairs.get(keyString).add(valueString); + } else if (default_graph_uri_index!=-1 && named_graph_uri_index==-1){ + if (default_graph_uri_index > query_index) { + + } + else { + + } + } else if (default_graph_uri_index==-1 && named_graph_uri_index!=-1) { + + } else { + + } + } + String[] pairs = query.split("&"); for (String pair : pairs) { int idx = pair.indexOf("="); @@ -98,7 +145,7 @@ public static Map> splitQuery(String query) throws Unsupport String valueString = URLDecoder.decode(pair.substring(idx + 1), "UTF-8"); if (!query_pairs.containsKey(keyString)) query_pairs.put(keyString, new HashSet()); query_pairs.get(keyString).add(valueString); - } + }*/ return query_pairs; } } diff --git a/engine/src/main/java/it/unibo/arces/wot/sepa/engine/protocol/sparql11/SPARQL11Handler.java b/engine/src/main/java/it/unibo/arces/wot/sepa/engine/protocol/sparql11/SPARQL11Handler.java index f6c3f8c5..f97a1b11 100644 --- a/engine/src/main/java/it/unibo/arces/wot/sepa/engine/protocol/sparql11/SPARQL11Handler.java +++ b/engine/src/main/java/it/unibo/arces/wot/sepa/engine/protocol/sparql11/SPARQL11Handler.java @@ -116,9 +116,11 @@ protected InternalUQRequest parse(HttpAsyncExchange exchange, ClientAuthorizatio * *
 			 * 
-			 * 					HTTP Method 	Query String Parameters 	Request 	| Content Type 	Request Message Body
+			 * 					| HTTP Method 	| Query String Parameters 	| Request Content Type 	| Request Message Body
 			 * ---------------------------------------------------------------------------------------------------------------------------------------- 
-			 * query via GET 	| GET 			|	query (exactly 1) 		|  None 	| None 			| default-graph-uri (0 or more)  named-graph-uri (0 or more)
+			 * query via GET 	| GET 			|  query (exactly 1) 		|  None 	            | None
+			 *                                  | default-graph-uri (0 or more)
+			 *                                  | named-graph-uri (0 or more)
 			 * 
 			 * 2.1.4 Specifying an RDF Dataset
 			 * 

From 97b49b587b5dee7a5c5ddabc81a2c253ae6775e8 Mon Sep 17 00:00:00 2001
From: Luca Roffia 
Date: Tue, 26 Nov 2024 18:03:29 +0100
Subject: [PATCH 2/3] config: new Dockerfile for JMX

---
 .../resources/endpoints/virtuoso-dld.jpar     | 33 +++++++++++++++++++
 logging-jconsole.properties                   |  9 +++++
 2 files changed, 42 insertions(+)
 create mode 100644 engine/src/main/resources/endpoints/virtuoso-dld.jpar
 create mode 100644 logging-jconsole.properties

diff --git a/engine/src/main/resources/endpoints/virtuoso-dld.jpar b/engine/src/main/resources/endpoints/virtuoso-dld.jpar
new file mode 100644
index 00000000..3880643b
--- /dev/null
+++ b/engine/src/main/resources/endpoints/virtuoso-dld.jpar
@@ -0,0 +1,33 @@
+{
+	"host": "dld.arces.unibo.it",
+	"oauth": {
+		"enable": false,
+		"register": "https://localhost:8443/oauth/register",
+		"tokenRequest": "https://localhost:8443/oauth/token",
+		"client_id": "",
+		"client_secret": "",
+		"jwt": "",
+		"expires": "",
+		"type": ""
+	},
+	"graphs": {
+		"default-graph-uri": "http://default",
+		"named-graph-uri": "http://default",
+		"using-graph-uri": "http://default",
+		"using-named-graph-uri": "http://default"
+	},
+	"sparql11protocol": {
+		"protocol": "http",
+		"port": 8890,
+		"query": {
+			"path": "/sparql",
+			"method": "URL_POST_ENCODED",
+			"format": "JSON"
+		},
+		"update": {
+			"path": "/sparql",
+			"method": "POST",
+			"format": "JSON"
+		}
+	}
+}
\ No newline at end of file
diff --git a/logging-jconsole.properties b/logging-jconsole.properties
new file mode 100644
index 00000000..b7345f5c
--- /dev/null
+++ b/logging-jconsole.properties
@@ -0,0 +1,9 @@
+handlers=java.util.logging.ConsoleHandler
+
+.level=ALL
+java.util.logging.ConsoleHandler.level=ALL
+#java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
+javax.management.level=ALL
+javax.management.remote.level=ALL
+
+# usage: jconsole -J-Djava.util.logging.config.file=logging-jconsole.properties
\ No newline at end of file

From 2d0be0c7881024b4ed77e34a1164c21c8411ab1f Mon Sep 17 00:00:00 2001
From: Luca Roffia 
Date: Wed, 27 Nov 2024 12:36:21 +0100
Subject: [PATCH 3/3] config: new Dockerfile for JMX

---
 client-api/pom.xml                                         | 7 +++++--
 .../arces/wot/sepa/commons/sparql/BindingsResults.java     | 2 --
 .../main/java/it/unibo/arces/wot/sepa/logging/Logging.java | 3 ++-
 pom.xml                                                    | 4 ++--
 run.sh                                                     | 0
 5 files changed, 9 insertions(+), 7 deletions(-)
 mode change 100644 => 100755 run.sh

diff --git a/client-api/pom.xml b/client-api/pom.xml
index 6924a656..785a08c0 100644
--- a/client-api/pom.xml
+++ b/client-api/pom.xml
@@ -8,8 +8,6 @@
 		${revision}
 	
 	client-api
-
-
 	
 		
 			org.apache.commons
@@ -52,5 +50,10 @@
 			jaxb-api
 			2.3.0
 		
+		
+			org.apache.logging.log4j
+			log4j-core
+			2.23.1
+		
 	
 
diff --git a/client-api/src/main/java/it/unibo/arces/wot/sepa/commons/sparql/BindingsResults.java b/client-api/src/main/java/it/unibo/arces/wot/sepa/commons/sparql/BindingsResults.java
index e0111410..e8894bc5 100644
--- a/client-api/src/main/java/it/unibo/arces/wot/sepa/commons/sparql/BindingsResults.java
+++ b/client-api/src/main/java/it/unibo/arces/wot/sepa/commons/sparql/BindingsResults.java
@@ -20,8 +20,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileCount;
-
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
diff --git a/client-api/src/main/java/it/unibo/arces/wot/sepa/logging/Logging.java b/client-api/src/main/java/it/unibo/arces/wot/sepa/logging/Logging.java
index b49dd960..efef8fd8 100644
--- a/client-api/src/main/java/it/unibo/arces/wot/sepa/logging/Logging.java
+++ b/client-api/src/main/java/it/unibo/arces/wot/sepa/logging/Logging.java
@@ -9,10 +9,11 @@
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.AppenderRef;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.LoggerContext;
+
 
 public class Logging {
 	public static final Logger logger = LogManager.getLogger();
diff --git a/pom.xml b/pom.xml
index 80ab3b21..c13101c1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -172,12 +172,12 @@
 		
 			org.apache.logging.log4j
 			log4j-api
-			2.20.0
+			2.23.1
 		
 		
 			org.apache.logging.log4j
 			log4j-core
-			2.20.0
+			2.23.1
 		
 		
 			com.google.code.gson
diff --git a/run.sh b/run.sh
old mode 100644
new mode 100755