This is an automated email from the ASF dual-hosted git repository.

mweiler pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git


The following commit(s) were added to refs/heads/main by this push:
     new 42acdee8c1 kie-issues#1835: Data Index GraphQL query fails when using 
non-default HTTP base path (#4034)
42acdee8c1 is described below

commit 42acdee8c1ced37967f2df9c4201031a2ed7b6bd
Author: Martin Cimbalek <[email protected]>
AuthorDate: Sat Aug 23 00:45:34 2025 +0200

    kie-issues#1835: Data Index GraphQL query fails when using non-default HTTP 
base path (#4034)
---
 .../svg/dataindex/QuarkusDataIndexClient.java      | 22 ++++++++++++++++++++--
 .../svg/dataindex/QuarkusDataIndexClientTest.java  |  4 ++--
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git 
a/quarkus/addons/process-svg/runtime/src/main/java/org/kie/kogito/svg/dataindex/QuarkusDataIndexClient.java
 
b/quarkus/addons/process-svg/runtime/src/main/java/org/kie/kogito/svg/dataindex/QuarkusDataIndexClient.java
index 063c285ada..4d406f2381 100644
--- 
a/quarkus/addons/process-svg/runtime/src/main/java/org/kie/kogito/svg/dataindex/QuarkusDataIndexClient.java
+++ 
b/quarkus/addons/process-svg/runtime/src/main/java/org/kie/kogito/svg/dataindex/QuarkusDataIndexClient.java
@@ -51,18 +51,21 @@ public class QuarkusDataIndexClient implements 
DataIndexClient {
     private Vertx vertx;
     private WebClient client;
     private String dataIndexHttpURL;
+    private String rootPath;
 
     @Inject
     public QuarkusDataIndexClient(@ConfigProperty(name = 
"kogito.dataindex.http.url", defaultValue = "http://localhost:8180";) String 
dataIndexHttpURL,
+            @ConfigProperty(name = "quarkus.http.root-path", defaultValue = 
"") String rootPath,
             Vertx vertx) {
         this.dataIndexHttpURL = dataIndexHttpURL;
         this.vertx = vertx;
+        this.rootPath = sanitizeRootPath(rootPath);
     }
 
     @PostConstruct
     protected void setup() throws MalformedURLException {
         client = WebClient.create(vertx, 
getWebClientToURLOptions(this.dataIndexHttpURL));
-        LOGGER.debug("Creating new instance of web client");
+        LOGGER.debug("Creating new instance of web client with url {} and 
rootPath {}", dataIndexHttpURL, rootPath);
     }
 
     protected WebClientOptions getWebClientToURLOptions(String targetHttpURL) 
throws MalformedURLException {
@@ -76,7 +79,7 @@ public class QuarkusDataIndexClient implements 
DataIndexClient {
     @Override
     public List<NodeInstance> getNodeInstancesFromProcessInstance(String 
processInstanceId, String authHeader) {
         String query = getNodeInstancesQuery(processInstanceId);
-        Future<List<NodeInstance>> future = client.post("/graphql")
+        Future<List<NodeInstance>> future = client.post(this.rootPath + 
"/graphql")
                 .putHeader("Authorization", authHeader)
                 .putHeader("content-type", "application/json")
                 .sendJson(JsonObject.mapFrom(singletonMap("query", query)))
@@ -109,4 +112,19 @@ public class QuarkusDataIndexClient implements 
DataIndexClient {
         }
     }
 
+    private String sanitizeRootPath(String rootPath) {
+        String sanitizedRootPath = rootPath;
+        if (rootPath != null) {
+            // remove empty root path
+            if (rootPath == "/") {
+                sanitizedRootPath = "";
+            }
+            // make sure the root path starts with /
+            if (rootPath.indexOf("/") < 0) {
+                sanitizedRootPath = "/" + rootPath;
+            }
+        }
+        LOGGER.debug("sanitizedRootPath {}", sanitizedRootPath);
+        return sanitizedRootPath;
+    }
 }
diff --git 
a/quarkus/addons/process-svg/runtime/src/test/java/org/kie/kogito/svg/dataindex/QuarkusDataIndexClientTest.java
 
b/quarkus/addons/process-svg/runtime/src/test/java/org/kie/kogito/svg/dataindex/QuarkusDataIndexClientTest.java
index 56531e2c3c..85b974e5bd 100644
--- 
a/quarkus/addons/process-svg/runtime/src/test/java/org/kie/kogito/svg/dataindex/QuarkusDataIndexClientTest.java
+++ 
b/quarkus/addons/process-svg/runtime/src/test/java/org/kie/kogito/svg/dataindex/QuarkusDataIndexClientTest.java
@@ -56,7 +56,7 @@ public class QuarkusDataIndexClientTest {
             "  }\n" +
             "}";
 
-    QuarkusDataIndexClient client = new QuarkusDataIndexClient(null, null);
+    QuarkusDataIndexClient client = new QuarkusDataIndexClient(null, null, 
null);
 
     @Test
     public void testGetNodeInstancesFromResponse() {
@@ -81,7 +81,7 @@ public class QuarkusDataIndexClientTest {
 
     @Test
     public void testSetupMalformedURL() {
-        QuarkusDataIndexClient testClient = new 
QuarkusDataIndexClient("malformedURL", null);
+        QuarkusDataIndexClient testClient = new 
QuarkusDataIndexClient("malformedURL", null, null);
         assertThrows(MalformedURLException.class, () -> testClient.setup());
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to