Skip to content

Commit 163db35

Browse files
committed
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
1 parent 4d9372b commit 163db35

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertiesStrategy.java

+4-13
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package org.eclipse.ditto.things.service.persistence.actors.strategies.commands;
1414

1515
import java.util.Optional;
16+
import java.util.concurrent.CompletableFuture;
1617
import java.util.concurrent.CompletionStage;
1718

1819
import javax.annotation.Nullable;
@@ -68,19 +69,9 @@ protected CompletionStage<DeleteFeatureDesiredProperties> performWotValidation(
6869
@Nullable final Thing previousThing,
6970
@Nullable final Thing previewThing
7071
) {
71-
return wotThingModelValidator.validateFeatureScopedDeletion(
72-
Optional.ofNullable(previousThing)
73-
.flatMap(Thing::getDefinition)
74-
.orElse(null),
75-
Optional.ofNullable(previousThing)
76-
.flatMap(Thing::getFeatures)
77-
.flatMap(f -> f.getFeature(command.getFeatureId()))
78-
.flatMap(Feature::getDefinition)
79-
.orElse(null),
80-
command.getFeatureId(),
81-
command.getResourcePath(),
82-
command.getDittoHeaders()
83-
).thenApply(aVoid -> command);
72+
// it is always ok to delete a feature's desired properties - no need to validate for e.g. required properties,
73+
// as they do not apply for desired properties
74+
return CompletableFuture.completedFuture(command);
8475
}
8576

8677
private Optional<Feature> extractFeature(final DeleteFeatureDesiredProperties command,

things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertyStrategy.java

+4-13
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package org.eclipse.ditto.things.service.persistence.actors.strategies.commands;
1414

1515
import java.util.Optional;
16+
import java.util.concurrent.CompletableFuture;
1617
import java.util.concurrent.CompletionStage;
1718

1819
import javax.annotation.Nullable;
@@ -71,19 +72,9 @@ protected CompletionStage<DeleteFeatureDesiredProperty> performWotValidation(
7172
@Nullable final Thing previousThing,
7273
@Nullable final Thing previewThing
7374
) {
74-
return wotThingModelValidator.validateFeatureScopedDeletion(
75-
Optional.ofNullable(previousThing)
76-
.flatMap(Thing::getDefinition)
77-
.orElse(null),
78-
Optional.ofNullable(previousThing)
79-
.flatMap(Thing::getFeatures)
80-
.flatMap(f -> f.getFeature(command.getFeatureId()))
81-
.flatMap(Feature::getDefinition)
82-
.orElse(null),
83-
command.getFeatureId(),
84-
command.getResourcePath(),
85-
command.getDittoHeaders()
86-
).thenApply(aVoid -> command);
75+
// it is always ok to delete a feature's desired properties - no need to validate for e.g. required properties,
76+
// as they do not apply for desired properties
77+
return CompletableFuture.completedFuture(command);
8778
}
8879

8980
private Optional<Feature> extractFeature(final DeleteFeatureDesiredProperty command, final @Nullable Thing thing) {

0 commit comments

Comments
 (0)