Move restconfStateStreamPath() 49/108849/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 3 Nov 2023 22:37:02 +0000 (23:37 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 3 Nov 2023 22:42:05 +0000 (23:42 +0100)
Management of ietf-restconf streams is the domain of ListenersBroker,
move the constant and the single used utility method there.

JIRA: NETCONF-1102
Change-Id: Id44123f5409dd2507db8d55220f9daa8dda23351
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/ListenersBroker.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/RestconfStateStreams.java

index 3da98c9e2970ae3815fdb1e7fea44730980c72c6..689fa35dcac49bd118dfb0afe339f9c6bb1ea76c 100644 (file)
@@ -32,6 +32,9 @@ import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfFuture;
 import org.opendaylight.restconf.nb.rfc8040.URLConstants;
 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.RestconfState;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.Streams;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.streams.Stream;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.device.notification.rev221106.SubscribeDeviceNotificationInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.device.notification.rev221106.SubscribeDeviceNotificationOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscriptionInput;
@@ -189,6 +192,10 @@ public abstract sealed class ListenersBroker {
 //    }
 
     private static final Logger LOG = LoggerFactory.getLogger(ListenersBroker.class);
+    private static final YangInstanceIdentifier RESTCONF_STATE_STREAMS = YangInstanceIdentifier.of(
+        NodeIdentifier.create(RestconfState.QNAME),
+        NodeIdentifier.create(Streams.QNAME),
+        NodeIdentifier.create(Stream.QNAME));
 
     private static final QName DATASTORE_QNAME =
         QName.create(CreateDataChangeEventSubscriptionInput1.QNAME, "datastore").intern();
@@ -266,7 +273,7 @@ public abstract sealed class ListenersBroker {
 
         // Now issue a delete operation while the name is still protected by being associated in the map.
         final var tx = dataBroker.newWriteOnlyTransaction();
-        tx.delete(LogicalDatastoreType.OPERATIONAL, RestconfStateStreams.restconfStateStreamPath(streamName));
+        tx.delete(LogicalDatastoreType.OPERATIONAL, restconfStateStreamPath(streamName));
         tx.commit().addCallback(new FutureCallback<CommitInfo>() {
             @Override
             public void onSuccess(final CommitInfo result) {
@@ -282,6 +289,11 @@ public abstract sealed class ListenersBroker {
         }, MoreExecutors.directExecutor());
     }
 
+    private static @NonNull YangInstanceIdentifier restconfStateStreamPath(final String streamName) {
+        return RESTCONF_STATE_STREAMS
+            .node(NodeIdentifierWithPredicates.of(Stream.QNAME, RestconfStateStreams.NAME_QNAME, streamName));
+    }
+
     /**
      * Creates string representation of stream name from URI. Removes slash from URI in start and end positions,
      * and optionally {@link URLConstants#BASE_PATH} prefix.
index 7fc86173bf901eab9ef5c38efe275c4cfe7dc7e4..9f4fe2a7ee86373e95a3a9586849c685035895d1 100644 (file)
@@ -13,9 +13,6 @@ import com.google.common.annotations.VisibleForTesting;
 import java.net.URI;
 import java.util.Set;
 import java.util.stream.Collectors;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.RestconfState;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.Streams;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.streams.Stream;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.streams.stream.Access;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -35,33 +32,20 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
  * Utilities for creating the content of {@code /ietf-restconf-monitoring:restconf-state/streams}.
  */
 public final class RestconfStateStreams {
-    private static final YangInstanceIdentifier RESTCONF_STATE_STREAMS = YangInstanceIdentifier.of(
-        NodeIdentifier.create(RestconfState.QNAME), NodeIdentifier.create(Streams.QNAME),
-        NodeIdentifier.create(Stream.QNAME));
-
     @VisibleForTesting
     static final QName DESCRIPTION_QNAME = qnameOf("description");
     @VisibleForTesting
     static final QName ENCODING_QNAME = qnameOf("encoding");
     @VisibleForTesting
     static final QName LOCATION_QNAME = qnameOf("location");
-    @VisibleForTesting
     static final QName NAME_QNAME = qnameOf("name");
 
     private RestconfStateStreams() {
         // Hidden on purpose
     }
 
-    public static @NonNull YangInstanceIdentifier restconfStateStreamPath(final String streamName) {
-        return restconfStateStreamPath(NodeIdentifierWithPredicates.of(Stream.QNAME, NAME_QNAME, streamName));
-    }
-
-    public static @NonNull YangInstanceIdentifier restconfStateStreamPath(final NodeIdentifierWithPredicates arg) {
-        return RESTCONF_STATE_STREAMS.node(arg);
-    }
-
     /**
-     * Map data of yang notification to normalized node according to ietf-restconf-monitoring.
+     * Map data of YANG notification stream to a {@link MapEntryNode} according to {@code ietf-restconf-monitoring}.
      *
      * @param streamName stream name
      * @param qnames Notification QNames to listen on