From 9025ebe3bd41064042386b1937491649839d3f96 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 14 Sep 2021 02:22:19 +0200 Subject: [PATCH] Remove DataChangeScope This class duplicate of Scope, which is a generated enum which has no other meaning, really. Remove it and migrate users. JIRA: NETCONF-773 Change-Id: Ibfa7311178a2cc0e09bfaec8228bd1e8f5128eab Signed-off-by: Robert Varga --- .../restconf/common/util/DataChangeScope.java | 42 ------------------- .../sal/restconf/impl/BrokerFacade.java | 4 +- .../sal/restconf/impl/RestconfImpl.java | 13 +++--- .../restconf/impl/test/BrokerFacadeTest.java | 8 ++-- .../impl/test/URIParametersParsing.java | 8 ++-- .../rests/services/impl/CreateStreamUtil.java | 4 +- 6 files changed, 16 insertions(+), 63 deletions(-) delete mode 100644 restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/DataChangeScope.java diff --git a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/DataChangeScope.java b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/DataChangeScope.java deleted file mode 100644 index f8ac8d342e..0000000000 --- a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/DataChangeScope.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.common.util; - -/** - * Represents the scope of a data change (addition, replacement, deletion) registration. - * - *

- * Note: this enum was originally defined in the AsynDataBroker interface but was removed when DataChangeListener - * et al were removed. - */ -public enum DataChangeScope { - /** - * Represents only a direct change of the node, such as replacement of a node, addition or deletion.. - * - */ - BASE, - - /** - * Represent a change (addition, replacement, deletion) of the node or one of its direct - * children. - * - *

- * This scope is superset of {@link #BASE}. - * - */ - ONE, - - /** - * Represents a change of the node or any of or any of its child nodes, direct and nested. - * - *

- * This scope is superset of {@link #ONE} and {@link #BASE}. - * - */ - SUBTREE -} diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java index c9e0731d46..ab321f6cf5 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java @@ -58,7 +58,7 @@ import org.opendaylight.restconf.common.patch.PatchEditOperation; import org.opendaylight.restconf.common.patch.PatchEntity; import org.opendaylight.restconf.common.patch.PatchStatusContext; import org.opendaylight.restconf.common.patch.PatchStatusEntity; -import org.opendaylight.restconf.common.util.DataChangeScope; +import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.ErrorTag; import org.opendaylight.yangtools.yang.common.ErrorType; @@ -510,7 +510,7 @@ public class BrokerFacade implements Closeable { return this.rpcService.invokeRpc(type, input); } - public void registerToListenDataChanges(final LogicalDatastoreType datastore, final DataChangeScope scope, + public void registerToListenDataChanges(final LogicalDatastoreType datastore, final Scope scope, final ListenerAdapter listener) { if (listener.isListening()) { return; diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java index 77bb5f0635..e81d0316d2 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java @@ -76,9 +76,9 @@ import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.patch.PatchContext; import org.opendaylight.restconf.common.patch.PatchStatusContext; -import org.opendaylight.restconf.common.util.DataChangeScope; import org.opendaylight.restconf.common.util.OperationsResourceUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope; import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType; import org.opendaylight.yangtools.yang.common.Empty; import org.opendaylight.yangtools.yang.common.ErrorTag; @@ -142,8 +142,6 @@ public final class RestconfImpl implements RestconfService { private static final Logger LOG = LoggerFactory.getLogger(RestconfImpl.class); - private static final DataChangeScope DEFAULT_SCOPE = DataChangeScope.BASE; - private static final LogicalDatastoreType DEFAULT_DATASTORE = LogicalDatastoreType.CONFIGURATION; private static final XMLNamespace NAMESPACE_EVENT_SUBSCRIPTION_AUGMENT = @@ -610,8 +608,8 @@ public final class RestconfImpl implements RestconfService { parseEnumTypeParameter(value, LogicalDatastoreType.class, DATASTORE_PARAM_NAME); datastore = datastore == null ? DEFAULT_DATASTORE : datastore; - DataChangeScope scope = parseEnumTypeParameter(value, DataChangeScope.class, SCOPE_PARAM_NAME); - scope = scope == null ? DEFAULT_SCOPE : scope; + Scope scope = parseEnumTypeParameter(value, Scope.class, SCOPE_PARAM_NAME); + scope = scope == null ? Scope.BASE : scope; outputType = parseEnumTypeParameter(value, NotificationOutputType.class, OUTPUT_TYPE_PARAM_NAME); outputType = outputType == null ? NotificationOutputType.XML : outputType; @@ -1048,7 +1046,7 @@ public final class RestconfImpl implements RestconfService { *

*/ @Override @@ -1262,8 +1260,7 @@ public final class RestconfImpl implements RestconfService { throw new RestconfDocumentedException("Stream name doesn't contains datastore value (pattern /datastore=)", ErrorType.APPLICATION, ErrorTag.MISSING_ATTRIBUTE); } - final DataChangeScope scope = - parserURIEnumParameter(DataChangeScope.class, paramToValues.get(SCOPE_PARAM_NAME)); + final Scope scope = parserURIEnumParameter(Scope.class, paramToValues.get(SCOPE_PARAM_NAME)); if (scope == null) { throw new RestconfDocumentedException("Stream name doesn't contains datastore value (pattern /scope=)", ErrorType.APPLICATION, ErrorTag.MISSING_ATTRIBUTE); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java index 65f446fed1..dad0907a7e 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java @@ -70,7 +70,7 @@ import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.errors.RestconfError; import org.opendaylight.restconf.common.patch.PatchContext; import org.opendaylight.restconf.common.patch.PatchStatusContext; -import org.opendaylight.restconf.common.util.DataChangeScope; +import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope; import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.ErrorTag; @@ -313,15 +313,13 @@ public class BrokerFacadeTest { DOMDataTreeIdentifier loc = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, this.instanceID); when(changeService.registerDataTreeChangeListener(eq(loc), eq(listener))).thenReturn(mockRegistration); - this.brokerFacade.registerToListenDataChanges( - LogicalDatastoreType.CONFIGURATION, DataChangeScope.BASE, listener); + this.brokerFacade.registerToListenDataChanges(LogicalDatastoreType.CONFIGURATION, Scope.BASE, listener); verify(changeService).registerDataTreeChangeListener(loc, listener); assertEquals("isListening", true, listener.isListening()); - this.brokerFacade.registerToListenDataChanges( - LogicalDatastoreType.CONFIGURATION, DataChangeScope.BASE, listener); + this.brokerFacade.registerToListenDataChanges(LogicalDatastoreType.CONFIGURATION, Scope.BASE, listener); verifyNoMoreInteractions(changeService); } diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java index e11f174e35..7574b3bdc3 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java @@ -30,7 +30,7 @@ import org.opendaylight.netconf.sal.streams.listeners.ListenerAdapter; import org.opendaylight.netconf.sal.streams.listeners.Notificator; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.context.NormalizedNodeContext; -import org.opendaylight.restconf.common.util.DataChangeScope; +import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope; import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.Revision; @@ -70,16 +70,16 @@ public class URIParametersParsing { @Test public void resolveURIParametersConcreteValues() { - resolveURIParameters("OPERATIONAL", "SUBTREE", LogicalDatastoreType.OPERATIONAL, DataChangeScope.SUBTREE); + resolveURIParameters("OPERATIONAL", "SUBTREE", LogicalDatastoreType.OPERATIONAL, Scope.SUBTREE); } @Test public void resolveURIParametersDefaultValues() { - resolveURIParameters(null, null, LogicalDatastoreType.CONFIGURATION, DataChangeScope.BASE); + resolveURIParameters(null, null, LogicalDatastoreType.CONFIGURATION, Scope.BASE); } private void resolveURIParameters(final String datastore, final String scope, - final LogicalDatastoreType datastoreExpected, final DataChangeScope scopeExpected) { + final LogicalDatastoreType datastoreExpected, final Scope scopeExpected) { final InstanceIdentifierBuilder iiBuilder = YangInstanceIdentifier.builder(); iiBuilder.node(QName.create("", "dummyStreamName")); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java index 4e2c5a9aff..b62e2ce670 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java @@ -18,11 +18,11 @@ import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; -import org.opendaylight.restconf.common.util.DataChangeScope; import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants; import org.opendaylight.restconf.nb.rfc8040.streams.listeners.ListenersBroker; import org.opendaylight.restconf.nb.rfc8040.streams.listeners.NotificationListenerAdapter; import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier; +import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope; import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType; import org.opendaylight.yangtools.yang.common.ErrorTag; import org.opendaylight.yangtools.yang.common.ErrorType; @@ -153,7 +153,7 @@ final class CreateStreamUtil { final String scopeName = extractStringLeaf(data, SCOPE_NODEID); // FIXME: this is not really used - final DataChangeScope scope = scopeName != null ? DataChangeScope.valueOf(scopeName) : DataChangeScope.BASE; + final Scope scope = scopeName != null ? Scope.forName(scopeName).orElseThrow() : Scope.BASE; return RestconfStreamsConstants.DATA_SUBSCRIPTION + "/" -- 2.36.6