From 163db3595e017920ef1339df6d521bfb605672d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20J=C3=A4ckle?= Date: Tue, 14 Jan 2025 11:54:37 +0100 Subject: [PATCH] fix wrongly done validation of removal of desired feature properties * it was enforced that "required" properties could not be removed * this does not make sense for desired properties, as they are all optional by convention --- .../DeleteFeatureDesiredPropertiesStrategy.java | 17 ++++------------- .../DeleteFeatureDesiredPropertyStrategy.java | 17 ++++------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertiesStrategy.java b/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertiesStrategy.java index 5e4c7013b4..1c5c80b071 100644 --- a/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertiesStrategy.java +++ b/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertiesStrategy.java @@ -13,6 +13,7 @@ package org.eclipse.ditto.things.service.persistence.actors.strategies.commands; import java.util.Optional; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import javax.annotation.Nullable; @@ -68,19 +69,9 @@ protected CompletionStage performWotValidation( @Nullable final Thing previousThing, @Nullable final Thing previewThing ) { - return wotThingModelValidator.validateFeatureScopedDeletion( - Optional.ofNullable(previousThing) - .flatMap(Thing::getDefinition) - .orElse(null), - Optional.ofNullable(previousThing) - .flatMap(Thing::getFeatures) - .flatMap(f -> f.getFeature(command.getFeatureId())) - .flatMap(Feature::getDefinition) - .orElse(null), - command.getFeatureId(), - command.getResourcePath(), - command.getDittoHeaders() - ).thenApply(aVoid -> command); + // it is always ok to delete a feature's desired properties - no need to validate for e.g. required properties, + // as they do not apply for desired properties + return CompletableFuture.completedFuture(command); } private Optional extractFeature(final DeleteFeatureDesiredProperties command, diff --git a/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertyStrategy.java b/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertyStrategy.java index cd46d0d24d..72e7e01e85 100644 --- a/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertyStrategy.java +++ b/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertyStrategy.java @@ -13,6 +13,7 @@ package org.eclipse.ditto.things.service.persistence.actors.strategies.commands; import java.util.Optional; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import javax.annotation.Nullable; @@ -71,19 +72,9 @@ protected CompletionStage performWotValidation( @Nullable final Thing previousThing, @Nullable final Thing previewThing ) { - return wotThingModelValidator.validateFeatureScopedDeletion( - Optional.ofNullable(previousThing) - .flatMap(Thing::getDefinition) - .orElse(null), - Optional.ofNullable(previousThing) - .flatMap(Thing::getFeatures) - .flatMap(f -> f.getFeature(command.getFeatureId())) - .flatMap(Feature::getDefinition) - .orElse(null), - command.getFeatureId(), - command.getResourcePath(), - command.getDittoHeaders() - ).thenApply(aVoid -> command); + // it is always ok to delete a feature's desired properties - no need to validate for e.g. required properties, + // as they do not apply for desired properties + return CompletableFuture.completedFuture(command); } private Optional extractFeature(final DeleteFeatureDesiredProperty command, final @Nullable Thing thing) {