Skip to content

Commit

Permalink
♻️ Review changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfi2022 committed Nov 22, 2024
1 parent 658b045 commit 848afd8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/main/java/de/muenchen/mobidam/s3/RestResponseWrapper.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/de/muenchen/mobidam/s3/S3OperationWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}

Expand All @@ -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");
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/muenchen/mobidam/s3/S3RouteBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}}")
Expand Down

0 comments on commit 848afd8

Please sign in to comment.