This is an automated email from the ASF dual-hosted git repository.
fantonangeli 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 6d7cb630f4 Adding a landing page for workflow endpoint (#4078)
6d7cb630f4 is described below
commit 6d7cb630f4ebef0783284f2237c1853d39685267
Author: Kumar Aditya Raj <[email protected]>
AuthorDate: Fri Mar 6 18:29:11 2026 +0530
Adding a landing page for workflow endpoint (#4078)
* Adding a landing page for workflow endpoint
* Serving UI on 8080/endpoint
* making json reply by default
* Adding test cases
* resolving suggested changes
* Resolving failed tests
* Resolved suggested changes
* Fix build issues after PR reviews
* adding title through variable
* updated the link
* Added versoin information
* Resolved suggested changes
---------
Co-authored-by: kumaradityaraj <[email protected]>
Co-authored-by: fantonangeli <[email protected]>
---
.../RestResourceQuarkusTemplate.java | 35 +++++++-
.../kie/kogito/quarkus/workflows/GreetRestIT.java | 36 ++++++++
.../kogito-quarkus-serverless-workflow/pom.xml | 11 +++
.../main/resources/META-INF/resources/favicon.svg | 44 ++++++++++
.../main/resources/META-INF/resources/index.html | 69 +++++++++++++++
.../main/resources/META-INF/resources/styles.css | 97 ++++++++++++++++++++++
6 files changed, 289 insertions(+), 3 deletions(-)
diff --git
a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceQuarkusTemplate.java
b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceQuarkusTemplate.java
index 60a0576e58..6202d1032e 100644
---
a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceQuarkusTemplate.java
+++
b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceQuarkusTemplate.java
@@ -22,6 +22,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
+import java.io.InputStream;
+import java.util.Scanner;
import jakarta.inject.Inject;
import jakarta.ws.rs.ClientErrorException;
@@ -44,6 +46,7 @@ import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriBuilder;
import jakarta.ws.rs.core.UriInfo;
import jakarta.ws.rs.core.Response.Status;
+import jakarta.ws.rs.HeaderParam;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
@@ -59,6 +62,9 @@ import org.kie.kogito.process.workitem.TaskModel;
import org.kie.kogito.auth.IdentityProviderFactory;
import org.kie.kogito.auth.SecurityPolicy;
+import jakarta.ws.rs.core.StreamingOutput;
+
+
@Path("/$name$")
@Tag(name = "Process - $name$", description = "$documentation$")
public class $Type$Resource {
@@ -95,10 +101,33 @@ public class $Type$Resource {
}
@GET
- @Produces(MediaType.APPLICATION_JSON)
+ @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_HTML})
@Operation(operationId = "getAllProcessInstances_$name$", summary =
"$documentation$", description = "$processInstanceDescription$")
- public List<$Type$Output> getResources_$name$() {
- return processService.getProcessInstanceOutput(process);
+ public Response getResources_$name$(@Context HttpHeaders headers) {
+ List<$Type$Output> out =
processService.getProcessInstanceOutput(process);
+ boolean wantsHtml = headers.getAcceptableMediaTypes()
+ .stream()
+ .anyMatch(mt -> mt.isCompatible(MediaType.TEXT_HTML_TYPE) &&
!mt.isWildcardType() && !mt.isWildcardSubtype());
+
+ if (wantsHtml) {
+ String path = "/META-INF/resources/index.html";
+
+ if (getClass().getResource(path) == null) {
+ return Response.status(Response.Status.NOT_FOUND)
+ .entity("HTML resource not found")
+ .build();
+ }
+
+ StreamingOutput stream = os -> {
+ try (InputStream inputStream =
getClass().getResourceAsStream(path)) {
+ inputStream.transferTo(os);
+ }
+ };
+
+ return Response.ok(stream, MediaType.TEXT_HTML_TYPE).build();
+ }
+
+ return Response.ok(out, MediaType.APPLICATION_JSON_TYPE).build();
}
@GET
diff --git
a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/GreetRestIT.java
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/GreetRestIT.java
index 72920b0459..49349be5cb 100644
---
a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/GreetRestIT.java
+++
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/GreetRestIT.java
@@ -26,6 +26,7 @@ import io.restassured.http.ContentType;
import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.*;
@QuarkusIntegrationTest
class GreetRestIT {
@@ -67,6 +68,41 @@ class GreetRestIT {
.body("version", is("1.0"));
}
+ @Test
+ void testHtmlResponse() {
+ given()
+ .accept(ContentType.HTML)
+ .when()
+ .get("/greet")
+ .then()
+ .statusCode(200)
+ .contentType(ContentType.HTML)
+ .body(containsString("SONATAFLOW WORKFLOW ENDPOINT"));
+ }
+
+ @Test
+ void testJsonResponseWithAcceptHeader() {
+ given()
+ .accept(ContentType.JSON)
+ .when()
+ .get("/greet")
+ .then()
+ .statusCode(200)
+ .contentType(ContentType.JSON)
+ .body(is("[]"));
+ }
+
+ @Test
+ void testJsonResponseWithoutAcceptHeader() {
+ given()
+ .when()
+ .get("/greet")
+ .then()
+ .statusCode(200)
+ .contentType(ContentType.JSON)
+ .body(is("[]"));
+ }
+
private void assertIt(String flowName, String unknownMessage) {
given()
.contentType(ContentType.JSON)
diff --git
a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/pom.xml
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/pom.xml
index 9b2d689e38..d3c1b5d881 100644
---
a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/pom.xml
+++
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/pom.xml
@@ -34,6 +34,11 @@
<properties>
<java.module.name>org.kie.kogito.serverless.workflow</java.module.name>
+
<SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_DOCLINK_HREF>https://kie.apache.org/docs/10.1.x/sonataflow/serverlessworkflow/latest/index.html</SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_DOCLINK_HREF>
+ <SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_DOCLINK_TEXT>Sonataflow
Docs</SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_DOCLINK_TEXT>
+
<SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_LOGO>favicon.svg</SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_LOGO>
+ <SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_TITLE>SONATAFLOW WORKFLOW
ENDPOINT</SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_TITLE>
+
<SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_VERSION>${project.parent.version}</SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_VERSION>
</properties>
@@ -120,6 +125,12 @@
</dependencies>
<build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
diff --git
a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/resources/META-INF/resources/favicon.svg
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/resources/META-INF/resources/favicon.svg
new file mode 100644
index 0000000000..8806924e38
--- /dev/null
+++
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/resources/META-INF/resources/favicon.svg
@@ -0,0 +1,44 @@
+<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 1024 1024">
+ <!--
+ - 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.
+ -->
+ <defs>
+ <style>
+
.cls-1{fill:#f5891f;}.cls-2{fill:#97d4e8;}.cls-3{fill:#fff;}.cls-4{fill:#085870;}
+ </style>
+ </defs>
+ <title>
+ kie_icon_rgb_fullcolor_default
+ </title>
+ <path
+ class="cls-1"
+
d="M921.17,381.72V280.19l-251.84,85.9a188.74,188.74,0,0,0-102.28,96.54l-46.6,101.14,45.25,30.1L512,719.41,458.29,593.87l45.26-30.1L456.94,462.63a188.62,188.62,0,0,0-101.47-96.22l-252.65-81v96.29a247.75,247.75,0,0,0,0,333.86V886.13l295.12,93.34v28.38A15.2,15.2,0,0,0,413.1,1023h197a15.2,15.2,0,0,0,15.15-15.15V977.91l295.91-97.66V715.58a247.72,247.72,0,0,0,0-333.86Z"
+ />
+ <path
+ class="cls-2"
+
d="M648.57,309.12l272.6-93V1L512,211.81,102.82,6.62V221.77l273,87.49A249.38,249.38,0,0,1,512,437.26,249.35,249.35,0,0,1,648.57,309.12Z"
+ />
+ <circle class="cls-3" cx="737.68" cy="548.65" r="145.89" />
+ <path class="cls-4" d="M787.05,463.14a98.74,98.74,0,1,0,49.37,85.51H737.68Z"
/>
+ <circle class="cls-3" cx="286.32" cy="548.65" r="145.89" />
+ <path class="cls-4" d="M335.68,463.14a98.74,98.74,0,1,0,49.38,85.51H286.32Z"
/>
+ <path
+ class="cls-3"
+
d="M414.88,404.23a187.59,187.59,0,0,1,42.06,58.4l46.61,101.14-45.26,30.1L512,719.41l53.7-125.54-45.25-30.1,46.6-101.14a188.74,188.74,0,0,1,102.28-96.54l251.84-85.9v-64l-272.6,93A249.35,249.35,0,0,0,512,437.26a249.38,249.38,0,0,0-136.21-128l-273-87.49v63.66l252.65,81A187.13,187.13,0,0,1,414.88,404.23Z"
+ />
+</svg>
diff --git
a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/resources/META-INF/resources/index.html
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/resources/META-INF/resources/index.html
new file mode 100644
index 0000000000..921df28324
--- /dev/null
+++
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/resources/META-INF/resources/index.html
@@ -0,0 +1,69 @@
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>${SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_TITLE}</title>
+ <link rel="stylesheet" href="styles.css" />
+ <link
+ rel="shortcut icon"
+ type="image/x-icon"
+ href="${SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_LOGO}"
+ />
+ </head>
+ <body>
+ <div class="maindiv">
+ <div class="container">
+ <div class="logo" style="display: flex; justify-content: center">
+ <img
+ src="${SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_LOGO}"
+ alt="KIE Logo"
+ />
+ <div style="display: flex; flex-direction: column; gap: 4px">
+ <h1 style="margin: 0">
+ ${SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_TITLE}
+ </h1>
+ <h6 style="margin: 0; font-weight: normal" class="versionInfo">
+ ${SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_VERSION}
+ </h6>
+ </div>
+ </div>
+ <div>
+ <h4>SonataFlow Workflow Endpoint service is up and working!</h4>
+ </div>
+ <p>
+ A workflow definition is a JSON or YAML file that conforms to the
+ Serverless Workflow specification DSL to do the services and events
+ orchestration and choreography.
+ </p>
+ <div>
+ <a
+ href="${SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_DOCLINK_HREF}"
+ class="btn"
+ target="_blank"
+ >${SONATAFLOW_WORKFLOW_ENDPOINT_WEBAPP_DOCLINK_TEXT}</a
+ >
+ </div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git
a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/resources/META-INF/resources/styles.css
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/resources/META-INF/resources/styles.css
new file mode 100644
index 0000000000..451455c97d
--- /dev/null
+++
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/resources/META-INF/resources/styles.css
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+body {
+ margin: 0px;
+ padding: 0px;
+}
+
+.maindiv {
+ font-family: "RedHatText", "Overpass", overpass, helvetica, arial,
sans-serif;
+ background-color: #fff;
+ color: #fff;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ height: 100vh;
+}
+
+.container {
+ text-align: center;
+ background-color: #fff;
+ max-width: 1000px;
+}
+
+.logo img {
+ width: 80px;
+ height: auto;
+}
+
+h1 {
+ font-size: 48px;
+ color: #e44c3b;
+ padding-left: 15px;
+}
+
+h4 {
+ font-size: 30px;
+ color: #c94848;
+ margin-top: 10px;
+}
+
+p {
+ font-size: 16px;
+ color: #1f1e1e;
+ margin-top: 5px;
+ margin-bottom: 40px;
+}
+
+.btn {
+ padding: 10px 20px;
+ background-color: #e44c3b;
+ color: #fff;
+ text-decoration: none;
+ border-radius: 5px;
+ font-size: 16px;
+ transition: background-color 0.3s;
+}
+
+.btn:hover {
+ background-color: #c73828;
+}
+
+.versionInfo {
+ color: #1f1e1e;
+}
+
+@media (prefers-color-scheme: dark) {
+ .maindiv,
+ .container {
+ background-color: #232121;
+ }
+
+ h4,
+ p {
+ color: #fefefe;
+ }
+
+ .versionInfo {
+ color: #fff;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]