From 848afd829a81c3ebc7b0ef53bd2c8064fe47dd8f Mon Sep 17 00:00:00 2001 From: sfi2022 <109145215+sfi2022@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:39:32 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Review=20changes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/de/muenchen/mobidam/s3/RestResponseWrapper.java | 5 +++-- .../java/de/muenchen/mobidam/s3/S3OperationWrapper.java | 9 +++++---- src/main/java/de/muenchen/mobidam/s3/S3RouteBuilder.java | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/muenchen/mobidam/s3/RestResponseWrapper.java b/src/main/java/de/muenchen/mobidam/s3/RestResponseWrapper.java index d981d98..c8f9a47 100644 --- a/src/main/java/de/muenchen/mobidam/s3/RestResponseWrapper.java +++ b/src/main/java/de/muenchen/mobidam/s3/RestResponseWrapper.java @@ -1,6 +1,7 @@ package de.muenchen.mobidam.s3; import de.muenchen.mobidam.Constants; +import de.muenchen.mobidam.eai.common.exception.CommonError; import de.muenchen.mobidam.eai.common.exception.ErrorResponseBuilder; import de.muenchen.mobidam.eai.common.exception.MobidamException; import de.muenchen.mobidam.rest.BucketContentInner; @@ -69,8 +70,8 @@ private void presignedUrl(Exchange exchange) throws MobidamException { var links = exchange.getIn().getBody(Collection.class); if (links.isEmpty()) { - var res = ErrorResponseBuilder.build(500, "Empty S3 url file list"); - exchange.getMessage().setBody(res); + CommonError error = ErrorResponseBuilder.build(500, "Empty S3 url file list"); + exchange.getMessage().setBody(error); throw new MobidamException("Empty S3 url file list"); } else { var file = new PresignedUrl(); diff --git a/src/main/java/de/muenchen/mobidam/s3/S3OperationWrapper.java b/src/main/java/de/muenchen/mobidam/s3/S3OperationWrapper.java index cca1f5b..5fa39a0 100644 --- a/src/main/java/de/muenchen/mobidam/s3/S3OperationWrapper.java +++ b/src/main/java/de/muenchen/mobidam/s3/S3OperationWrapper.java @@ -3,6 +3,7 @@ import de.muenchen.mobidam.Constants; import de.muenchen.mobidam.domain.MobidamArchive; import de.muenchen.mobidam.eai.common.CommonConstants; +import de.muenchen.mobidam.eai.common.exception.CommonError; import de.muenchen.mobidam.eai.common.exception.ErrorResponseBuilder; import de.muenchen.mobidam.eai.common.exception.MobidamException; import java.time.Duration; @@ -42,8 +43,8 @@ public void process(Exchange exchange) throws Exception { var objectName = exchange.getIn().getHeader(Constants.PARAMETER_OBJECT_NAME, String.class); if (objectName == null) { - var res = ErrorResponseBuilder.build(400, "Object name is empty"); - exchange.getMessage().setBody(res); + CommonError error = ErrorResponseBuilder.build(400, "Object name is empty"); + exchange.getMessage().setBody(error); throw new MobidamException("Object name is empty"); } @@ -65,8 +66,8 @@ public void process(Exchange exchange) throws Exception { objectName = exchange.getIn().getHeader(Constants.PARAMETER_OBJECT_NAME, String.class); if (objectName == null) { - var res = ErrorResponseBuilder.build(400, "Object name is empty"); - exchange.getMessage().setBody(res); + CommonError error = ErrorResponseBuilder.build(400, "Object name is empty"); + exchange.getMessage().setBody(error); throw new MobidamException("Object name is empty"); } diff --git a/src/main/java/de/muenchen/mobidam/s3/S3RouteBuilder.java b/src/main/java/de/muenchen/mobidam/s3/S3RouteBuilder.java index 330a393..dbeecfe 100644 --- a/src/main/java/de/muenchen/mobidam/s3/S3RouteBuilder.java +++ b/src/main/java/de/muenchen/mobidam/s3/S3RouteBuilder.java @@ -56,10 +56,10 @@ public void configure() { Throwable exception = (Throwable) exchange.getAllProperties().get(Exchange.EXCEPTION_CAUGHT); logException(exchange, exception); if (!(exchange.getMessage().getBody() instanceof CommonError)) { - var res = ErrorResponseBuilder.build(HttpStatus.INTERNAL_SERVER_ERROR.value(), exception.getClass().getName()); - exchange.getMessage().setBody(res); + CommonError error = ErrorResponseBuilder.build(HttpStatus.INTERNAL_SERVER_ERROR.value(), exception.getClass().getName()); + exchange.getMessage().setBody(error); } - exchange.getMessage().setHeader(Exchange.HTTP_RESPONSE_CODE, ((CommonError) exchange.getMessage().getBody()).getStatus()); + exchange.getMessage().setHeader(Exchange.HTTP_RESPONSE_CODE, exchange.getMessage().getBody(CommonError.class).getStatus()); }); from("{{camel.route.common}}")