[SDFAB-705] Fix GUI for the control and data plane resiliency

Additionally, fix similar issues in GUI2 and add initial
support for ports with name in GUI/GUI2.

This is also the first step towards supporting port with name widely in ONOS

Change-Id: Ib04f780bf0b7171e82a6beb69b39c0aaeb4be957
diff --git a/core/api/src/main/java/org/onosproject/net/ConnectPoint.java b/core/api/src/main/java/org/onosproject/net/ConnectPoint.java
index 7a311aa..ac04a05 100644
--- a/core/api/src/main/java/org/onosproject/net/ConnectPoint.java
+++ b/core/api/src/main/java/org/onosproject/net/ConnectPoint.java
@@ -178,14 +178,25 @@
          * - scheme:ip:port/path/cp
          *
          * The assumption is the last `/` will separate the device ID
-         * from the connection point number.
+         * from the connection point number. If the cp is a named port
+         * `/` can be included in the port name. We use `[` as heuristic
+         * to separate the device ID from the port number.
          */
         checkNotNull(string);
         int idx = string.lastIndexOf("/");
         checkArgument(idx != -1, NO_SEP_SPECIFIED);
 
-        String id = string.substring(0, idx);
-        String cp = string.substring(idx + 1);
+        String id = "";
+        String cp = "";
+        // deviceId/[ which means the id is 2 chars behind
+        int nameIdx = string.lastIndexOf("[");
+        if (nameIdx > 0) {
+            id = string.substring(0, nameIdx - 1);
+            cp = string.substring(nameIdx);
+        } else if (nameIdx < 0) {
+            id = string.substring(0, idx);
+            cp = string.substring(idx + 1);
+        }
         checkArgument(!cp.isEmpty(), SEP_NO_VALUE);
 
         return new ConnectPoint(DeviceId.deviceId(id), PortNumber.fromString(cp));
diff --git a/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java b/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java
index 85c51f6..ae9d445 100644
--- a/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java
+++ b/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java
@@ -36,7 +36,7 @@
 import java.util.Set;
 
 import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onosproject.net.ConnectPoint.deviceConnectPoint;
+import static org.onosproject.net.ConnectPoint.fromString;
 import static org.onosproject.net.DeviceId.deviceId;
 import static org.onosproject.net.HostId.hostId;
 
@@ -301,8 +301,8 @@
                     continue;
                 }
 
-                cpSrc = deviceConnectPoint(connectPoints[0]);
-                cpDst = deviceConnectPoint(connectPoints[1]);
+                cpSrc = fromString(connectPoints[0]);
+                cpDst = fromString(connectPoints[1]);
                 link = linkService.getLink(cpSrc, cpDst);
 
                 if (link != null) {