From df4462c392415827653e222391efca8ba2d2abd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20J=C3=A4ckle?= Date: Mon, 17 Jul 2023 21:16:52 +0200 Subject: [PATCH] #1691 fixed persisting inline "_policy" in ThingMerged events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Jäckle --- .../condition/package-info.java | 18 ------------------ .../model/signals/events/ThingMerged.java | 6 +++--- .../serializer/ThingMongoEventAdapter.java | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 23 deletions(-) delete mode 100644 internal/utils/persistent-actors/src/main/java/org/eclipse/ditto/internal/utils/persistentactors/condition/package-info.java diff --git a/internal/utils/persistent-actors/src/main/java/org/eclipse/ditto/internal/utils/persistentactors/condition/package-info.java b/internal/utils/persistent-actors/src/main/java/org/eclipse/ditto/internal/utils/persistentactors/condition/package-info.java deleted file mode 100644 index 8e8e30ac54..0000000000 --- a/internal/utils/persistent-actors/src/main/java/org/eclipse/ditto/internal/utils/persistentactors/condition/package-info.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2021 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ - -/** - * Entity-tag handlers. - */ -@org.eclipse.ditto.utils.jsr305.annotations.AllValuesAreNonnullByDefault -package org.eclipse.ditto.internal.utils.persistentactors.condition; diff --git a/things/model/src/main/java/org/eclipse/ditto/things/model/signals/events/ThingMerged.java b/things/model/src/main/java/org/eclipse/ditto/things/model/signals/events/ThingMerged.java index f199c0820a..5a280a94a5 100644 --- a/things/model/src/main/java/org/eclipse/ditto/things/model/signals/events/ThingMerged.java +++ b/things/model/src/main/java/org/eclipse/ditto/things/model/signals/events/ThingMerged.java @@ -210,16 +210,16 @@ public String toString() { /** * An enumeration of the JSON fields of a {@code ThingMerged} event. */ - static final class JsonFields { + public static final class JsonFields { private JsonFields() { throw new AssertionError(); } - static final JsonFieldDefinition JSON_PATH = + public static final JsonFieldDefinition JSON_PATH = JsonFactory.newStringFieldDefinition("path", FieldType.REGULAR, JsonSchemaVersion.V_2); - static final JsonFieldDefinition JSON_VALUE = + public static final JsonFieldDefinition JSON_VALUE = JsonFactory.newJsonValueFieldDefinition("value", FieldType.REGULAR, JsonSchemaVersion.V_2); } } diff --git a/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/serializer/ThingMongoEventAdapter.java b/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/serializer/ThingMongoEventAdapter.java index ba7d45a8ec..9e4c3b6cd6 100644 --- a/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/serializer/ThingMongoEventAdapter.java +++ b/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/serializer/ThingMongoEventAdapter.java @@ -22,6 +22,7 @@ import org.eclipse.ditto.json.JsonPointer; import org.eclipse.ditto.policies.model.Policy; import org.eclipse.ditto.things.model.signals.events.ThingEvent; +import org.eclipse.ditto.things.model.signals.events.ThingMerged; import org.eclipse.ditto.things.service.common.config.DefaultThingConfig; import akka.actor.ExtendedActorSystem; @@ -35,6 +36,10 @@ public final class ThingMongoEventAdapter extends AbstractMongoEventAdapter event, final JsonObject jsonObject) { - return super.performToJournalMigration(event, jsonObject) - .remove(POLICY_IN_THING_EVENT_PAYLOAD); // remove the policy entries from thing event payload + if (event instanceof ThingMerged) { + return super.performToJournalMigration(event, jsonObject) + .remove(POLICY_IN_THING_MERGED_VALUE_PAYLOAD); // remove the policy entries from thing merged payload + } else { + return super.performToJournalMigration(event, jsonObject) + .remove(POLICY_IN_THING_EVENT_PAYLOAD); // remove the policy entries from thing event payload + } } }