Remove DataChangeScope 87/97487/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 14 Sep 2021 00:22:19 +0000 (02:22 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 14 Sep 2021 07:12:08 +0000 (09:12 +0200)
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 <robert.varga@pantheon.tech>
restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/DataChangeScope.java [deleted file]
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.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 (file)
index f8ac8d3..0000000
+++ /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.
- *
- * <p>
- * 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.
-     *
-     * <p>
-     * 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.
-     *
-     * <p>
-     * This scope is superset of {@link #ONE} and {@link #BASE}.
-     *
-     */
-    SUBTREE
-}
index c9e0731d46938edce67b17653b174273ec5f8a07..ab321f6cf531d8fcc6bd893662c03c334c54b07c 100644 (file)
@@ -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;
index 77bb5f0635ce84796e13119a683bc44511d091a2..e81d0316d208cf08c039cba03481a7e7979726db 100644 (file)
@@ -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 {
      * <ul>
      * <li>datastore - default CONFIGURATION (other values of
      * {@link LogicalDatastoreType} enum type)</li>
-     * <li>scope - default BASE (other values of {@link DataChangeScope})</li>
+     * <li>scope - default BASE (other values of {@link Scope})</li>
      * </ul>
      */
     @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);
index 65f446fed1a20a5281e2dabcf46de71d0d0551ee..dad0907a7ecf49467ebf39521f5341a34c41b0a7 100644 (file)
@@ -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);
     }
 
index e11f174e357527adfb78e9c79055603742863d4e..7574b3bdc375903d91e52b7420a96ad24f899e7f 100644 (file)
@@ -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"));
index 4e2c5a9aff4aa33709adeb8fe609f40f24044bda..b62e2ce67052c982bddd629390228b06423fc4ce 100644 (file)
@@ -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
                 + "/"