Bump upstream dependencies to K-SR2
[transportpce.git] / networkmodel / src / main / java / org / opendaylight / transportpce / networkmodel / NetConfTopologyListener.java
index b48c61ffee6d9066e1c7084e1001a3f08aa32a1c..ce15d3377f810b3688b34b49e2cd8eb12b57f8ee 100644 (file)
@@ -16,7 +16,6 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
-import javax.annotation.Nonnull;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.DataObjectModification;
 import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
@@ -38,9 +37,9 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.Netconf;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev240118.ConnectionOper.ConnectionStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev240118.connection.oper.available.capabilities.AvailableCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNode;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -69,7 +68,8 @@ public class NetConfTopologyListener implements DataTreeChangeListener<Node> {
         this.portMapping = portMapping;
     }
 
-    public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Node>> changes) {
+    @Override
+    public void onDataTreeChanged(Collection<DataTreeModification<Node>> changes) {
         LOG.info("onDataTreeChanged - {}", this.getClass().getSimpleName());
         for (DataTreeModification<Node> change : changes) {
             DataObjectModification<Node> rootNode = change.getRootNode();
@@ -100,8 +100,8 @@ public class NetConfTopologyListener implements DataTreeChangeListener<Node> {
                             return;
                         }
                         this.networkModelService
-                            .createOpenRoadmNode(nodeId, deviceCapabilityOpt.get().getCapability());
-                        onDeviceConnected(nodeId, deviceCapabilityOpt.get().getCapability());
+                            .createOpenRoadmNode(nodeId, deviceCapabilityOpt.orElseThrow().getCapability());
+                        onDeviceConnected(nodeId, deviceCapabilityOpt.orElseThrow().getCapability());
                         LOG.info("Device {} correctly connected to controller", nodeId);
                     }
                     if (ConnectionStatus.Connected.equals(netconfNodeBefore.getConnectionStatus())
@@ -123,7 +123,7 @@ public class NetConfTopologyListener implements DataTreeChangeListener<Node> {
             LOG.error("Failed to get mount point for node {}", nodeId);
             return;
         }
-        MountPoint mountPoint = mountPointOpt.get();
+        MountPoint mountPoint = mountPointOpt.orElseThrow();
         final Optional<NotificationService> notificationService = mountPoint.getService(NotificationService.class);
         if (notificationService.isEmpty()) {
             LOG.error(RPC_SERVICE_FAILED, nodeId);
@@ -131,7 +131,7 @@ public class NetConfTopologyListener implements DataTreeChangeListener<Node> {
         }
         NodeRegistration nodeRegistration =
             new NodeRegistration(
-                nodeId, openRoadmVersion, notificationService.get(), this.dataBroker, this.portMapping);
+                nodeId, openRoadmVersion, notificationService.orElseThrow(), this.dataBroker, this.portMapping);
         nodeRegistration.registerListeners();
         registrations.put(nodeId, nodeRegistration);
 
@@ -148,7 +148,7 @@ public class NetConfTopologyListener implements DataTreeChangeListener<Node> {
         if (service.isEmpty()) {
             return false;
         }
-        final NotificationsService rpcService = service.get().getRpcService(NotificationsService.class);
+        final NotificationsService rpcService = service.orElseThrow().getRpcService(NotificationsService.class);
         if (rpcService == null) {
             LOG.error(RPC_SERVICE_FAILED, nodeId);
             return false;
@@ -199,13 +199,13 @@ public class NetConfTopologyListener implements DataTreeChangeListener<Node> {
         Optional<Streams> ordmInfoObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, streamsIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-        if (ordmInfoObject == null || ordmInfoObject.isEmpty() || ordmInfoObject.get().getStream().isEmpty()) {
+        if (ordmInfoObject == null || ordmInfoObject.isEmpty() || ordmInfoObject.orElseThrow().getStream().isEmpty()) {
             LOG.error("List of streams supports by device is not present");
             return List.of("OPENROADM","NETCONF");
         }
         List<String> streams = new ArrayList<>();
         List<String> netconfStreams = new ArrayList<>();
-        for (Stream strm : ordmInfoObject.get().getStream().values()) {
+        for (Stream strm : ordmInfoObject.orElseThrow().getStream().values()) {
             LOG.debug("Streams are {}", strm);
             if ("OPENROADM".equalsIgnoreCase(strm.getName().getValue())) {
                 streams.add(strm.getName().getValue());