diff --git a/pom.xml b/pom.xml
index 661068f93f..8a4daf2411 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,7 +81,6 @@
2.3.2
1.1
3.0.1
- 3.1.0
3.29.2-GA
3.5.2.Final
4.4.3
@@ -94,8 +93,8 @@
0.2.0
3.7.1
1.4.3
- 1.11.5
- 1.11.5
+ 1.12.0
+ 1.12.0
1.12
2.17.0
4.1.72.Final
@@ -119,9 +118,11 @@
1.4.0
2.0.6
2.2
- 3.1.5
- 6.1.5
- 2.2.7
+ 2.3.0
+ 6.1.1
+ 3.2.0
+ 6.2.0
+ 2.2.19
0.8.1
1.11
@@ -154,6 +155,13 @@
+
+ org.springframework
+ spring-framework-bom
+ ${spring.version}
+ import
+ pom
+
commons-codec
commons-codec
@@ -339,11 +347,6 @@
persistence-api
${jakarta-persistence-api.version}
-
- jakarta.ws.rs
- jakarta.ws.rs-api
- ${jakarta.ws.rs.version}
-
org.apache.activemq
activemq-client
@@ -510,6 +513,11 @@
spring-security-core
${spring-security.version}
+
+ org.springframework.security
+ spring-security-web
+ ${spring-security.version}
+
org.yaml
snakeyaml
@@ -743,6 +751,11 @@
quartz
${quartz.version}
+
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
+ ${springdoc.version}
+
redis.clients
jedis
@@ -975,6 +988,7 @@
17
UTF-8
+ true
@@ -1264,6 +1278,7 @@
17
UTF-8
+ true
diff --git a/streampipes-extensions/streampipes-extensions-all-iiot/Dockerfile b/streampipes-extensions/streampipes-extensions-all-iiot/Dockerfile
index a53114ad38..ae8040391e 100644
--- a/streampipes-extensions/streampipes-extensions-all-iiot/Dockerfile
+++ b/streampipes-extensions/streampipes-extensions-all-iiot/Dockerfile
@@ -23,4 +23,4 @@ COPY --from=builder dependencies/ ./
COPY --from=builder snapshot-dependencies/ ./
COPY --from=builder spring-boot-loader/ ./
COPY --from=builder application/ ./
-ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
+ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
diff --git a/streampipes-extensions/streampipes-extensions-all-jvm/Dockerfile b/streampipes-extensions/streampipes-extensions-all-jvm/Dockerfile
index 558320271d..31c59268e2 100644
--- a/streampipes-extensions/streampipes-extensions-all-jvm/Dockerfile
+++ b/streampipes-extensions/streampipes-extensions-all-jvm/Dockerfile
@@ -26,4 +26,4 @@ COPY --from=builder dependencies/ ./
COPY --from=builder snapshot-dependencies/ ./
COPY --from=builder spring-boot-loader/ ./
COPY --from=builder application/ ./
-ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
+ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
diff --git a/streampipes-extensions/streampipes-extensions-iiot-minimal/Dockerfile b/streampipes-extensions/streampipes-extensions-iiot-minimal/Dockerfile
index 5c449815c5..621162a874 100644
--- a/streampipes-extensions/streampipes-extensions-iiot-minimal/Dockerfile
+++ b/streampipes-extensions/streampipes-extensions-iiot-minimal/Dockerfile
@@ -23,4 +23,4 @@ COPY --from=builder dependencies/ ./
COPY --from=builder snapshot-dependencies/ ./
COPY --from=builder spring-boot-loader/ ./
COPY --from=builder application/ ./
-ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
+ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
diff --git a/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/Role.java b/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/Role.java
index 7e2747595c..26f5d1c003 100644
--- a/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/Role.java
+++ b/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/Role.java
@@ -57,8 +57,9 @@ public enum Role {
),
ROLE_CONNECT_ADMIN(
Constants.ROLE_CONNECT_ADMIN_VALUE,
- Privilege.PRIVILEGE_WRITE_ADAPTER
-
+ Privilege.PRIVILEGE_WRITE_ADAPTER,
+ Privilege.PRIVILEGE_READ_ADAPTER,
+ Privilege.PRIVILEGE_DELETE_ADAPTER
),
ROLE_DASHBOARD_USER(
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/message/Notification.java b/streampipes-model/src/main/java/org/apache/streampipes/model/message/Notification.java
index 272a6fd731..283072d828 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/message/Notification.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/message/Notification.java
@@ -34,7 +34,8 @@ public Notification(String title, String description) {
this.description = description;
}
- public Notification(String title, String description,
+ public Notification(String title,
+ String description,
String additionalInformation) {
super();
this.title = title;
@@ -42,7 +43,8 @@ public Notification(String title, String description,
this.additionalInformation = additionalInformation;
}
- public Notification(NotificationType notificationType, String additionalInformation) {
+ public Notification(NotificationType notificationType,
+ String additionalInformation) {
this(notificationType.title(), notificationType.description(), additionalInformation);
}
diff --git a/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeImageResource.java b/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeImageResource.java
index 0b90d72e66..6e71ec1a36 100644
--- a/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeImageResource.java
+++ b/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeImageResource.java
@@ -21,19 +21,21 @@
import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource;
import org.apache.streampipes.storage.management.StorageDispatcher;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
-@Path("v4/datalake/images")
+
+import java.io.InputStream;
+
+@RestController
+@RequestMapping("/api/v4/datalake/images")
public class DataLakeImageResource extends AbstractAuthGuardedRestResource {
- @GET
- @Path("{imageId}")
- @Produces("image/jpeg")
- public Response getImage(@PathParam("imageId") String imageId) {
+ @GetMapping(path = "{imageId}", produces = "image/jpeg")
+ public ResponseEntity getImage(@PathVariable("imageId") String imageId) {
return ok(StorageDispatcher.INSTANCE.getNoSqlStore().getImageStorage().getImageBytes(imageId));
}
}
diff --git a/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeMeasureResourceV4.java b/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeMeasureResourceV4.java
index 7ed976cbc8..f315571cff 100644
--- a/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeMeasureResourceV4.java
+++ b/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeMeasureResourceV4.java
@@ -23,25 +23,26 @@
import org.apache.streampipes.dataexplorer.influx.DataLakeMeasurementCount;
import org.apache.streampipes.model.datalake.DataLakeMeasure;
import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
import org.apache.streampipes.storage.management.StorageDispatcher;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.PUT;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
-@Path("/v4/datalake/measure")
+@RestController
+@RequestMapping("/api/v4/datalake/measure")
public class DataLakeMeasureResourceV4 extends AbstractAuthGuardedRestResource {
private final IDataExplorerSchemaManagement dataLakeMeasureManagement;
@@ -53,29 +54,24 @@ public DataLakeMeasureResourceV4() {
this.dataLakeMeasureManagement = new DataExplorerSchemaManagement(dataLakeStorage);
}
- @POST
- @JacksonSerialized
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response addDataLake(DataLakeMeasure dataLakeMeasure) {
+ @PostMapping(
+ produces = MediaType.APPLICATION_JSON_VALUE,
+ consumes = MediaType.APPLICATION_JSON_VALUE
+ )
+ public ResponseEntity addDataLake(@RequestBody DataLakeMeasure dataLakeMeasure) {
DataLakeMeasure result = this.dataLakeMeasureManagement.createOrUpdateMeasurement(dataLakeMeasure);
return ok(result);
}
- @GET
- @JacksonSerialized
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getDataLakeInfos(@QueryParam("filter") List measurementNames) {
+ @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity
-
- jakarta.ws.rs
- jakarta.ws.rs-api
-
org.rendersnake
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractExtensionsResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractExtensionsResource.java
index 9854c20420..95dbbaad15 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractExtensionsResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractExtensionsResource.java
@@ -19,42 +19,19 @@
package org.apache.streampipes.rest.extensions;
import org.apache.http.HttpStatus;
-
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.ResponseEntity;
public class AbstractExtensionsResource {
- protected Response ok(T entity) {
- return Response
+ protected ResponseEntity ok(T entity) {
+ return ResponseEntity
.ok()
- .entity(entity)
- .build();
- }
-
- protected Response clientError() {
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .build();
+ .body(entity);
}
- protected Response serverError() {
- return Response
+ protected ResponseEntity serverError() {
+ return ResponseEntity
.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
.build();
}
-
- protected Response notModified(T entity) {
- return Response
- .notModified()
- .entity(entity)
- .build();
- }
-
- protected Response noContent(T entity) {
- return Response
- .noContent()
- .entity(entity)
- .build();
- }
-
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractPipelineElementResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractPipelineElementResource.java
index 4ff9621ab1..e2bd86a454 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractPipelineElementResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/AbstractPipelineElementResource.java
@@ -28,21 +28,16 @@
import org.apache.streampipes.model.grounding.EventGrounding;
import org.apache.streampipes.model.grounding.TransportFormat;
import org.apache.streampipes.model.grounding.TransportProtocol;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
-import org.apache.streampipes.rest.shared.util.SpMediaType;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import org.apache.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
import java.io.IOException;
import java.net.URL;
@@ -59,18 +54,13 @@ public abstract class AbstractPipelineElementResource<
private static final Logger LOG = LoggerFactory.getLogger(AbstractPipelineElementResource.class);
- @GET
- @Path("{appId}")
- @Produces(MediaType.APPLICATION_JSON)
- @JacksonSerialized
- public NamedStreamPipesEntity getDescription(@PathParam("appId") String appId) {
+ @GetMapping(path = "{appId}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public NamedStreamPipesEntity getDescription(@PathVariable("appId") String appId) {
return prepareElement(appId);
}
- @GET
- @Path("{appId}/assets")
- @Produces(SpMediaType.APPLICATION_ZIP)
- public Response getAssets(@PathParam("appId") String appId) {
+ @GetMapping(path = "{appId}/assets", produces = "application/zip")
+ public ResponseEntity> getAssets(@PathVariable("appId") String appId) {
List includedAssets = getDeclarerById(appId).declareConfig().getDescription().getIncludedAssets();
try {
return ok(new AssetZipGenerator(appId, includedAssets).makeZip());
@@ -80,29 +70,25 @@ public Response getAssets(@PathParam("appId") String appId) {
}
}
- @GET
- @Path("{appId}/assets/icon")
- @Produces("image/png")
- public Response getIconAsset(@PathParam("appId") String appId) throws IOException {
+ @GetMapping(path = "{appId}/assets/icon", produces = MediaType.IMAGE_PNG_VALUE)
+ public ResponseEntity getIconAsset(@PathVariable("appId") String appId) throws IOException {
try {
URL iconUrl = Resources.getResource(makeIconPath(appId));
return ok(Resources.toByteArray(iconUrl));
} catch (IllegalArgumentException e) {
LOG.warn("No icon resource found for pipeline element {}", appId);
- return Response.status(HttpStatus.SC_BAD_REQUEST).build();
+ return ResponseEntity.status(HttpStatus.SC_BAD_REQUEST).build();
}
}
- @GET
- @Path("{id}/assets/documentation")
- @Produces(MediaType.TEXT_PLAIN)
- public Response getDocumentationAsset(@PathParam("id") String elementId) throws IOException {
+ @GetMapping(path = "{id}/assets/documentation", produces = MediaType.TEXT_PLAIN_VALUE)
+ public ResponseEntity getDocumentationAsset(@PathVariable("id") String elementId) throws IOException {
try {
URL documentationUrl = Resources.getResource(makeDocumentationPath(elementId));
return ok(Resources.toString(documentationUrl, Charsets.UTF_8));
} catch (IllegalArgumentException e) {
LOG.warn("No documentation resource found for pipeline element {}", elementId);
- return Response.status(HttpStatus.SC_BAD_REQUEST).build();
+ return ResponseEntity.status(HttpStatus.SC_BAD_REQUEST).build();
}
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/WelcomePage.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/WelcomePage.java
index 38867a73af..aa9454b5f3 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/WelcomePage.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/WelcomePage.java
@@ -25,26 +25,25 @@
import org.apache.streampipes.rest.extensions.html.JSONGenerator;
import org.apache.streampipes.rest.extensions.html.page.WelcomePageGenerator;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
import java.util.Collection;
-@Path("/")
+@RestController
+@RequestMapping("/")
public class WelcomePage {
- @GET
- @Produces(MediaType.TEXT_HTML)
+ @GetMapping(produces = MediaType.TEXT_HTML_VALUE)
public String getWelcomePageHtml() {
WelcomePageGenerator welcomePage = getWelcomePageGenerator();
HTMLGenerator html = new HTMLGenerator(welcomePage.buildUris());
return html.buildHtml();
}
- @GET
- @Produces(MediaType.APPLICATION_JSON)
+ @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public String getWelcomePageJson() {
WelcomePageGenerator welcomePage = getWelcomePageGenerator();
JSONGenerator json = new JSONGenerator(welcomePage.buildUris());
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterAssetResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterAssetResource.java
index b47338c927..0fb89bfc1c 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterAssetResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterAssetResource.java
@@ -22,23 +22,26 @@
import org.apache.streampipes.extensions.management.connect.ConnectWorkerDescriptionProvider;
import org.apache.streampipes.extensions.management.util.AssetsUtil;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;
+import org.apache.streampipes.model.message.Notifications;
+import org.apache.streampipes.rest.shared.exception.SpMessageException;
import org.apache.streampipes.rest.shared.impl.AbstractSharedRestInterface;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
-
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.net.URL;
import java.util.Optional;
-@Path("/api/v1/worker/adapters")
+@RestController
+@RequestMapping("/api/v1/worker/adapters")
public class AdapterAssetResource extends AbstractSharedRestInterface {
private ConnectWorkerDescriptionProvider connectWorkerDescriptionProvider;
@@ -48,36 +51,31 @@ public AdapterAssetResource() {
}
- @GET
- @Path("/{id}/assets")
- @Produces("application/zip")
- public Response getAssets(@PathParam("id") String id) {
+ @GetMapping(path = "/{id}/assets", produces = "application/zip")
+ public ResponseEntity getAssets(@PathVariable("id") String id) {
Optional adapterDescription = this.connectWorkerDescriptionProvider.getAdapterDescription(id);
if (adapterDescription.isPresent()) {
try {
return ok(new AssetZipGenerator(id, adapterDescription.get().getIncludedAssets()).makeZip());
} catch (IOException e) {
- e.printStackTrace();
- return fail();
+ throw new SpMessageException(HttpStatus.INTERNAL_SERVER_ERROR, e);
}
} else {
- return fail();
+ throw new SpMessageException(
+ HttpStatus.NOT_FOUND,
+ Notifications.error(String.format("Could not find adapter with id %s", id)));
}
}
- @GET
- @Path("/{id}/assets/icon")
- @Produces("image/png")
- public Response getIconAsset(@PathParam("id") String elementId) throws IOException {
+ @GetMapping(path = "/{id}/assets/icon", produces = MediaType.IMAGE_PNG_VALUE)
+ public ResponseEntity getIconAsset(@PathVariable("id") String elementId) throws IOException {
URL iconUrl = Resources.getResource(AssetsUtil.makeIconPath(elementId));
return ok(Resources.toByteArray(iconUrl));
}
- @GET
- @Path("/{id}/assets/documentation")
- @Produces(MediaType.TEXT_PLAIN)
- public String getDocumentationAsset(@PathParam("id") String elementId) throws IOException {
+ @GetMapping(path = "/{id}/assets/documentation", produces = MediaType.TEXT_PLAIN_VALUE)
+ public String getDocumentationAsset(@PathVariable("id") String elementId) throws IOException {
URL documentationUrl = Resources.getResource(AssetsUtil.makeDocumentationPath(elementId));
return Resources.toString(documentationUrl, Charsets.UTF_8);
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterDescriptionResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterDescriptionResource.java
index cdc0f75146..6df779c15b 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterDescriptionResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterDescriptionResource.java
@@ -21,26 +21,26 @@
import org.apache.streampipes.extensions.management.init.DeclarersSingleton;
import org.apache.streampipes.extensions.management.locales.LabelGenerator;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
+import org.apache.streampipes.model.message.Notifications;
+import org.apache.streampipes.rest.shared.exception.SpMessageException;
import org.apache.streampipes.rest.shared.impl.AbstractSharedRestInterface;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
-@Path("/api/v1/worker/adapters")
+@RestController
+@RequestMapping("/api/v1/worker/adapters")
public class AdapterDescriptionResource extends AbstractSharedRestInterface {
- @GET
- @Path("/{id}")
- @Produces(MediaType.APPLICATION_JSON)
- @JacksonSerialized
- public Response getAdapterDescription(@PathParam("id") String id) {
+ @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity getAdapterDescription(@PathVariable("id") String id) {
var adapterDescriptionOpt = DeclarersSingleton.getInstance().getAdapter(id);
if (adapterDescriptionOpt.isPresent()) {
try {
@@ -48,10 +48,12 @@ public Response getAdapterDescription(@PathParam("id") String id) {
var localizedDescription = applyLocales(adapterDescription);
return ok(localizedDescription);
} catch (IOException e) {
- return serverError(e);
+ throw new SpMessageException(HttpStatus.INTERNAL_SERVER_ERROR, e);
}
} else {
- return notFound();
+ throw new SpMessageException(
+ HttpStatus.NOT_FOUND,
+ Notifications.error(String.format("Could not find adapter with id %s", id)));
}
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterWorkerResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterWorkerResource.java
index 56475c355d..8b61e0c2e7 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterWorkerResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/AdapterWorkerResource.java
@@ -24,23 +24,26 @@
import org.apache.streampipes.extensions.management.init.RunningAdapterInstances;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;
import org.apache.streampipes.model.message.Notifications;
+import org.apache.streampipes.model.message.SuccessMessage;
import org.apache.streampipes.model.monitoring.SpLogMessage;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
+import org.apache.streampipes.rest.shared.exception.SpLogMessageException;
import org.apache.streampipes.rest.shared.impl.AbstractSharedRestInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-
-
-@Path("/api/v1/worker")
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Collection;
+
+@RestController
+@RequestMapping("/api/v1/worker")
public class AdapterWorkerResource extends AbstractSharedRestInterface {
private static final Logger logger = LoggerFactory.getLogger(AdapterWorkerResource.class);
@@ -58,21 +61,17 @@ public AdapterWorkerResource(AdapterWorkerManagement adapterManagement) {
this.adapterManagement = adapterManagement;
}
- @GET
- @JacksonSerialized
- @Path("/running")
- @Produces(MediaType.APPLICATION_JSON)
- public Response getRunningAdapterInstances() {
+ @GetMapping(path = "/running", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity> getRunningAdapterInstances() {
return ok(adapterManagement.getAllRunningAdapterInstances());
}
- @POST
- @JacksonSerialized
- @Path("/stream/invoke")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response invokeAdapter(AdapterDescription adapterStreamDescription) {
+ @PostMapping(
+ path = "/stream/invoke",
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity invokeAdapter(@RequestBody AdapterDescription adapterStreamDescription) {
try {
adapterManagement.invokeAdapter(adapterStreamDescription);
@@ -83,16 +82,15 @@ public Response invokeAdapter(AdapterDescription adapterStreamDescription) {
return ok(Notifications.success(responseMessage));
} catch (AdapterException e) {
logger.error("Error while starting adapter with id " + adapterStreamDescription.getElementId(), e);
- return serverError(SpLogMessage.from(e));
+ throw new SpLogMessageException(HttpStatus.INTERNAL_SERVER_ERROR, SpLogMessage.from(e));
}
}
- @POST
- @JacksonSerialized
- @Path("/stream/stop")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response stopAdapter(AdapterDescription adapterStreamDescription) {
+ @PostMapping(
+ path = "/stream/stop",
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity stopAdapter(@RequestBody AdapterDescription adapterStreamDescription) {
String responseMessage;
try {
@@ -107,7 +105,7 @@ public Response stopAdapter(AdapterDescription adapterStreamDescription) {
return ok(Notifications.success(responseMessage));
} catch (AdapterException e) {
logger.error("Error while stopping adapter with id " + adapterStreamDescription.getElementId(), e);
- return serverError(SpLogMessage.from(e));
+ throw new SpLogMessageException(HttpStatus.INTERNAL_SERVER_ERROR, SpLogMessage.from(e));
}
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/GuessResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/GuessResource.java
index e00102437b..25adc18edc 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/GuessResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/GuessResource.java
@@ -24,20 +24,21 @@
import org.apache.streampipes.extensions.management.context.AdapterContextGenerator;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;
import org.apache.streampipes.model.connect.guess.GuessSchema;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
+import org.apache.streampipes.rest.shared.exception.SpMessageException;
import org.apache.streampipes.rest.shared.impl.AbstractSharedRestInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-
-
-@Path("/api/v1/worker/guess")
+@RestController
+@RequestMapping("/api/v1/worker/guess")
public class GuessResource extends AbstractSharedRestInterface {
private static final Logger logger = LoggerFactory.getLogger(GuessResource.class);
@@ -52,11 +53,11 @@ public GuessResource(GuessManagement guessManagement) {
this.guessManagement = guessManagement;
}
- @POST
- @JacksonSerialized
- @Path("/schema")
- @Produces(MediaType.APPLICATION_JSON)
- public Response guessSchema(AdapterDescription adapterDescription) {
+ @PostMapping(
+ path = "/schema",
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity guessSchema(@RequestBody AdapterDescription adapterDescription) {
try {
GuessSchema result = guessManagement.guessSchema(adapterDescription);
@@ -64,11 +65,11 @@ public Response guessSchema(AdapterDescription adapterDescription) {
return ok(result);
} catch (ParseException e) {
logger.error("Error while parsing events: ", e);
- return serverError(e);
+ throw new SpMessageException(HttpStatus.INTERNAL_SERVER_ERROR, e);
} catch (AdapterException e) {
logger.error("Error while guessing schema for AdapterDescription: {}, {}", adapterDescription.getElementId(),
e.getMessage());
- return serverError(e);
+ throw new SpMessageException(HttpStatus.INTERNAL_SERVER_ERROR, e);
}
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/HttpServerAdapterResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/HttpServerAdapterResource.java
index 70fea2aa42..4fe4911a64 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/HttpServerAdapterResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/HttpServerAdapterResource.java
@@ -18,27 +18,29 @@
package org.apache.streampipes.rest.extensions.connect;
import org.apache.streampipes.extensions.management.connect.HttpServerAdapterManagement;
+import org.apache.streampipes.rest.shared.exception.SpMessageException;
-import org.apache.http.HttpStatus;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.core.Response;
-
-@Path("/api/v1/worker/live")
+@RestController
+@RequestMapping("/api/v1/worker/live")
public class HttpServerAdapterResource {
- @POST
- @Path("{endpointId}")
- public Response receiveEvent(@PathParam("endpointId") String endpointId,
- byte[] body) {
+ @PostMapping(path = "{endpointId}")
+ public ResponseEntity receiveEvent(@PathVariable("endpointId") String endpointId,
+ @RequestBody byte[] body) {
try {
HttpServerAdapterManagement.INSTANCE.notify(endpointId, body);
- return Response.ok().build();
+ return ResponseEntity.ok().build();
} catch (Exception e) {
- return Response.status(HttpStatus.SC_BAD_REQUEST).entity(e.getMessage()).build();
+ throw new SpMessageException(HttpStatus.BAD_REQUEST, e);
}
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/RuntimeResolvableResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/RuntimeResolvableResource.java
index a49616c66b..0412560c99 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/RuntimeResolvableResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/connect/RuntimeResolvableResource.java
@@ -26,29 +26,27 @@
import org.apache.streampipes.extensions.management.connect.RuntimeResovable;
import org.apache.streampipes.model.runtime.RuntimeOptionsRequest;
import org.apache.streampipes.model.runtime.RuntimeOptionsResponse;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
import org.apache.streampipes.rest.shared.impl.AbstractSharedRestInterface;
-import org.apache.http.HttpStatus;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-
-@Path("/api/v1/worker/resolvable")
+@RestController
+@RequestMapping("/api/v1/worker/resolvable")
public class RuntimeResolvableResource extends AbstractSharedRestInterface {
- @POST
- @Path("{id}/configurations")
- @JacksonSerialized
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response fetchConfigurations(@PathParam("id") String elementId,
- RuntimeOptionsRequest runtimeOptionsRequest) {
+ @PostMapping(
+ path = "{id}/configurations",
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity> fetchConfigurations(@PathVariable("id") String elementId,
+ @RequestBody RuntimeOptionsRequest runtimeOptionsRequest) {
var adapter = RuntimeResovable.getAdapter(elementId);
RuntimeOptionsResponse response;
@@ -66,10 +64,9 @@ public Response fetchConfigurations(@PathParam("id") String elementId,
"This element does not support dynamic options - is the pipeline element description up to date?");
}
} catch (SpConfigurationException e) {
- return jakarta.ws.rs.core.Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .entity(e)
- .build();
+ return ResponseEntity
+ .status(HttpStatus.BAD_REQUEST)
+ .body(e);
}
}
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/AdapterMigrationResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/AdapterMigrationResource.java
index 476f11b64b..1ed5d319ef 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/AdapterMigrationResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/AdapterMigrationResource.java
@@ -22,7 +22,7 @@
import org.apache.streampipes.extensions.api.migration.IAdapterMigrator;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;
import org.apache.streampipes.model.extensions.migration.MigrationRequest;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
+import org.apache.streampipes.model.migration.MigrationResult;
import org.apache.streampipes.sdk.extractor.StaticPropertyExtractor;
import io.swagger.v3.oas.annotations.Operation;
@@ -30,30 +30,30 @@
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import org.apache.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-
-@Path("/api/v1/migrations/adapter")
+@RestController
+@RequestMapping("/api/v1/migrations/adapter")
public class AdapterMigrationResource extends MigrateExtensionsResource<
AdapterDescription,
IStaticPropertyExtractor,
IAdapterMigrator
> {
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @JacksonSerialized
+ @PostMapping(
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(
summary = "Execute the migration for a specific adapter instance", tags = {"Extensions", "Migration"},
responses = {
@ApiResponse(
- responseCode = "" + HttpStatus.SC_OK,
+ responseCode = "200",
description = "The migration was executed. Its result is described in the response. "
+ "The Response needs to be handled accordingly.",
content = @Content(
@@ -61,12 +61,12 @@ public class AdapterMigrationResource extends MigrateExtensionsResource<
name = "Successful migration",
value = "{\"success\": true,\"messages\": \"SUCCESS\", \"element\": {}}"
),
- mediaType = MediaType.APPLICATION_JSON
+ mediaType = MediaType.APPLICATION_JSON_VALUE
)
)
}
)
- public Response migrateAdapter(
+ public ResponseEntity> migrateAdapter(
@Parameter(
description = "request that encompasses the adapter description(AdapterDescription) and "
+ "the configuration of the migration",
@@ -74,7 +74,7 @@ public Response migrateAdapter(
+ "\"modelType\": \"adapter\", \"fromVersion\": 0, \"toVersion\": 1}}",
required = true
)
- MigrationRequest adapterMigrationRequest) {
+ @RequestBody MigrationRequest adapterMigrationRequest) {
return ok(handleMigration(adapterMigrationRequest));
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/DataProcessorMigrationResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/DataProcessorMigrationResource.java
index 8a493a6e08..c062679949 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/DataProcessorMigrationResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/DataProcessorMigrationResource.java
@@ -22,7 +22,7 @@
import org.apache.streampipes.extensions.api.migration.IDataProcessorMigrator;
import org.apache.streampipes.model.extensions.migration.MigrationRequest;
import org.apache.streampipes.model.graph.DataProcessorInvocation;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
+import org.apache.streampipes.model.migration.MigrationResult;
import org.apache.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
import io.swagger.v3.oas.annotations.Operation;
@@ -31,23 +31,24 @@
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.apache.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-
-@Path("api/v1/migrations/processor")
+@RestController
+@RequestMapping("api/v1/migrations/processor")
public class DataProcessorMigrationResource extends MigrateExtensionsResource<
DataProcessorInvocation,
IDataProcessorParameterExtractor,
IDataProcessorMigrator
> {
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @JacksonSerialized
+ @PostMapping(
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(
summary = "Execute the migration for a specific data processor instance", tags = {"Extensions", "Migration"},
responses = {
@@ -60,12 +61,12 @@ public class DataProcessorMigrationResource extends MigrateExtensionsResource<
name = "Successful migration",
value = "{\"success\": true,\"messages\": \"SUCCESS\", \"element\": {}}"
),
- mediaType = MediaType.APPLICATION_JSON
+ mediaType = MediaType.APPLICATION_JSON_VALUE
)
)
}
)
- public Response migrateDataProcessor(
+ public ResponseEntity> migrateDataProcessor(
@Parameter(
description = "Request that encompasses the data processor description (DataProcessorInvocation) and "
+ "the configuration of the migration to be performed",
@@ -73,7 +74,7 @@ public Response migrateDataProcessor(
+ "\"modelType\": \"dprocessor\", \"fromVersion\": 0, \"toVersion\": 1}}",
required = true
)
- MigrationRequest processorMigrationRequest) {
+ @RequestBody MigrationRequest processorMigrationRequest) {
return ok(handleMigration(processorMigrationRequest));
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/DataSinkMigrationResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/DataSinkMigrationResource.java
index 397fce7b49..2ca9ac2771 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/DataSinkMigrationResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/migration/DataSinkMigrationResource.java
@@ -22,7 +22,7 @@
import org.apache.streampipes.extensions.api.migration.IDataSinkMigrator;
import org.apache.streampipes.model.extensions.migration.MigrationRequest;
import org.apache.streampipes.model.graph.DataSinkInvocation;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
+import org.apache.streampipes.model.migration.MigrationResult;
import org.apache.streampipes.sdk.extractor.DataSinkParameterExtractor;
@@ -32,49 +32,50 @@
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.apache.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-
-
-@Path("api/v1/migrations/sink")
+@RestController
+@RequestMapping("/api/v1/migrations/sink")
public class DataSinkMigrationResource extends MigrateExtensionsResource<
- DataSinkInvocation,
- IDataSinkParameterExtractor,
+ DataSinkInvocation,
+ IDataSinkParameterExtractor,
IDataSinkMigrator
- > {
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @JacksonSerialized
+ > {
+ @PostMapping(
+ produces = MediaType.APPLICATION_JSON_VALUE,
+ consumes = MediaType.APPLICATION_JSON_VALUE
+ )
@Operation(
- summary = "Execute the migration for a specific data sink instance", tags = {"Extensions", "Migration"},
- responses = {
- @ApiResponse(
- responseCode = "" + HttpStatus.SC_OK,
- description = "The migration was executed. It's result is described in the response. "
- + "The Response needs to be handled accordingly.",
- content = @Content(
- examples = @ExampleObject(
- name = "Successful migration",
- value = "{\"success\": true,\"messages\": \"SUCCESS\", \"element\": {}}"
- ),
- mediaType = MediaType.APPLICATION_JSON
- )
+ summary = "Execute the migration for a specific data sink instance", tags = {"Extensions", "Migration"},
+ responses = {
+ @ApiResponse(
+ responseCode = "" + HttpStatus.SC_OK,
+ description = "The migration was executed. It's result is described in the response. "
+ + "The Response needs to be handled accordingly.",
+ content = @Content(
+ examples = @ExampleObject(
+ name = "Successful migration",
+ value = "{\"success\": true,\"messages\": \"SUCCESS\", \"element\": {}}"
+ ),
+ mediaType = MediaType.APPLICATION_JSON_VALUE
)
- }
- )
- public Response migrateDataSink(
- @Parameter(
- description = "Request that encompasses the data sink description (DataSinkInvocation) and "
- + "the configuration of the migration to be performed",
- example = "{\"migrationElement\": {}, \"modelMigratorConfig\": {\"targetAppId\": \"app-id\", "
- + "\"modelType\": \"dsink\", \"fromVersion\": 0, \"toVersion\": 1}}",
- required = true
)
- MigrationRequest sinkMigrationRequest) {
+ }
+ )
+ public ResponseEntity> migrateDataSink(
+ @Parameter(
+ description = "Request that encompasses the data sink description (DataSinkInvocation) and "
+ + "the configuration of the migration to be performed",
+ example = "{\"migrationElement\": {}, \"modelMigratorConfig\": {\"targetAppId\": \"app-id\", "
+ + "\"modelType\": \"dsink\", \"fromVersion\": 0, \"toVersion\": 1}}",
+ required = true
+ )
+ @RequestBody MigrationRequest sinkMigrationRequest) {
return ok(handleMigration(sinkMigrationRequest));
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/monitoring/MonitoringResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/monitoring/MonitoringResource.java
index 8cfbea34d4..e907dae6c3 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/monitoring/MonitoringResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/monitoring/MonitoringResource.java
@@ -20,20 +20,21 @@
package org.apache.streampipes.rest.extensions.monitoring;
import org.apache.streampipes.extensions.api.monitoring.SpMonitoringManager;
+import org.apache.streampipes.model.monitoring.SpEndpointMonitoringInfo;
import org.apache.streampipes.rest.extensions.AbstractExtensionsResource;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
-@Path("monitoring")
+@RestController
+@RequestMapping("monitoring")
public class MonitoringResource extends AbstractExtensionsResource {
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public Response getMonitoringInfos() {
+ @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity getMonitoringInfos() {
try {
return ok(SpMonitoringManager.INSTANCE.getMonitoringInfo());
} finally {
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/DataProcessorPipelineElementResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/DataProcessorPipelineElementResource.java
index b583f3c51c..2ce81664c5 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/DataProcessorPipelineElementResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/DataProcessorPipelineElementResource.java
@@ -30,11 +30,13 @@
import org.apache.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
import org.apache.streampipes.svcdiscovery.api.model.SpServicePathPrefix;
-import jakarta.ws.rs.Path;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
-@Path(SpServicePathPrefix.DATA_PROCESSOR)
+@RestController
+@RequestMapping(SpServicePathPrefix.DATA_PROCESSOR)
public class DataProcessorPipelineElementResource extends InvocablePipelineElementResource<
DataProcessorInvocation,
IStreamPipesDataProcessor,
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/DataSinkPipelineElementResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/DataSinkPipelineElementResource.java
index 9b525fd14d..3c4127085f 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/DataSinkPipelineElementResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/DataSinkPipelineElementResource.java
@@ -30,11 +30,13 @@
import org.apache.streampipes.sdk.extractor.DataSinkParameterExtractor;
import org.apache.streampipes.svcdiscovery.api.model.SpServicePathPrefix;
-import jakarta.ws.rs.Path;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
-@Path(SpServicePathPrefix.DATA_SINK)
+@RestController
+@RequestMapping(SpServicePathPrefix.DATA_SINK)
public class DataSinkPipelineElementResource extends InvocablePipelineElementResource
{
@Override
@@ -42,17 +43,15 @@ protected Map getElementDeclarers() {
return DeclarersSingleton.getInstance().getDataStreams();
}
- @GET
- @Path("{streamId}/assets")
- @Produces("application/zip")
- public jakarta.ws.rs.core.Response getAssets(@PathParam("streamId") String streamId) {
+ @GetMapping(path = "{streamId}/assets", produces = "application/zip")
+ public ResponseEntity getAssets(@PathVariable("streamId") String streamId) {
try {
return ok(new AssetZipGenerator(streamId,
getById(streamId)
.getIncludedAssets()).makeZip());
} catch (IOException e) {
e.printStackTrace();
- return jakarta.ws.rs.core.Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).build();
+ return ResponseEntity.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).build();
}
}
diff --git a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/InvocablePipelineElementResource.java b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/InvocablePipelineElementResource.java
index 61e866db90..3f7e160970 100644
--- a/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/InvocablePipelineElementResource.java
+++ b/streampipes-rest-extensions/src/main/java/org/apache/streampipes/rest/extensions/pe/InvocablePipelineElementResource.java
@@ -35,22 +35,20 @@
import org.apache.streampipes.model.runtime.RuntimeOptionsRequest;
import org.apache.streampipes.model.runtime.RuntimeOptionsResponse;
import org.apache.streampipes.rest.extensions.AbstractPipelineElementResource;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
import org.apache.streampipes.sdk.extractor.AbstractParameterExtractor;
import org.apache.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
import java.util.Map;
public abstract class InvocablePipelineElementResource<
@@ -71,13 +69,12 @@ public InvocablePipelineElementResource(Class clazz) {
protected abstract String getInstanceId(String uri, String elementId);
- @POST
- @Path("{elementId}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- @JacksonSerialized
- public jakarta.ws.rs.core.Response invokeRuntime(@PathParam("elementId") String elementId,
- K graph) {
+ @PostMapping(
+ path = "{elementId}",
+ produces = MediaType.APPLICATION_JSON_VALUE,
+ consumes = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity invokeRuntime(@PathVariable("elementId") String elementId,
+ @RequestBody K graph) {
if (isDebug()) {
LOG.info("SP_DEBUG env variable is set - overriding broker hostname and port for local development");
@@ -109,13 +106,12 @@ public jakarta.ws.rs.core.Response invokeRuntime(@PathParam("elementId") String
return ok(new Response(elementId, false, "Could not find the element with id: " + elementId));
}
- @POST
- @Path("{elementId}/configurations")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- @JacksonSerialized
- public jakarta.ws.rs.core.Response fetchConfigurations(@PathParam("elementId") String elementId,
- RuntimeOptionsRequest req) {
+ @PostMapping(
+ path = "{elementId}/configurations",
+ produces = MediaType.APPLICATION_JSON_VALUE,
+ consumes = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity> fetchConfigurations(@PathVariable("elementId") String elementId,
+ @RequestBody RuntimeOptionsRequest req) {
T declarer = getDeclarerById(elementId);
RuntimeOptionsResponse responseOptions;
@@ -131,23 +127,21 @@ public jakarta.ws.rs.core.Response fetchConfigurations(@PathParam("elementId") S
new RuntimeResolvableRequestHandler().handleRuntimeResponse((SupportsRuntimeConfig) declarer, req);
return ok(responseOptions);
} else {
- return jakarta.ws.rs.core.Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).build();
+ return ResponseEntity.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).build();
}
} catch (SpConfigurationException e) {
- return jakarta.ws.rs.core.Response
+ return ResponseEntity
.status(HttpStatus.SC_BAD_REQUEST)
- .entity(e)
- .build();
+ .body(e);
}
}
- @POST
- @Path("{elementId}/output")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- @JacksonSerialized
- public jakarta.ws.rs.core.Response fetchOutputStrategy(@PathParam("elementId") String elementId,
- K runtimeOptionsRequest) {
+ @PostMapping(
+ path = "{elementId}/output",
+ produces = MediaType.APPLICATION_JSON_VALUE,
+ consumes = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity> fetchOutputStrategy(@PathVariable("elementId") String elementId,
+ @RequestBody K runtimeOptionsRequest) {
try {
//I runtimeOptionsRequest = JacksonSerializer.getObjectMapper().readValue(payload, clazz);
ResolvesContainerProvidedOutputStrategy resolvesOutput =
@@ -163,11 +157,9 @@ public jakarta.ws.rs.core.Response fetchOutputStrategy(@PathParam("elementId") S
// TODO move endpoint to /elementId/instances/runningInstanceId
- @DELETE
- @Path("{elementId}/{runningInstanceId}")
- @Produces(MediaType.APPLICATION_JSON)
- public jakarta.ws.rs.core.Response detach(@PathParam("elementId") String elementId,
- @PathParam("runningInstanceId") String runningInstanceId) {
+ @DeleteMapping(path = "{elementId}/{runningInstanceId}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity detach(@PathVariable("elementId") String elementId,
+ @PathVariable("runningInstanceId") String runningInstanceId) {
IStreamPipesRuntime, ?> runningInstance = RunningInstances.INSTANCE.getInvocation(runningInstanceId);
@@ -184,10 +176,8 @@ public jakarta.ws.rs.core.Response detach(@PathParam("elementId") String element
return ok(new Response(elementId, false, "Could not find the running instance with id: " + runningInstanceId));
}
- @GET
- @Path("{elementId}/instances")
- @Produces(MediaType.APPLICATION_JSON)
- public jakarta.ws.rs.core.Response listRunningInstances(@PathParam("elementId") String elementId) {
+ @GetMapping(path = "{elementId}/instances", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity> listRunningInstances(@PathVariable("elementId") String elementId) {
return ok(RunningInstances.INSTANCE.getRunningInstanceIdsForElement(elementId));
}
diff --git a/streampipes-rest-shared/pom.xml b/streampipes-rest-shared/pom.xml
index a2f50afb17..e40097cb19 100644
--- a/streampipes-rest-shared/pom.xml
+++ b/streampipes-rest-shared/pom.xml
@@ -48,45 +48,8 @@
- jakarta.annotation
- jakarta.annotation-api
-
-
- jakarta.servlet
- jakarta.servlet-api
-
-
- jakarta.ws.rs
- jakarta.ws.rs-api
-
-
- org.glassfish.jersey.media
- jersey-media-multipart
-
-
- org.apache.httpcomponents
- httpcore
-
-
-
-
- org.glassfish.jersey.containers
- jersey-container-jetty-http
-
-
- org.eclipse.jetty
- jetty-server
-
-
- org.eclipse.jetty
- jetty-util
-
-
- org.eclipse.jetty
- jetty-continuation
-
-
- test
+ org.springframework.boot
+ spring-boot-starter-web
junit
diff --git a/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/annotation/NoAuthenticationRequired.java b/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/annotation/NoAuthenticationRequired.java
deleted file mode 100644
index e790c93cbd..0000000000
--- a/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/annotation/NoAuthenticationRequired.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- *
- */
-package org.apache.streampipes.rest.shared.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface NoAuthenticationRequired {
-}
diff --git a/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/exception/RestResponseExceptionHandler.java b/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/exception/RestResponseExceptionHandler.java
new file mode 100644
index 0000000000..6ed9eb175d
--- /dev/null
+++ b/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/exception/RestResponseExceptionHandler.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.streampipes.rest.shared.exception;
+
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.context.request.WebRequest;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
+
+@ControllerAdvice
+public class RestResponseExceptionHandler extends ResponseEntityExceptionHandler {
+
+ @ExceptionHandler(value = { SpNotificationException.class })
+ protected ResponseEntity