[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
(cherry picked from commit 178046ba11ab21d94a1e818fb893931bb015734b)
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));