diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataProcessorApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataProcessorApi.java index 983dc4848d..656d5cf185 100644 --- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataProcessorApi.java +++ b/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataProcessorApi.java @@ -39,8 +39,7 @@ public DataProcessorApi(StreamPipesClientConfig clientConfig) { @Override protected StreamPipesApiPath getBaseResourcePath() { return StreamPipesApiPath.fromBaseApiPath() - .addToPath("sepas") - .addToPath("own"); + .addToPath("sepas"); } @Override diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataSinkApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataSinkApi.java index b6a574fa0b..d53d21047a 100644 --- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataSinkApi.java +++ b/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataSinkApi.java @@ -100,7 +100,6 @@ public DataSinkInvocation getDataSinkForPipelineElement(String templateId, DataS @Override protected StreamPipesApiPath getBaseResourcePath() { return StreamPipesApiPath.fromBaseApiPath() - .addToPath("actions") - .addToPath("own"); + .addToPath("actions"); } } diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataStreamApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataStreamApi.java index 935c474ffc..d3b8d28428 100644 --- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataStreamApi.java +++ b/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataStreamApi.java @@ -103,7 +103,6 @@ public SpKafkaConsumer subscribe(SpDataStream stream, @Override protected StreamPipesApiPath getBaseResourcePath() { return StreamPipesApiPath.fromBaseApiPath() - .addToPath("streams") - .addToPath("own"); + .addToPath("streams"); } } diff --git a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/AbstractPipelineElementResourceManager.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/AbstractPipelineElementResourceManager.java index 7dacac05e4..da3aed9814 100644 --- a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/AbstractPipelineElementResourceManager.java +++ b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/AbstractPipelineElementResourceManager.java @@ -23,6 +23,7 @@ import org.apache.streampipes.storage.api.CRUDStorage; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; public abstract class AbstractPipelineElementResourceManager, @@ -43,6 +44,7 @@ public List findAllIdsOnly() { public List findAllAsInvocation() { return findAll() .stream() + .filter(Objects::nonNull) .map(this::toInvocation) .collect(Collectors.toList()); } @@ -52,7 +54,12 @@ public W find(String elementId) { } public X findAsInvocation(String elementId) { - return toInvocation(find(elementId)); + var element = find(elementId); + if (Objects.nonNull(element)) { + return toInvocation(find(elementId)); + } else { + throw new IllegalArgumentException("Could not find element with id " + elementId); + } } public void delete(String elementId) { diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataProcessorResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataProcessorResource.java index 31991bf874..2d2ea2cc87 100644 --- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataProcessorResource.java +++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataProcessorResource.java @@ -18,6 +18,7 @@ package org.apache.streampipes.rest.impl.pe; +import org.apache.streampipes.model.StreamPipesErrorMessage; import org.apache.streampipes.model.graph.DataProcessorDescription; import org.apache.streampipes.model.graph.DataProcessorInvocation; import org.apache.streampipes.model.message.NotificationType; @@ -55,7 +56,6 @@ public List getAvailable() { } @GET - @Path("/own") @JacksonSerialized @Produces({MediaType.APPLICATION_JSON}) @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE) @@ -65,7 +65,7 @@ public List getOwn() { } @DELETE - @Path("/own/{elementId}") + @Path("/{elementId}") @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized @PreAuthorize(AuthConstants.HAS_DELETE_PIPELINE_ELEMENT_PRIVILEGE) @@ -79,8 +79,12 @@ public Response removeOwn(@PathParam("elementId") String elementId) { @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE) - public DataProcessorInvocation getElement(@PathParam("elementId") String elementId) { - return getDataProcessorResourceManager().findAsInvocation(elementId); + public Response getElement(@PathParam("elementId") String elementId) { + try { + return ok(getDataProcessorResourceManager().findAsInvocation(elementId)); + } catch (IllegalArgumentException e) { + return badRequest(StreamPipesErrorMessage.from(e)); + } } private DataProcessorResourceManager getDataProcessorResourceManager() { diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataSinkResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataSinkResource.java index b289af8bfc..8eb7decebc 100644 --- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataSinkResource.java +++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataSinkResource.java @@ -18,6 +18,7 @@ package org.apache.streampipes.rest.impl.pe; +import org.apache.streampipes.model.StreamPipesErrorMessage; import org.apache.streampipes.model.graph.DataSinkDescription; import org.apache.streampipes.model.graph.DataSinkInvocation; import org.apache.streampipes.model.message.NotificationType; @@ -56,7 +57,6 @@ public List getAvailable() { } @GET - @Path("/own") @Produces({MediaType.APPLICATION_JSON, SpMediaType.JSONLD}) @JacksonSerialized @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE) @@ -66,7 +66,7 @@ public List getOwn() { } @DELETE - @Path("/own/{elementId}") + @Path("/{elementId}") @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized @PreAuthorize(AuthConstants.HAS_DELETE_PIPELINE_ELEMENT_PRIVILEGE) @@ -80,8 +80,12 @@ public Response removeOwn(@PathParam("elementId") String elementId) { @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE) - public DataSinkInvocation getElement(@PathParam("elementId") String elementId) { - return getDataSinkResourceManager().findAsInvocation(elementId); + public Response getElement(@PathParam("elementId") String elementId) { + try { + return ok(getDataSinkResourceManager().findAsInvocation(elementId)); + } catch (IllegalArgumentException e) { + return badRequest(StreamPipesErrorMessage.from(e)); + } } private DataSinkResourceManager getDataSinkResourceManager() { 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 760d664f91..09b79877c6 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 @@ -19,6 +19,7 @@ package org.apache.streampipes.rest.impl.pe; import org.apache.streampipes.model.SpDataStream; +import org.apache.streampipes.model.StreamPipesErrorMessage; import org.apache.streampipes.model.message.NotificationType; import org.apache.streampipes.resource.management.DataStreamResourceManager; import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource; @@ -80,8 +81,12 @@ public Response delete(@PathParam("elementId") String elementId) { @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE) - public SpDataStream getElement(@PathParam("elementId") String elementId) { - return getDataStreamResourceManager().findAsInvocation(elementId); + public Response getElement(@PathParam("elementId") String elementId) { + try { + return ok(getDataStreamResourceManager().findAsInvocation(elementId)); + } catch (IllegalArgumentException e) { + return badRequest(StreamPipesErrorMessage.from(e)); + } } @POST diff --git a/ui/projects/streampipes/platform-services/src/lib/apis/pipeline-element.service.ts b/ui/projects/streampipes/platform-services/src/lib/apis/pipeline-element.service.ts index 51bf9ed543..66aa59918a 100644 --- a/ui/projects/streampipes/platform-services/src/lib/apis/pipeline-element.service.ts +++ b/ui/projects/streampipes/platform-services/src/lib/apis/pipeline-element.service.ts @@ -38,7 +38,7 @@ export class PipelineElementService { ) {} getDataProcessors(): Observable { - return this.http.get(this.dataProcessorsUrl + '/own').pipe( + return this.http.get(this.dataProcessorsUrl).pipe( map(data => { return (data as []).map(dpi => DataProcessorInvocation.fromData(dpi), @@ -48,7 +48,7 @@ export class PipelineElementService { } getDataSinks(): Observable { - return this.http.get(this.dataSinksUrl + '/own').pipe( + return this.http.get(this.dataSinksUrl).pipe( map(data => { return (data as []).map(dpi => DataSinkInvocation.fromData(dpi), @@ -58,7 +58,7 @@ export class PipelineElementService { } getDataStreams(): Observable { - return this.http.get(this.dataStreamsUrl + '/own').pipe( + return this.http.get(this.dataStreamsUrl).pipe( map(data => { return (data as []).map(dpi => { if (