From af04c40abc793b870a9311ea47b58196f741914a Mon Sep 17 00:00:00 2001 From: Stefan Obermeier Date: Tue, 25 Apr 2023 11:57:41 +0200 Subject: [PATCH 1/4] Add variable to set location of checkstyle base path --- streampipes-client/pom.xml | 7 ++++++- streampipes-rest-extensions/pom.xml | 2 +- streampipes-rest-shared/pom.xml | 3 ++- streampipes-rest/pom.xml | 7 ++++++- tools/maven/checkstyle.xml | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/streampipes-client/pom.xml b/streampipes-client/pom.xml index f24e663780..4b21b3c9e0 100644 --- a/streampipes-client/pom.xml +++ b/streampipes-client/pom.xml @@ -97,8 +97,13 @@ org.apache.maven.plugins maven-checkstyle-plugin + + + checkstyle.config.path=${project.parent.basedir} + + - + \ No newline at end of file diff --git a/streampipes-rest-extensions/pom.xml b/streampipes-rest-extensions/pom.xml index d95d3e45de..192260917d 100644 --- a/streampipes-rest-extensions/pom.xml +++ b/streampipes-rest-extensions/pom.xml @@ -75,4 +75,4 @@ - + \ No newline at end of file diff --git a/streampipes-rest-shared/pom.xml b/streampipes-rest-shared/pom.xml index de74e640dc..e94975373e 100644 --- a/streampipes-rest-shared/pom.xml +++ b/streampipes-rest-shared/pom.xml @@ -17,7 +17,8 @@ ~ --> - + streampipes-parent org.apache.streampipes diff --git a/streampipes-rest/pom.xml b/streampipes-rest/pom.xml index 64eb418d7c..94bcca3803 100644 --- a/streampipes-rest/pom.xml +++ b/streampipes-rest/pom.xml @@ -159,7 +159,12 @@ org.apache.maven.plugins maven-checkstyle-plugin + + + checkstyle.config.base.path=${project.parent.basedir}/tools/maven + + - + \ No newline at end of file diff --git a/tools/maven/checkstyle.xml b/tools/maven/checkstyle.xml index 83861dbe07..a86ef413dc 100644 --- a/tools/maven/checkstyle.xml +++ b/tools/maven/checkstyle.xml @@ -28,7 +28,7 @@ page at http://checkstyle.sourceforge.net/config.html --> - + From e227fe9b584338328048ef038f39d9d38dc0ea11 Mon Sep 17 00:00:00 2001 From: Stefan Obermeier Date: Tue, 25 Apr 2023 15:36:35 +0200 Subject: [PATCH 2/4] Fix checkstyle.config.base.path in streampipes-client --- streampipes-client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/streampipes-client/pom.xml b/streampipes-client/pom.xml index 4b21b3c9e0..25c96b1a12 100644 --- a/streampipes-client/pom.xml +++ b/streampipes-client/pom.xml @@ -99,7 +99,7 @@ maven-checkstyle-plugin - checkstyle.config.path=${project.parent.basedir} + checkstyle.config.base.path=${project.parent.basedir}/tools/maven From 32d0b82cca6698897a65397d5e2884dc8220fa68 Mon Sep 17 00:00:00 2001 From: Stefan Obermeier Date: Wed, 26 Apr 2023 12:10:19 +0200 Subject: [PATCH 3/4] Map REST 404 to Optional.empty in Java --- .../client/api/AbstractTypedClientApi.java | 14 ++++++- .../streampipes/client/api/CRUDApi.java | 3 +- .../client/api/DataLakeMeasureApi.java | 3 +- .../client/api/DataProcessorApi.java | 3 +- .../streampipes/client/api/DataSinkApi.java | 3 +- .../streampipes/client/api/DataStreamApi.java | 3 +- .../streampipes/client/api/PipelineApi.java | 3 +- .../api/PipelineElementTemplateApi.java | 3 +- .../streampipes/client/http/HttpRequest.java | 18 ++++++--- .../exceptions/SpHttpErrorStatusCode.java | 39 +++++++++++++++++++ .../impl/AbstractSharedRestInterface.java | 7 +++- .../function/FunctionContextGenerator.java | 5 ++- 12 files changed, 85 insertions(+), 19 deletions(-) create mode 100644 streampipes-commons/src/main/java/org/apache/streampipes/commons/exceptions/SpHttpErrorStatusCode.java diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/AbstractTypedClientApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/AbstractTypedClientApi.java index abd60c439a..ff3964bd8e 100644 --- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/AbstractTypedClientApi.java +++ b/streampipes-client/src/main/java/org/apache/streampipes/client/api/AbstractTypedClientApi.java @@ -22,9 +22,11 @@ import org.apache.streampipes.client.serializer.ListSerializer; import org.apache.streampipes.client.serializer.ObjectSerializer; import org.apache.streampipes.client.util.StreamPipesApiPath; +import org.apache.streampipes.commons.exceptions.SpHttpErrorStatusCode; import org.apache.streampipes.commons.exceptions.SpRuntimeException; import java.util.List; +import java.util.Optional; public abstract class AbstractTypedClientApi extends AbstractClientApi { @@ -40,9 +42,17 @@ protected List getAll(StreamPipesApiPath apiPath) throws SpRuntimeException { return new GetRequest<>(clientConfig, apiPath, targetClass, serializer).executeRequest(); } - protected T getSingle(StreamPipesApiPath apiPath) throws SpRuntimeException { + protected Optional getSingle(StreamPipesApiPath apiPath) throws SpRuntimeException { ObjectSerializer serializer = new ObjectSerializer<>(); - return new GetRequest<>(clientConfig, apiPath, targetClass, serializer).executeRequest(); + try { + return Optional.of(new GetRequest<>(clientConfig, apiPath, targetClass, serializer).executeRequest()); + } catch (SpHttpErrorStatusCode e) { + if (e.getHttpStatusCode() == 404) { + return Optional.empty(); + } else { + throw e; + } + } } protected abstract StreamPipesApiPath getBaseResourcePath(); diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/CRUDApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/CRUDApi.java index 6cabcc09ab..cbe4221850 100644 --- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/CRUDApi.java +++ b/streampipes-client/src/main/java/org/apache/streampipes/client/api/CRUDApi.java @@ -18,10 +18,11 @@ package org.apache.streampipes.client.api; import java.util.List; +import java.util.Optional; public interface CRUDApi { - V get(K id); + Optional get(K id); List all(); diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataLakeMeasureApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataLakeMeasureApi.java index d59b4898ea..702723ad44 100644 --- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataLakeMeasureApi.java +++ b/streampipes-client/src/main/java/org/apache/streampipes/client/api/DataLakeMeasureApi.java @@ -23,6 +23,7 @@ import org.apache.streampipes.model.datalake.DataLakeMeasure; import java.util.List; +import java.util.Optional; public class DataLakeMeasureApi extends AbstractTypedClientApi implements CRUDApi { @@ -31,7 +32,7 @@ public DataLakeMeasureApi(StreamPipesClientConfig clientConfig) { super(clientConfig, DataLakeMeasure.class); } - public DataLakeMeasure get(String id) { + public Optional get(String id) { return getSingle(getBaseResourcePath().addToPath(id)); } 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 656d5cf185..64f7ea7ee4 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 @@ -28,6 +28,7 @@ import org.apache.streampipes.model.graph.DataProcessorInvocation; import java.util.List; +import java.util.Optional; public class DataProcessorApi extends AbstractTypedClientApi implements CRUDApi { @@ -43,7 +44,7 @@ protected StreamPipesApiPath getBaseResourcePath() { } @Override - public DataProcessorInvocation get(String s) { + public Optional get(String s) { return getSingle(getBaseResourcePath().addToPath(s)); } 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 d53d21047a..694d458d62 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 @@ -27,6 +27,7 @@ import org.apache.streampipes.model.graph.DataSinkInvocation; import java.util.List; +import java.util.Optional; public class DataSinkApi extends AbstractTypedClientApi implements CRUDApi { @@ -36,7 +37,7 @@ public DataSinkApi(StreamPipesClientConfig clientConfig) { } @Override - public DataSinkInvocation get(String s) { + public Optional get(String s) { return getSingle(getBaseResourcePath().addToPath(s)); } 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 d3b8d28428..dd0c3e8247 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 @@ -28,6 +28,7 @@ import java.net.URLEncoder; import java.util.List; +import java.util.Optional; public class DataStreamApi extends AbstractTypedClientApi implements CRUDApi { @@ -36,7 +37,7 @@ public DataStreamApi(StreamPipesClientConfig clientConfig) { } @Override - public SpDataStream get(String streamId) { + public Optional get(String streamId) { return getSingle(StreamPipesApiPath.fromBaseApiPath() .addToPath("streams").addToPath(streamId)); } diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/PipelineApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/PipelineApi.java index 888c15df79..8cc180057e 100644 --- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/PipelineApi.java +++ b/streampipes-client/src/main/java/org/apache/streampipes/client/api/PipelineApi.java @@ -26,6 +26,7 @@ import org.apache.streampipes.model.pipeline.PipelineOperationStatus; import java.util.List; +import java.util.Optional; public class PipelineApi extends AbstractTypedClientApi implements CRUDApi { @@ -34,7 +35,7 @@ public PipelineApi(StreamPipesClientConfig clientConfig) { } @Override - public Pipeline get(String pipelineId) { + public Optional get(String pipelineId) { return getSingle(getBaseResourcePath().addToPath(pipelineId)); } diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/PipelineElementTemplateApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/PipelineElementTemplateApi.java index 3038fefdde..33c9c22c53 100644 --- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/PipelineElementTemplateApi.java +++ b/streampipes-client/src/main/java/org/apache/streampipes/client/api/PipelineElementTemplateApi.java @@ -22,6 +22,7 @@ import org.apache.streampipes.model.template.PipelineElementTemplate; import java.util.List; +import java.util.Optional; public class PipelineElementTemplateApi extends AbstractTypedClientApi implements CRUDApi { @@ -31,7 +32,7 @@ public PipelineElementTemplateApi(StreamPipesClientConfig clientConfig) { } @Override - public PipelineElementTemplate get(String id) { + public Optional get(String id) { return getSingle(getBaseResourcePath().addToPath(id)); } diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java b/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java index b0ffc92ad5..e34a1225ba 100644 --- a/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java +++ b/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java @@ -22,6 +22,7 @@ import org.apache.streampipes.client.model.StreamPipesClientConfig; import org.apache.streampipes.client.serializer.Serializer; import org.apache.streampipes.client.util.StreamPipesApiPath; +import org.apache.streampipes.commons.exceptions.SpHttpErrorStatusCode; import org.apache.streampipes.commons.exceptions.SpRuntimeException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -100,14 +101,19 @@ public T executeRequest() { if (status.getStatusCode() == HttpStatus.SC_OK) { return afterRequest(serializer, response.getEntity()); } else { - if (status.getStatusCode() == 401) { - throw new SpRuntimeException( - " 401 - Access to this resource is forbidden - did you provide a poper API key or client secret?"); - } else { - throw new SpRuntimeException(status.getStatusCode() + " - " + status.getReasonPhrase()); + switch (status.getStatusCode()) { + case HttpStatus.SC_UNAUTHORIZED: + throw new SpHttpErrorStatusCode( + " 401 - Access to this resource is forbidden - did you provide a poper API key or client secret?", + 401); + case HttpStatus.SC_NOT_FOUND: + throw new SpHttpErrorStatusCode(" 404 - The requested resource could not be found.", 404); + default: + throw new SpHttpErrorStatusCode(status.getStatusCode() + " - " + status.getReasonPhrase(), + status.getStatusCode()); } } - } catch (IOException | SpRuntimeException e) { + } catch (IOException e) { throw new SpRuntimeException( "Could not connect to the StreamPipes API - please check that StreamPipes is available", e); } diff --git a/streampipes-commons/src/main/java/org/apache/streampipes/commons/exceptions/SpHttpErrorStatusCode.java b/streampipes-commons/src/main/java/org/apache/streampipes/commons/exceptions/SpHttpErrorStatusCode.java new file mode 100644 index 0000000000..a4188e9664 --- /dev/null +++ b/streampipes-commons/src/main/java/org/apache/streampipes/commons/exceptions/SpHttpErrorStatusCode.java @@ -0,0 +1,39 @@ +/* + * 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.commons.exceptions; + +public class SpHttpErrorStatusCode extends SpRuntimeException { + + private static final long serialVersionUID = 2289470758226670270L; + private Integer httpStatusCode; + + /** + * Creates a new Exception with the given message and null as the cause. + * + * @param message The exception message + */ + public SpHttpErrorStatusCode(String message, Integer httpStatusCode) { + super(message); + this.httpStatusCode = httpStatusCode; + } + + public Integer getHttpStatusCode() { + return httpStatusCode; + } +} diff --git a/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/impl/AbstractSharedRestInterface.java b/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/impl/AbstractSharedRestInterface.java index 4d5b78a9c1..74897e29b0 100644 --- a/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/impl/AbstractSharedRestInterface.java +++ b/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/impl/AbstractSharedRestInterface.java @@ -31,12 +31,15 @@ protected Response badRequest(T entity) { return error(entity, 400); } + protected Response notFound(T entity) { + return error(entity, 404); + } + protected Response serverError(T entity) { return error(entity, 500); } - protected Response error(T entity, - Integer statusCode) { + protected Response error(T entity, Integer statusCode) { return Response .status(statusCode) .entity(entity) diff --git a/streampipes-wrapper-standalone/src/main/java/org/apache/streampipes/wrapper/standalone/function/FunctionContextGenerator.java b/streampipes-wrapper-standalone/src/main/java/org/apache/streampipes/wrapper/standalone/function/FunctionContextGenerator.java index c3465b4138..9b56d0d078 100644 --- a/streampipes-wrapper-standalone/src/main/java/org/apache/streampipes/wrapper/standalone/function/FunctionContextGenerator.java +++ b/streampipes-wrapper-standalone/src/main/java/org/apache/streampipes/wrapper/standalone/function/FunctionContextGenerator.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.Map; -import java.util.stream.Collectors; +import java.util.Optional; public class FunctionContextGenerator { @@ -60,6 +60,7 @@ private List receiveStreams(StreamPipesClient client) { return this.streamIds .stream() .map(streamId -> client.streams().get(streamId)) - .collect(Collectors.toList()); + .flatMap(Optional::stream) + .toList(); } } From d11089eb102ae759a3c59d3f436c4f038d53865c Mon Sep 17 00:00:00 2001 From: Stefan Obermeier Date: Wed, 26 Apr 2023 12:11:41 +0200 Subject: [PATCH 4/4] Return 404 if requested pipeline does not exist --- .../rest/impl/PipelineResource.java | 97 ++++++++----------- 1 file changed, 38 insertions(+), 59 deletions(-) diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java index eafa7179d3..b71064f3c7 100644 --- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java +++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java @@ -18,7 +18,6 @@ package org.apache.streampipes.rest.impl; - import org.apache.streampipes.commons.exceptions.NoMatchingFormatException; import org.apache.streampipes.commons.exceptions.NoMatchingJsonSchemaException; import org.apache.streampipes.commons.exceptions.NoMatchingProtocolException; @@ -76,14 +75,12 @@ public class PipelineResource extends AbstractAuthGuardedRestResource { @GET @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized - @Operation(summary = "Get all pipelines of the current user", - tags = {"Pipeline"}, - responses = { - @ApiResponse(content = { - @Content( + @Operation(summary = "Get all pipelines of the current user", tags = {"Pipeline"}, responses = { + @ApiResponse(content = { + @Content( mediaType = "application/json", - array = @ArraySchema(schema = @Schema(implementation = Pipeline.class))) - })}) + array = @ArraySchema(schema = @Schema(implementation = Pipeline.class)) + )})}) @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE) @PostFilter("hasPermission(filterObject.pipelineId, 'READ')") public List get() { @@ -94,8 +91,7 @@ public List get() { @Produces(MediaType.APPLICATION_JSON) @Path("/{pipelineId}/status") @JacksonSerialized - @Operation(summary = "Get the pipeline status of a given pipeline", - tags = {"Pipeline"}) + @Operation(summary = "Get the pipeline status of a given pipeline", tags = {"Pipeline"}) @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE) public Response getPipelineStatus(@PathParam("pipelineId") String pipelineId) { return ok(PipelineStatusManager.getPipelineStatus(pipelineId, 5)); @@ -105,8 +101,7 @@ public Response getPipelineStatus(@PathParam("pipelineId") String pipelineId) { @Path("/{pipelineId}") @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized - @Operation(summary = "Delete a pipeline with a given id", - tags = {"Pipeline"}) + @Operation(summary = "Delete a pipeline with a given id", tags = {"Pipeline"}) @PreAuthorize(AuthConstants.HAS_DELETE_PIPELINE_PRIVILEGE) public Response removeOwn(@PathParam("pipelineId") String pipelineId) { PipelineManager.deletePipeline(pipelineId); @@ -117,19 +112,23 @@ public Response removeOwn(@PathParam("pipelineId") String pipelineId) { @Path("/{pipelineId}") @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized - @Operation(summary = "Get a specific pipeline with the given id", - tags = {"Pipeline"}) + @Operation(summary = "Get a specific pipeline with the given id", tags = {"Pipeline"}) @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE) public Response getElement(@PathParam("pipelineId") String pipelineId) { - return ok(PipelineManager.getPipeline(pipelineId)); + Pipeline foundPipeline = PipelineManager.getPipeline(pipelineId); + + if (foundPipeline == null) { + return notFound("Pipeline with " + pipelineId + " not found."); + } else { + return ok(PipelineManager.getPipeline(pipelineId)); + } } @Path("/{pipelineId}/start") @GET @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized - @Operation(summary = "Start the pipeline with the given id", - tags = {"Pipeline"}) + @Operation(summary = "Start the pipeline with the given id", tags = {"Pipeline"}) @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE) public Response start(@PathParam("pipelineId") String pipelineId) { try { @@ -146,28 +145,24 @@ public Response start(@PathParam("pipelineId") String pipelineId) { @GET @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized - @Operation(summary = "Stop the pipeline with the given id", - tags = {"Pipeline"}) + @Operation(summary = "Stop the pipeline with the given id", tags = {"Pipeline"}) @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE) public Response stop(@PathParam("pipelineId") String pipelineId, - @QueryParam("forceStop") @DefaultValue("false") boolean forceStop) { + @QueryParam("forceStop") @DefaultValue("false") boolean forceStop) { try { PipelineOperationStatus status = PipelineManager.stopPipeline(pipelineId, forceStop); return ok(status); - } catch - (Exception e) { + } catch (Exception e) { e.printStackTrace(); - return constructErrorMessage( - new Notification(NotificationType.UNKNOWN_ERROR.title(), NotificationType.UNKNOWN_ERROR.description(), - e.getMessage())); + return constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR.title(), + NotificationType.UNKNOWN_ERROR.description(), e.getMessage())); } } @POST @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized - @Operation(summary = "Store a new pipeline", - tags = {"Pipeline"}) + @Operation(summary = "Store a new pipeline", tags = {"Pipeline"}) @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE) public Response addPipeline(Pipeline pipeline) { @@ -184,21 +179,17 @@ public Response addPipeline(Pipeline pipeline) { @Hidden @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE) @PostAuthorize("hasPermission(returnObject, 'READ')") - public PipelineElementRecommendationMessage recommend(Pipeline pipeline, - @PathParam("recId") String baseRecElement) { + public PipelineElementRecommendationMessage recommend(Pipeline pipeline, @PathParam("recId") String baseRecElement) { try { return Operations.findRecommendedElements(pipeline, baseRecElement); } catch (JsonSyntaxException e) { - throw new WebApplicationException(badRequest(new Notification(NotificationType.UNKNOWN_ERROR, - e.getMessage()))); + throw new WebApplicationException(badRequest(new Notification(NotificationType.UNKNOWN_ERROR, e.getMessage()))); } catch (NoSuitableSepasAvailableException e) { - throw new WebApplicationException(badRequest(new Notification(NotificationType.NO_SEPA_FOUND, - e.getMessage()))); + throw new WebApplicationException(badRequest(new Notification(NotificationType.NO_SEPA_FOUND, e.getMessage()))); } catch (Exception e) { e.printStackTrace(); throw new WebApplicationException( - serverError(constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR, - e.getMessage())))); + serverError(constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR, e.getMessage())))); } } @@ -224,26 +215,20 @@ public Response update(Pipeline pipeline) { try { return ok(Operations.validatePipeline(pipeline)); } catch (JsonSyntaxException e) { - return badRequest(new Notification(NotificationType.UNKNOWN_ERROR, - e.getMessage())); + return badRequest(new Notification(NotificationType.UNKNOWN_ERROR, e.getMessage())); } catch (NoMatchingSchemaException e) { - return badRequest(new Notification(NotificationType.NO_VALID_CONNECTION, - e.getMessage())); + return badRequest(new Notification(NotificationType.NO_VALID_CONNECTION, e.getMessage())); } catch (NoMatchingFormatException e) { - return badRequest(new Notification(NotificationType.NO_MATCHING_FORMAT_CONNECTION, - e.getMessage())); + return badRequest(new Notification(NotificationType.NO_MATCHING_FORMAT_CONNECTION, e.getMessage())); } catch (NoMatchingProtocolException e) { - return badRequest(new Notification(NotificationType.NO_MATCHING_PROTOCOL_CONNECTION, - e.getMessage())); + return badRequest(new Notification(NotificationType.NO_MATCHING_PROTOCOL_CONNECTION, e.getMessage())); } catch (RemoteServerNotAccessibleException | NoMatchingJsonSchemaException e) { - return serverError(new Notification(NotificationType.REMOTE_SERVER_NOT_ACCESSIBLE - , e.getMessage())); + return serverError(new Notification(NotificationType.REMOTE_SERVER_NOT_ACCESSIBLE, e.getMessage())); } catch (InvalidConnectionException e) { return badRequest(e.getErrorLog()); } catch (Exception e) { e.printStackTrace(); - return serverError(new Notification(NotificationType.UNKNOWN_ERROR, - e.getMessage())); + return serverError(new Notification(NotificationType.UNKNOWN_ERROR, e.getMessage())); } } @@ -251,11 +236,9 @@ public Response update(Pipeline pipeline) { @Path("/{pipelineId}") @Produces(MediaType.APPLICATION_JSON) @JacksonSerialized - @Operation(summary = "Update an existing pipeline", - tags = {"Pipeline"}) + @Operation(summary = "Update an existing pipeline", tags = {"Pipeline"}) @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE) - public Response overwritePipeline(@PathParam("pipelineId") String pipelineId, - Pipeline pipeline) { + public Response overwritePipeline(@PathParam("pipelineId") String pipelineId, Pipeline pipeline) { Pipeline storedPipeline = getPipelineStorage().getPipeline(pipelineId); if (!storedPipeline.isRunning()) { storedPipeline.setStreams(pipeline.getStreams()); @@ -275,14 +258,10 @@ public Response overwritePipeline(@PathParam("pipelineId") String pipelineId, @Produces(MediaType.APPLICATION_JSON) @Path("/contains/{elementId}") @JacksonSerialized - @Operation(summary = "Returns all pipelines that contain the element with the elementId", - tags = {"Pipeline"}, - responses = { - @ApiResponse(content = { - @Content( - mediaType = "application/json", - array = @ArraySchema(schema = @Schema(implementation = Pipeline.class))) - })}) + @Operation(summary = "Returns all pipelines that contain the element with the elementId", tags = { + "Pipeline"}, responses = {@ApiResponse(content = { + @Content(mediaType = "application/json", + array = @ArraySchema(schema = @Schema(implementation = Pipeline.class)))})}) @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE) @PostFilter("hasPermission(filterObject.pipelineId, 'READ')") public List getPipelinesContainingElement(@PathParam("elementId") String elementId) {