From fe5675c12b20a0c69bb1a3d6f06e3950fff07b04 Mon Sep 17 00:00:00 2001 From: Aleksandar Stanchev Date: Mon, 16 Oct 2023 12:42:40 +0300 Subject: [PATCH] preserve httpStatus for other reason on faild create of thing Signed-off-by: Aleksandar Stanchev --- .../commands/exceptions/ThingNotCreatableException.java | 5 +++-- .../ditto/things/service/enforcement/ThingEnforcerActor.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/exceptions/ThingNotCreatableException.java b/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/exceptions/ThingNotCreatableException.java index d17f4c1632..b283ece304 100755 --- a/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/exceptions/ThingNotCreatableException.java +++ b/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/exceptions/ThingNotCreatableException.java @@ -113,8 +113,9 @@ public static Builder newBuilderForPolicyExisting(final ThingId thingId, final P * @param reason the reason why the implicit policy creation failed. * @return the builder. */ - public static Builder newBuilderForOtherReason(final ThingId thingId, final PolicyId policyId, final String reason) { - return new Builder(thingId, policyId, reason); + public static Builder newBuilderForOtherReason(final HttpStatus httpStatus, final ThingId thingId, final PolicyId policyId, final String reason) { + return new Builder(thingId, policyId, reason) + .httpStatus(httpStatus); } /** diff --git a/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingEnforcerActor.java b/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingEnforcerActor.java index 49ed602e7d..8a24dec6b5 100644 --- a/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingEnforcerActor.java +++ b/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingEnforcerActor.java @@ -425,7 +425,7 @@ private ThingNotCreatableException reportInitialPolicyCreationFailure(final Poli .dittoHeaders(command.getDittoHeaders()) .build(); } else { - return ThingNotCreatableException.newBuilderForOtherReason(command.getEntityId(), policyId, + return ThingNotCreatableException.newBuilderForOtherReason(policyException.getHttpStatus(), command.getEntityId(), policyId, policyException.getMessage()) .dittoHeaders(command.getDittoHeaders()) .build();