You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2022/11/24 10:26:49 UTC

[streampipes] 01/01: [STREAMPIPES-649] Update REST API for data streams

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

zehnder pushed a commit to branch STREAMPIPES-649
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit 84d7b3a13800683b60c38484958f7f0f59e7afee
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Thu Nov 24 11:26:35 2022 +0100

    [STREAMPIPES-649] Update REST API for data streams
---
 .../rest/impl/pe/DataStreamResource.java           | 108 +++++++++++++--------
 1 file changed, 68 insertions(+), 40 deletions(-)

diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataStreamResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataStreamResource.java
index 4d328cc7a..f0d5a0833 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataStreamResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataStreamResource.java
@@ -25,60 +25,88 @@ import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResourc
 import org.apache.streampipes.rest.security.AuthConstants;
 import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
 import org.apache.streampipes.rest.shared.util.SpMediaType;
+
 import org.springframework.security.access.prepost.PostFilter;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Component;
 
-import javax.ws.rs.*;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+
 import java.util.List;
 
 @Component
 @Path("/v2/streams")
 public class DataStreamResource extends AbstractAuthGuardedRestResource {
 
-	@GET
-	@Path("/available")
-	@Produces(MediaType.APPLICATION_JSON)
-	@JacksonSerialized
-	@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
-	@PostFilter("hasPermission(filterObject.elementId, 'READ')")
-	public List<SpDataStream> getAvailable() {
-		return getDataStreamResourceManager().findAll();
-	}
+  @GET
+  @Path("/available")
+  @Produces(MediaType.APPLICATION_JSON)
+  @JacksonSerialized
+  @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
+  @PostFilter("hasPermission(filterObject.elementId, 'READ')")
+  public List<SpDataStream> getAvailable() {
+    return getDataStreamResourceManager().findAll();
+  }
+
+  @GET
+  @Path("/")
+  @Produces({MediaType.APPLICATION_JSON, SpMediaType.JSONLD})
+  @JacksonSerialized
+  @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
+  @PostFilter("hasPermission(filterObject.elementId, 'READ')")
+  public List<SpDataStream> get() {
+    return getDataStreamResourceManager().findAllAsInvocation();
+  }
+
+  @GET
+  @Path("/own")
+  @Produces({MediaType.APPLICATION_JSON, SpMediaType.JSONLD})
+  @JacksonSerialized
+  @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
+  @PostFilter("hasPermission(filterObject.elementId, 'READ')")
+  @Deprecated(since = "0.71.0", forRemoval = true)
+  public List<SpDataStream> getOwn() {
+    return getDataStreamResourceManager().findAllAsInvocation();
+  }
+
+  @DELETE
+  @Path("/own/{elementId}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @JacksonSerialized
+  @PreAuthorize(AuthConstants.HAS_DELETE_PIPELINE_ELEMENT_PRIVILEGE)
+  @Deprecated(since = "0.71.0", forRemoval = true)
+  public Response removeOwn(@PathParam("elementId") String elementId) {
+    getDataStreamResourceManager().delete(elementId);
+    return constructSuccessMessage(NotificationType.STORAGE_SUCCESS.uiNotification());
+  }
 
-	@GET
-	@Path("/own")
-	@Produces({MediaType.APPLICATION_JSON, SpMediaType.JSONLD})
-	@JacksonSerialized
-	@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
-	@PostFilter("hasPermission(filterObject.elementId, 'READ')")
-	public List<SpDataStream> getOwn() {
-		return getDataStreamResourceManager().findAllAsInvocation();
-	}
+  @DELETE
+  @Path("/{elementId}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @JacksonSerialized
+  @PreAuthorize(AuthConstants.HAS_DELETE_PIPELINE_ELEMENT_PRIVILEGE)
+  public Response delete(@PathParam("elementId") String elementId) {
+    getDataStreamResourceManager().delete(elementId);
+    return constructSuccessMessage(NotificationType.STORAGE_SUCCESS.uiNotification());
+  }
 
-	@DELETE
-	@Path("/own/{elementId}")
-	@Produces(MediaType.APPLICATION_JSON)
-	@JacksonSerialized
-	@PreAuthorize(AuthConstants.HAS_DELETE_PIPELINE_ELEMENT_PRIVILEGE)
-	public Response removeOwn(@PathParam("elementId") String elementId) {
-		getDataStreamResourceManager().delete(elementId);
-		return constructSuccessMessage(NotificationType.STORAGE_SUCCESS.uiNotification());
-	}
-	
-	@Path("/{elementId}")
-	@GET
-	@Produces(MediaType.APPLICATION_JSON)
-	@JacksonSerialized
-	@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
-	public SpDataStream getElement(@PathParam("elementId") String elementId) {
-		return getDataStreamResourceManager().findAsInvocation(elementId);
-	}
+  @Path("/{elementId}")
+  @GET
+  @Produces(MediaType.APPLICATION_JSON)
+  @JacksonSerialized
+  @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
+  public SpDataStream getElement(@PathParam("elementId") String elementId) {
+    return getDataStreamResourceManager().findAsInvocation(elementId);
+  }
 
-	private DataStreamResourceManager getDataStreamResourceManager() {
-		return getSpResourceManager().manageDataStreams();
-	}
+  private DataStreamResourceManager getDataStreamResourceManager() {
+    return getSpResourceManager().manageDataStreams();
+  }
 
 }