From 81ec8fe96476245a29d20569170453f789a325b6 Mon Sep 17 00:00:00 2001 From: Johannes Schneider Date: Fri, 8 Apr 2022 13:48:43 +0200 Subject: [PATCH] review: deprecate WithSelectedFields in things model in favor in same interface in base model Signed-off-by: Johannes Schneider --- .../signals/commands/WithSelectedFields.java | 57 ++++++++++--------- .../routes/policies/PoliciesRoute.java | 3 +- .../signals/commands/WithSelectedFields.java | 45 ++++++++------- .../commands/query/RetrieveThings.java | 14 ++--- .../commands/query/ThingQueryCommand.java | 2 +- 5 files changed, 62 insertions(+), 59 deletions(-) diff --git a/base/model/src/main/java/org/eclipse/ditto/base/model/signals/commands/WithSelectedFields.java b/base/model/src/main/java/org/eclipse/ditto/base/model/signals/commands/WithSelectedFields.java index 0cfee7c082..f90dd68d0d 100644 --- a/base/model/src/main/java/org/eclipse/ditto/base/model/signals/commands/WithSelectedFields.java +++ b/base/model/src/main/java/org/eclipse/ditto/base/model/signals/commands/WithSelectedFields.java @@ -1,34 +1,35 @@ - /* - * Copyright (c) 2022 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 - */ - package org.eclipse.ditto.base.model.signals.commands; +/* + * Copyright (c) 2022 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 + */ +package org.eclipse.ditto.base.model.signals.commands; - import java.util.Optional; +import java.util.Optional; import org.eclipse.ditto.json.JsonFieldSelector; - /** - * Command enabled for field selecting. - * @since 2.4.0 - */ - public interface WithSelectedFields { +/** + * Command enabled for field selecting. + * + * @since 2.4.0 + */ +public interface WithSelectedFields { - /** - * Returns the selected fields which are to be included in the JSON of the retrieved entity. - * - * @return the selected fields. - */ - default Optional getSelectedFields() { - return Optional.empty(); - } + /** + * Returns the selected fields which are to be included in the JSON of the retrieved entity. + * + * @return the selected fields. + */ + default Optional getSelectedFields() { + return Optional.empty(); + } - } +} diff --git a/gateway/service/src/main/java/org/eclipse/ditto/gateway/service/endpoints/routes/policies/PoliciesRoute.java b/gateway/service/src/main/java/org/eclipse/ditto/gateway/service/endpoints/routes/policies/PoliciesRoute.java index 95374dc92f..c57505f660 100755 --- a/gateway/service/src/main/java/org/eclipse/ditto/gateway/service/endpoints/routes/policies/PoliciesRoute.java +++ b/gateway/service/src/main/java/org/eclipse/ditto/gateway/service/endpoints/routes/policies/PoliciesRoute.java @@ -26,7 +26,6 @@ import org.eclipse.ditto.base.model.signals.commands.Command; import org.eclipse.ditto.gateway.service.endpoints.routes.AbstractRoute; import org.eclipse.ditto.gateway.service.endpoints.routes.RouteBaseProperties; -import org.eclipse.ditto.gateway.service.endpoints.routes.things.ThingsParameter; import org.eclipse.ditto.gateway.service.security.authentication.AuthenticationResult; import org.eclipse.ditto.gateway.service.security.authentication.jwt.JwtAuthenticationResult; import org.eclipse.ditto.json.JsonFactory; @@ -121,7 +120,7 @@ private Route policyId(final RequestContext ctx, final DittoHeaders dittoHeaders return pathEndOrSingleSlash(() -> concat( // GET /policies/?fields= - get(() -> parameterOptional(ThingsParameter.FIELDS.toString(), fieldsString -> + get(() -> parameterOptional(PoliciesParameter.FIELDS.toString(), fieldsString -> handlePerRequest(ctx, RetrievePolicy.of(policyId, dittoHeaders, calculateSelectedFields(fieldsString).orElse(null))) )), diff --git a/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/WithSelectedFields.java b/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/WithSelectedFields.java index 7a92fe9642..45d814d2ce 100644 --- a/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/WithSelectedFields.java +++ b/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/WithSelectedFields.java @@ -1,26 +1,29 @@ - /* - * 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 - */ - package org.eclipse.ditto.things.model.signals.commands; +/* + * 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 + */ +package org.eclipse.ditto.things.model.signals.commands; - import java.util.Optional; +import java.util.Optional; - import org.eclipse.ditto.json.JsonFieldSelector; +import org.eclipse.ditto.json.JsonFieldSelector; - public interface WithSelectedFields extends org.eclipse.ditto.base.model.signals.commands.WithSelectedFields { +/** + * @deprecated since 2.4.0 use {@link org.eclipse.ditto.base.model.signals.commands.WithSelectedFields} instead. + */ +public interface WithSelectedFields extends org.eclipse.ditto.base.model.signals.commands.WithSelectedFields { - @Override - default Optional getSelectedFields() { - return Optional.empty(); - } + @Override + default Optional getSelectedFields() { + return Optional.empty(); + } - } +} diff --git a/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/query/RetrieveThings.java b/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/query/RetrieveThings.java index cbffa6a300..5f3f75198c 100755 --- a/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/query/RetrieveThings.java +++ b/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/query/RetrieveThings.java @@ -28,6 +28,13 @@ import javax.annotation.concurrent.Immutable; import javax.annotation.concurrent.NotThreadSafe; +import org.eclipse.ditto.base.model.headers.DittoHeaders; +import org.eclipse.ditto.base.model.json.FieldType; +import org.eclipse.ditto.base.model.json.JsonParsableCommand; +import org.eclipse.ditto.base.model.json.JsonSchemaVersion; +import org.eclipse.ditto.base.model.signals.commands.AbstractCommand; +import org.eclipse.ditto.base.model.signals.commands.WithNamespace; +import org.eclipse.ditto.base.model.signals.commands.WithSelectedFields; import org.eclipse.ditto.json.JsonArray; import org.eclipse.ditto.json.JsonCollectors; import org.eclipse.ditto.json.JsonFactory; @@ -38,16 +45,9 @@ import org.eclipse.ditto.json.JsonObjectBuilder; import org.eclipse.ditto.json.JsonPointer; import org.eclipse.ditto.json.JsonValue; -import org.eclipse.ditto.base.model.headers.DittoHeaders; -import org.eclipse.ditto.base.model.json.FieldType; -import org.eclipse.ditto.base.model.json.JsonParsableCommand; -import org.eclipse.ditto.base.model.json.JsonSchemaVersion; import org.eclipse.ditto.things.model.ThingConstants; import org.eclipse.ditto.things.model.ThingId; -import org.eclipse.ditto.base.model.signals.commands.AbstractCommand; -import org.eclipse.ditto.base.model.signals.commands.WithNamespace; import org.eclipse.ditto.things.model.signals.commands.ThingCommand; -import org.eclipse.ditto.things.model.signals.commands.WithSelectedFields; import org.eclipse.ditto.things.model.signals.commands.exceptions.MissingThingIdsException; /** diff --git a/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/query/ThingQueryCommand.java b/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/query/ThingQueryCommand.java index 56c0a8041b..8f31e9017c 100755 --- a/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/query/ThingQueryCommand.java +++ b/things/model/src/main/java/org/eclipse/ditto/things/model/signals/commands/query/ThingQueryCommand.java @@ -13,8 +13,8 @@ package org.eclipse.ditto.things.model.signals.commands.query; import org.eclipse.ditto.base.model.headers.DittoHeaders; +import org.eclipse.ditto.base.model.signals.commands.WithSelectedFields; import org.eclipse.ditto.things.model.signals.commands.ThingCommand; -import org.eclipse.ditto.things.model.signals.commands.WithSelectedFields; /** * Aggregates all {@link org.eclipse.ditto.things.model.signals.commands.ThingCommand}s which query the state of things (read, ...).