Simon Hunt
Committed by Gerrit Code Review

GUI -- Refactoring of server-side message handlers (Part One).

Change-Id: I895cef0545f7ba4b78a2adfa2bad9d889ca0104a
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.ui;
18 +
19 +import com.fasterxml.jackson.databind.ObjectMapper;
20 +import com.fasterxml.jackson.databind.node.ObjectNode;
21 +
22 +/**
23 + * Provides convenience methods for dealing with JSON nodes, arrays etc.
24 + */
25 +public final class JsonUtils {
26 +
27 + private static final ObjectMapper MAPPER = new ObjectMapper();
28 +
29 + // non-instantiable
30 + private JsonUtils() { }
31 +
32 + /**
33 + * Wraps a message payload into an event structure for the given event
34 + * type and sequence ID. Generally, the sequence ID should be a copy of
35 + * the ID from the client request event.
36 + *
37 + * @param type event type
38 + * @param sid sequence ID
39 + * @param payload event payload
40 + * @return the object node representation
41 + */
42 + public static ObjectNode envelope(String type, long sid, ObjectNode payload) {
43 + ObjectNode event = MAPPER.createObjectNode();
44 + event.put("event", type);
45 + if (sid > 0) {
46 + event.put("sid", sid);
47 + }
48 + event.set("payload", payload);
49 + return event;
50 + }
51 +
52 + /**
53 + * Returns the event type from the specified event.
54 + * If the node does not have an "event" property, "unknown" is returned.
55 + *
56 + * @param event message event
57 + * @return extracted event type
58 + */
59 + public static String eventType(ObjectNode event) {
60 + return string(event, "event", "unknown");
61 + }
62 +
63 + /**
64 + * Returns the payload from the specified event.
65 + *
66 + * @param event message event
67 + * @return extracted payload object
68 + */
69 + public static ObjectNode payload(ObjectNode event) {
70 + return (ObjectNode) event.path("payload");
71 + }
72 +
73 + /**
74 + * Returns the specified node property as a number.
75 + *
76 + * @param node message event
77 + * @param name property name
78 + * @return property as number
79 + */
80 + public static long number(ObjectNode node, String name) {
81 + return node.path(name).asLong();
82 + }
83 +
84 + /**
85 + * Returns the specified node property as a string.
86 + *
87 + * @param node message event
88 + * @param name property name
89 + * @return property as a string
90 + */
91 + public static String string(ObjectNode node, String name) {
92 + return node.path(name).asText();
93 + }
94 +
95 + /**
96 + * Returns the specified node property as a string, with a default fallback.
97 + *
98 + * @param node message event
99 + * @param name property name
100 + * @param defaultValue fallback value if property is absent
101 + * @return property as a string
102 + */
103 + public static String string(ObjectNode node, String name, String defaultValue) {
104 + return node.path(name).asText(defaultValue);
105 + }
106 +
107 +}
...@@ -138,13 +138,17 @@ public abstract class UiMessageHandler { ...@@ -138,13 +138,17 @@ public abstract class UiMessageHandler {
138 * @return the object node representation 138 * @return the object node representation
139 */ 139 */
140 protected ObjectNode envelope(String type, long sid, ObjectNode payload) { 140 protected ObjectNode envelope(String type, long sid, ObjectNode payload) {
141 - ObjectNode event = mapper.createObjectNode(); 141 + return JsonUtils.envelope(type, sid, payload);
142 - event.put("event", type);
143 - if (sid > 0) {
144 - event.put("sid", sid);
145 } 142 }
146 - event.set("payload", payload); 143 +
147 - return event; 144 + /**
145 + * Returns the event type from the specified event.
146 + *
147 + * @param event the event
148 + * @return the event type
149 + */
150 + protected String eventType(ObjectNode event) {
151 + return JsonUtils.eventType(event);
148 } 152 }
149 153
150 /** 154 /**
...@@ -154,7 +158,7 @@ public abstract class UiMessageHandler { ...@@ -154,7 +158,7 @@ public abstract class UiMessageHandler {
154 * @return extracted payload object 158 * @return extracted payload object
155 */ 159 */
156 protected ObjectNode payload(ObjectNode event) { 160 protected ObjectNode payload(ObjectNode event) {
157 - return (ObjectNode) event.path("payload"); 161 + return JsonUtils.payload(event);
158 } 162 }
159 163
160 /** 164 /**
...@@ -165,7 +169,7 @@ public abstract class UiMessageHandler { ...@@ -165,7 +169,7 @@ public abstract class UiMessageHandler {
165 * @return property as number 169 * @return property as number
166 */ 170 */
167 protected long number(ObjectNode node, String name) { 171 protected long number(ObjectNode node, String name) {
168 - return node.path(name).asLong(); 172 + return JsonUtils.number(node, name);
169 } 173 }
170 174
171 /** 175 /**
...@@ -176,7 +180,7 @@ public abstract class UiMessageHandler { ...@@ -176,7 +180,7 @@ public abstract class UiMessageHandler {
176 * @return property as a string 180 * @return property as a string
177 */ 181 */
178 protected String string(ObjectNode node, String name) { 182 protected String string(ObjectNode node, String name) {
179 - return node.path(name).asText(); 183 + return JsonUtils.string(node, name);
180 } 184 }
181 185
182 /** 186 /**
...@@ -188,7 +192,21 @@ public abstract class UiMessageHandler { ...@@ -188,7 +192,21 @@ public abstract class UiMessageHandler {
188 * @return property as a string 192 * @return property as a string
189 */ 193 */
190 protected String string(ObjectNode node, String name, String defaultValue) { 194 protected String string(ObjectNode node, String name, String defaultValue) {
191 - return node.path(name).asText(defaultValue); 195 + return JsonUtils.string(node, name, defaultValue);
192 } 196 }
193 197
198 + /**
199 + * Concatenates an arbitrary number of objects, using their
200 + * toString() methods.
201 + *
202 + * @param items the items to concatenate
203 + * @return a concatenated string
204 + */
205 + protected static String concat(Object... items) {
206 + StringBuilder sb = new StringBuilder();
207 + for (Object o : items) {
208 + sb.append(o);
209 + }
210 + return sb.toString();
211 + }
194 } 212 }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.ui.impl; 17 +package org.onosproject.ui.table;
18 18
19 import com.fasterxml.jackson.databind.ObjectMapper; 19 import com.fasterxml.jackson.databind.ObjectMapper;
20 import com.fasterxml.jackson.databind.node.ObjectNode; 20 import com.fasterxml.jackson.databind.node.ObjectNode;
...@@ -30,18 +30,18 @@ public abstract class AbstractTableRow implements TableRow { ...@@ -30,18 +30,18 @@ public abstract class AbstractTableRow implements TableRow {
30 30
31 private static final ObjectMapper MAPPER = new ObjectMapper(); 31 private static final ObjectMapper MAPPER = new ObjectMapper();
32 32
33 - private final Map<String, String> data = new HashMap<>(); 33 + private final Map<String, String> cells = new HashMap<>();
34 34
35 @Override 35 @Override
36 public String get(String key) { 36 public String get(String key) {
37 - return data.get(key); 37 + return cells.get(key);
38 } 38 }
39 39
40 @Override 40 @Override
41 public ObjectNode toJsonNode() { 41 public ObjectNode toJsonNode() {
42 ObjectNode result = MAPPER.createObjectNode(); 42 ObjectNode result = MAPPER.createObjectNode();
43 for (String id : columnIds()) { 43 for (String id : columnIds()) {
44 - result.put(id, data.get(id)); 44 + result.put(id, cells.get(id));
45 } 45 }
46 return result; 46 return result;
47 } 47 }
...@@ -54,12 +54,23 @@ public abstract class AbstractTableRow implements TableRow { ...@@ -54,12 +54,23 @@ public abstract class AbstractTableRow implements TableRow {
54 protected abstract String[] columnIds(); 54 protected abstract String[] columnIds();
55 55
56 /** 56 /**
57 - * Add a column ID to value binding. 57 + * Add a column ID to cell value binding.
58 * 58 *
59 * @param id the column ID 59 * @param id the column ID
60 * @param value the cell value 60 * @param value the cell value
61 */ 61 */
62 protected void add(String id, String value) { 62 protected void add(String id, String value) {
63 - data.put(id, value); 63 + cells.put(id, value);
64 + }
65 +
66 + /**
67 + * Add a column ID to cell value binding.
68 + * Note that value.toString() is invoked.
69 + *
70 + * @param id the column ID
71 + * @param value the cell value
72 + */
73 + protected void add(String id, Object value) {
74 + cells.put(id, value.toString());
64 } 75 }
65 } 76 }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.ui.impl; 17 +package org.onosproject.ui.table;
18 18
19 import java.util.Comparator; 19 import java.util.Comparator;
20 20
...@@ -22,7 +22,13 @@ import java.util.Comparator; ...@@ -22,7 +22,13 @@ import java.util.Comparator;
22 * Comparator for {@link TableRow}. 22 * Comparator for {@link TableRow}.
23 */ 23 */
24 public class RowComparator implements Comparator<TableRow> { 24 public class RowComparator implements Comparator<TableRow> {
25 - public static enum Direction { ASC, DESC } 25 + /** Designates the sort direction. */
26 + public enum Direction {
27 + /** Sort Ascending. */
28 + ASC,
29 + /** Sort Descending. */
30 + DESC
31 + }
26 32
27 public static final String DESC_STR = "desc"; 33 public static final String DESC_STR = "desc";
28 34
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.ui.impl; 17 +package org.onosproject.ui.table;
18 18
19 19
20 import com.fasterxml.jackson.databind.node.ObjectNode; 20 import com.fasterxml.jackson.databind.node.ObjectNode;
...@@ -23,6 +23,11 @@ import com.fasterxml.jackson.databind.node.ObjectNode; ...@@ -23,6 +23,11 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
23 * Defines a table row abstraction to support sortable tables on the GUI. 23 * Defines a table row abstraction to support sortable tables on the GUI.
24 */ 24 */
25 public interface TableRow { 25 public interface TableRow {
26 +
27 + // TODO: Define TableCell interface and return that, rather than String
28 + // The hope is that this will allow us to write a generic mechanism for
29 + // selecting a comparator based on the cell type for the column, to be
30 + // used for sorting the table rows.
26 /** 31 /**
27 * Returns the value of the cell for the given column ID. 32 * Returns the value of the cell for the given column ID.
28 * 33 *
......
...@@ -13,41 +13,65 @@ ...@@ -13,41 +13,65 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.ui.impl;
17 16
18 -import com.fasterxml.jackson.databind.node.ArrayNode; 17 +package org.onosproject.ui.table;
19 -import org.onosproject.ui.UiMessageHandler;
20 18
21 -import java.util.Set; 19 +import com.fasterxml.jackson.databind.ObjectMapper;
20 +import com.fasterxml.jackson.databind.node.ArrayNode;
21 +import com.fasterxml.jackson.databind.node.ObjectNode;
22 +import org.onosproject.ui.JsonUtils;
22 23
23 /** 24 /**
24 - * Base message handler for tabular views. 25 + * Provides static utility methods for dealing with tables.
25 */ 26 */
26 -public abstract class AbstractTabularViewMessageHandler extends UiMessageHandler { 27 +public final class TableUtils {
27 28
28 - /** 29 + private static final ObjectMapper MAPPER = new ObjectMapper();
29 - * Creates a new tabular view message handler. 30 +
30 - * 31 + // non-instantiable
31 - * @param messageTypes set of message types 32 + private TableUtils() { }
32 - */
33 - protected AbstractTabularViewMessageHandler(Set<String> messageTypes) {
34 - super(messageTypes);
35 - }
36 33
37 /** 34 /**
38 - * Produces JSON from the specified array of rows. 35 + * Produces a JSON array node from the specified table rows.
39 * 36 *
40 * @param rows table rows 37 * @param rows table rows
41 * @return JSON array 38 * @return JSON array
42 */ 39 */
43 - protected ArrayNode generateArrayNode(TableRow[] rows) { 40 + public static ArrayNode generateArrayNode(TableRow[] rows) {
44 - ArrayNode array = mapper.createArrayNode(); 41 + ArrayNode array = MAPPER.createArrayNode();
45 for (TableRow r : rows) { 42 for (TableRow r : rows) {
46 array.add(r.toJsonNode()); 43 array.add(r.toJsonNode());
47 } 44 }
48 return array; 45 return array;
49 } 46 }
50 47
51 - // TODO: possibly convert this into just a toolbox class 48 + /**
52 - // TODO: extract and generalize other table constructs 49 + * Creates a row comparator for the given request. The ID of the column
50 + * to sort on is the payload's "sortCol" property (defaults to "id").
51 + * The direction for the sort is the payload's "sortDir" property
52 + * (defaults to "asc").
53 + *
54 + * @param payload the event payload
55 + * @return a row comparator
56 + */
57 + public static RowComparator createRowComparator(ObjectNode payload) {
58 + return createRowComparator(payload, "id");
59 + }
60 +
61 + /**
62 + * Creates a row comparator for the given request. The ID of the column to
63 + * sort on is the payload's "sortCol" property (or the specified default).
64 + * The direction for the sort is the payload's "sortDir" property
65 + * (defaults to "asc").
66 + *
67 + * @param payload the event payload
68 + * @param defColId the default column ID
69 + * @return a row comparator
70 + */
71 + public static RowComparator createRowComparator(ObjectNode payload,
72 + String defColId) {
73 + String sortCol = JsonUtils.string(payload, "sortCol", defColId);
74 + String sortDir = JsonUtils.string(payload, "sortDir", "asc");
75 + return new RowComparator(sortCol, RowComparator.direction(sortDir));
76 + }
53 } 77 }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.ui.impl; 16 package org.onosproject.ui.impl;
17 17
18 -import com.fasterxml.jackson.databind.node.ArrayNode;
19 import com.fasterxml.jackson.databind.node.ObjectNode; 18 import com.fasterxml.jackson.databind.node.ObjectNode;
20 import com.google.common.collect.ImmutableSet; 19 import com.google.common.collect.ImmutableSet;
21 import org.onosproject.app.ApplicationAdminService; 20 import org.onosproject.app.ApplicationAdminService;
...@@ -23,6 +22,11 @@ import org.onosproject.app.ApplicationService; ...@@ -23,6 +22,11 @@ import org.onosproject.app.ApplicationService;
23 import org.onosproject.app.ApplicationState; 22 import org.onosproject.app.ApplicationState;
24 import org.onosproject.core.Application; 23 import org.onosproject.core.Application;
25 import org.onosproject.core.ApplicationId; 24 import org.onosproject.core.ApplicationId;
25 +import org.onosproject.ui.UiMessageHandler;
26 +import org.onosproject.ui.table.AbstractTableRow;
27 +import org.onosproject.ui.table.RowComparator;
28 +import org.onosproject.ui.table.TableRow;
29 +import org.onosproject.ui.table.TableUtils;
26 30
27 import java.util.Arrays; 31 import java.util.Arrays;
28 import java.util.List; 32 import java.util.List;
...@@ -33,7 +37,7 @@ import static org.onosproject.app.ApplicationState.ACTIVE; ...@@ -33,7 +37,7 @@ import static org.onosproject.app.ApplicationState.ACTIVE;
33 /** 37 /**
34 * Message handler for application view related messages. 38 * Message handler for application view related messages.
35 */ 39 */
36 -public class ApplicationViewMessageHandler extends AbstractTabularViewMessageHandler { 40 +public class ApplicationViewMessageHandler extends UiMessageHandler {
37 41
38 /** 42 /**
39 * Creates a new message handler for the application messages. 43 * Creates a new message handler for the application messages.
...@@ -44,7 +48,7 @@ public class ApplicationViewMessageHandler extends AbstractTabularViewMessageHan ...@@ -44,7 +48,7 @@ public class ApplicationViewMessageHandler extends AbstractTabularViewMessageHan
44 48
45 @Override 49 @Override
46 public void process(ObjectNode message) { 50 public void process(ObjectNode message) {
47 - String type = string(message, "event", "unknown"); 51 + String type = eventType(message);
48 if (type.equals("appDataRequest")) { 52 if (type.equals("appDataRequest")) {
49 sendAppList(message); 53 sendAppList(message);
50 } else if (type.equals("appManagementRequest")) { 54 } else if (type.equals("appManagementRequest")) {
...@@ -54,17 +58,13 @@ public class ApplicationViewMessageHandler extends AbstractTabularViewMessageHan ...@@ -54,17 +58,13 @@ public class ApplicationViewMessageHandler extends AbstractTabularViewMessageHan
54 58
55 private void sendAppList(ObjectNode message) { 59 private void sendAppList(ObjectNode message) {
56 ObjectNode payload = payload(message); 60 ObjectNode payload = payload(message);
57 - String sortCol = string(payload, "sortCol", "id"); 61 + RowComparator rc = TableUtils.createRowComparator(payload);
58 - String sortDir = string(payload, "sortDir", "asc");
59 62
60 ApplicationService service = get(ApplicationService.class); 63 ApplicationService service = get(ApplicationService.class);
61 TableRow[] rows = generateTableRows(service); 64 TableRow[] rows = generateTableRows(service);
62 - RowComparator rc =
63 - new RowComparator(sortCol, RowComparator.direction(sortDir));
64 Arrays.sort(rows, rc); 65 Arrays.sort(rows, rc);
65 - ArrayNode applications = generateArrayNode(rows);
66 ObjectNode rootNode = mapper.createObjectNode(); 66 ObjectNode rootNode = mapper.createObjectNode();
67 - rootNode.set("apps", applications); 67 + rootNode.set("apps", TableUtils.generateArrayNode(rows));
68 68
69 connection().sendMessage("appDataResponse", 0, rootNode); 69 connection().sendMessage("appDataResponse", 0, rootNode);
70 } 70 }
...@@ -95,7 +95,8 @@ public class ApplicationViewMessageHandler extends AbstractTabularViewMessageHan ...@@ -95,7 +95,8 @@ public class ApplicationViewMessageHandler extends AbstractTabularViewMessageHan
95 } 95 }
96 96
97 /** 97 /**
98 - * TableRow implementation for {@link org.onosproject.core.Application applications}. 98 + * TableRow implementation for
99 + * {@link org.onosproject.core.Application applications}.
99 */ 100 */
100 private static class ApplicationTableRow extends AbstractTableRow { 101 private static class ApplicationTableRow extends AbstractTableRow {
101 102
...@@ -118,10 +119,10 @@ public class ApplicationViewMessageHandler extends AbstractTabularViewMessageHan ...@@ -118,10 +119,10 @@ public class ApplicationViewMessageHandler extends AbstractTabularViewMessageHan
118 ApplicationState state = service.getState(app.id()); 119 ApplicationState state = service.getState(app.id());
119 String iconId = state == ACTIVE ? ICON_ID_ACTIVE : ICON_ID_INACTIVE; 120 String iconId = state == ACTIVE ? ICON_ID_ACTIVE : ICON_ID_INACTIVE;
120 121
121 - add(STATE, state.toString()); 122 + add(STATE, state);
122 add(STATE_IID, iconId); 123 add(STATE_IID, iconId);
123 add(ID, app.id().name()); 124 add(ID, app.id().name());
124 - add(VERSION, app.version().toString()); 125 + add(VERSION, app.version());
125 add(ORIGIN, app.origin()); 126 add(ORIGIN, app.origin());
126 add(DESC, app.description()); 127 add(DESC, app.description());
127 } 128 }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
16 16
17 package org.onosproject.ui.impl; 17 package org.onosproject.ui.impl;
18 18
19 -import com.fasterxml.jackson.databind.node.ArrayNode;
20 import com.fasterxml.jackson.databind.node.ObjectNode; 19 import com.fasterxml.jackson.databind.node.ObjectNode;
21 import com.google.common.collect.ImmutableSet; 20 import com.google.common.collect.ImmutableSet;
22 import org.joda.time.DateTime; 21 import org.joda.time.DateTime;
...@@ -24,6 +23,11 @@ import org.joda.time.format.DateTimeFormat; ...@@ -24,6 +23,11 @@ import org.joda.time.format.DateTimeFormat;
24 import org.onosproject.cluster.ClusterService; 23 import org.onosproject.cluster.ClusterService;
25 import org.onosproject.cluster.ControllerNode; 24 import org.onosproject.cluster.ControllerNode;
26 import org.onosproject.cluster.NodeId; 25 import org.onosproject.cluster.NodeId;
26 +import org.onosproject.ui.UiMessageHandler;
27 +import org.onosproject.ui.table.AbstractTableRow;
28 +import org.onosproject.ui.table.RowComparator;
29 +import org.onosproject.ui.table.TableRow;
30 +import org.onosproject.ui.table.TableUtils;
27 31
28 import java.util.ArrayList; 32 import java.util.ArrayList;
29 import java.util.Arrays; 33 import java.util.Arrays;
...@@ -33,7 +37,7 @@ import java.util.List; ...@@ -33,7 +37,7 @@ import java.util.List;
33 /** 37 /**
34 * Message handler for cluster view related messages. 38 * Message handler for cluster view related messages.
35 */ 39 */
36 -public class ClusterViewMessageHandler extends AbstractTabularViewMessageHandler { 40 +public class ClusterViewMessageHandler extends UiMessageHandler {
37 41
38 /** 42 /**
39 * Creates a new message handler for the cluster messages. 43 * Creates a new message handler for the cluster messages.
...@@ -44,18 +48,21 @@ public class ClusterViewMessageHandler extends AbstractTabularViewMessageHandler ...@@ -44,18 +48,21 @@ public class ClusterViewMessageHandler extends AbstractTabularViewMessageHandler
44 48
45 @Override 49 @Override
46 public void process(ObjectNode message) { 50 public void process(ObjectNode message) {
51 + String type = eventType(message);
52 + if (type.equals("clusterDataRequest")) {
53 + sendClusterList(message);
54 + }
55 + }
56 +
57 + private void sendClusterList(ObjectNode message) {
47 ObjectNode payload = payload(message); 58 ObjectNode payload = payload(message);
48 - String sortCol = string(payload, "sortCol", "id"); 59 + RowComparator rc = TableUtils.createRowComparator(payload);
49 - String sortDir = string(payload, "sortDir", "asc");
50 60
51 ClusterService service = get(ClusterService.class); 61 ClusterService service = get(ClusterService.class);
52 TableRow[] rows = generateTableRows(service); 62 TableRow[] rows = generateTableRows(service);
53 - RowComparator rc =
54 - new RowComparator(sortCol, RowComparator.direction(sortDir));
55 Arrays.sort(rows, rc); 63 Arrays.sort(rows, rc);
56 - ArrayNode clusterNodes = generateArrayNode(rows);
57 ObjectNode rootNode = mapper.createObjectNode(); 64 ObjectNode rootNode = mapper.createObjectNode();
58 - rootNode.set("clusters", clusterNodes); 65 + rootNode.set("clusters", TableUtils.generateArrayNode(rows));
59 66
60 connection().sendMessage("clusterDataResponse", 0, rootNode); 67 connection().sendMessage("clusterDataResponse", 0, rootNode);
61 } 68 }
......
...@@ -27,6 +27,11 @@ import org.onosproject.net.Link; ...@@ -27,6 +27,11 @@ import org.onosproject.net.Link;
27 import org.onosproject.net.Port; 27 import org.onosproject.net.Port;
28 import org.onosproject.net.device.DeviceService; 28 import org.onosproject.net.device.DeviceService;
29 import org.onosproject.net.link.LinkService; 29 import org.onosproject.net.link.LinkService;
30 +import org.onosproject.ui.UiMessageHandler;
31 +import org.onosproject.ui.table.AbstractTableRow;
32 +import org.onosproject.ui.table.RowComparator;
33 +import org.onosproject.ui.table.TableRow;
34 +import org.onosproject.ui.table.TableUtils;
30 35
31 import java.util.ArrayList; 36 import java.util.ArrayList;
32 import java.util.Arrays; 37 import java.util.Arrays;
...@@ -37,7 +42,7 @@ import java.util.Set; ...@@ -37,7 +42,7 @@ import java.util.Set;
37 /** 42 /**
38 * Message handler for device view related messages. 43 * Message handler for device view related messages.
39 */ 44 */
40 -public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler { 45 +public class DeviceViewMessageHandler extends UiMessageHandler {
41 46
42 private static final String ID = "id"; 47 private static final String ID = "id";
43 private static final String TYPE = "type"; 48 private static final String TYPE = "type";
...@@ -68,36 +73,31 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler ...@@ -68,36 +73,31 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler
68 } 73 }
69 74
70 @Override 75 @Override
71 - public void process(ObjectNode event) { 76 + public void process(ObjectNode message) {
72 - String type = string(event, "event", "unknown"); 77 + String type = eventType(message);
73 if (type.equals("deviceDataRequest")) { 78 if (type.equals("deviceDataRequest")) {
74 - dataRequest(event); 79 + dataRequest(message);
75 } else if (type.equals("deviceDetailsRequest")) { 80 } else if (type.equals("deviceDetailsRequest")) {
76 - detailsRequest(event); 81 + detailsRequest(message);
77 } 82 }
78 } 83 }
79 84
80 - private void dataRequest(ObjectNode event) { 85 + private void dataRequest(ObjectNode message) {
81 - ObjectNode payload = payload(event); 86 + ObjectNode payload = payload(message);
82 - String sortCol = string(payload, "sortCol", "id"); 87 + RowComparator rc = TableUtils.createRowComparator(payload);
83 - String sortDir = string(payload, "sortDir", "asc");
84 88
85 DeviceService service = get(DeviceService.class); 89 DeviceService service = get(DeviceService.class);
86 MastershipService mastershipService = get(MastershipService.class); 90 MastershipService mastershipService = get(MastershipService.class);
87 -
88 TableRow[] rows = generateTableRows(service, mastershipService); 91 TableRow[] rows = generateTableRows(service, mastershipService);
89 - RowComparator rc =
90 - new RowComparator(sortCol, RowComparator.direction(sortDir));
91 Arrays.sort(rows, rc); 92 Arrays.sort(rows, rc);
92 - ArrayNode devices = generateArrayNode(rows);
93 ObjectNode rootNode = mapper.createObjectNode(); 93 ObjectNode rootNode = mapper.createObjectNode();
94 - rootNode.set("devices", devices); 94 + rootNode.set("devices", TableUtils.generateArrayNode(rows));
95 95
96 connection().sendMessage("deviceDataResponse", 0, rootNode); 96 connection().sendMessage("deviceDataResponse", 0, rootNode);
97 } 97 }
98 98
99 - private void detailsRequest(ObjectNode event) { 99 + private void detailsRequest(ObjectNode message) {
100 - ObjectNode payload = payload(event); 100 + ObjectNode payload = payload(message);
101 String id = string(payload, "id", "of:0000000000000000"); 101 String id = string(payload, "id", "of:0000000000000000");
102 102
103 DeviceId deviceId = DeviceId.deviceId(id); 103 DeviceId deviceId = DeviceId.deviceId(id);
...@@ -139,9 +139,7 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler ...@@ -139,9 +139,7 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler
139 MastershipService mastershipService) { 139 MastershipService mastershipService) {
140 List<TableRow> list = new ArrayList<>(); 140 List<TableRow> list = new ArrayList<>();
141 for (Device dev : service.getDevices()) { 141 for (Device dev : service.getDevices()) {
142 - list.add(new DeviceTableRow(service, 142 + list.add(new DeviceTableRow(service, mastershipService, dev));
143 - mastershipService,
144 - dev));
145 } 143 }
146 return list.toArray(new TableRow[list.size()]); 144 return list.toArray(new TableRow[list.size()]);
147 } 145 }
...@@ -159,13 +157,13 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler ...@@ -159,13 +157,13 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler
159 157
160 Set<Link> links = ls.getEgressLinks(new ConnectPoint(id, p.number())); 158 Set<Link> links = ls.getEgressLinks(new ConnectPoint(id, p.number()));
161 if (!links.isEmpty()) { 159 if (!links.isEmpty()) {
162 - String egressLinks = ""; 160 + StringBuilder egressLinks = new StringBuilder();
163 for (Link l : links) { 161 for (Link l : links) {
164 ConnectPoint dest = l.dst(); 162 ConnectPoint dest = l.dst();
165 - egressLinks += dest.elementId().toString() 163 + egressLinks.append(dest.elementId()).append("/")
166 - + "/" + dest.port().toString() + " "; 164 + .append(dest.port()).append(" ");
167 } 165 }
168 - port.put(LINK_DEST, egressLinks); 166 + port.put(LINK_DEST, egressLinks.toString());
169 } 167 }
170 168
171 return port; 169 return port;
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
16 16
17 package org.onosproject.ui.impl; 17 package org.onosproject.ui.impl;
18 18
19 -import com.fasterxml.jackson.databind.node.ArrayNode;
20 import com.fasterxml.jackson.databind.node.ObjectNode; 19 import com.fasterxml.jackson.databind.node.ObjectNode;
21 import com.google.common.collect.ImmutableSet; 20 import com.google.common.collect.ImmutableSet;
22 import org.apache.commons.lang.WordUtils; 21 import org.apache.commons.lang.WordUtils;
...@@ -27,6 +26,11 @@ import org.onosproject.net.flow.TrafficSelector; ...@@ -27,6 +26,11 @@ import org.onosproject.net.flow.TrafficSelector;
27 import org.onosproject.net.flow.TrafficTreatment; 26 import org.onosproject.net.flow.TrafficTreatment;
28 import org.onosproject.net.flow.criteria.Criterion; 27 import org.onosproject.net.flow.criteria.Criterion;
29 import org.onosproject.net.flow.instructions.Instruction; 28 import org.onosproject.net.flow.instructions.Instruction;
29 +import org.onosproject.ui.UiMessageHandler;
30 +import org.onosproject.ui.table.AbstractTableRow;
31 +import org.onosproject.ui.table.RowComparator;
32 +import org.onosproject.ui.table.TableRow;
33 +import org.onosproject.ui.table.TableUtils;
30 34
31 import java.util.ArrayList; 35 import java.util.ArrayList;
32 import java.util.Arrays; 36 import java.util.Arrays;
...@@ -37,7 +41,7 @@ import java.util.Set; ...@@ -37,7 +41,7 @@ import java.util.Set;
37 /** 41 /**
38 * Message handler for flow view related messages. 42 * Message handler for flow view related messages.
39 */ 43 */
40 -public class FlowViewMessageHandler extends AbstractTabularViewMessageHandler { 44 +public class FlowViewMessageHandler extends UiMessageHandler {
41 45
42 private static final String NO_DEV = "none"; 46 private static final String NO_DEV = "none";
43 47
...@@ -50,10 +54,16 @@ public class FlowViewMessageHandler extends AbstractTabularViewMessageHandler { ...@@ -50,10 +54,16 @@ public class FlowViewMessageHandler extends AbstractTabularViewMessageHandler {
50 54
51 @Override 55 @Override
52 public void process(ObjectNode message) { 56 public void process(ObjectNode message) {
57 + String type = eventType(message);
58 + if (type.equals("flowDataRequest")) {
59 + sendFlowList(message);
60 + }
61 + }
62 +
63 + private void sendFlowList(ObjectNode message) {
53 ObjectNode payload = payload(message); 64 ObjectNode payload = payload(message);
65 + RowComparator rc = TableUtils.createRowComparator(payload);
54 String uri = string(payload, "devId", NO_DEV); 66 String uri = string(payload, "devId", NO_DEV);
55 - String sortCol = string(payload, "sortCol", "id");
56 - String sortDir = string(payload, "sortDir", "asc");
57 67
58 ObjectNode rootNode; 68 ObjectNode rootNode;
59 if (uri.equals(NO_DEV)) { 69 if (uri.equals(NO_DEV)) {
...@@ -61,16 +71,11 @@ public class FlowViewMessageHandler extends AbstractTabularViewMessageHandler { ...@@ -61,16 +71,11 @@ public class FlowViewMessageHandler extends AbstractTabularViewMessageHandler {
61 rootNode.set("flows", mapper.createArrayNode()); 71 rootNode.set("flows", mapper.createArrayNode());
62 } else { 72 } else {
63 DeviceId deviceId = DeviceId.deviceId(uri); 73 DeviceId deviceId = DeviceId.deviceId(uri);
64 -
65 FlowRuleService service = get(FlowRuleService.class); 74 FlowRuleService service = get(FlowRuleService.class);
66 TableRow[] rows = generateTableRows(service, deviceId); 75 TableRow[] rows = generateTableRows(service, deviceId);
67 - RowComparator rc =
68 - new RowComparator(sortCol, RowComparator.direction(sortDir));
69 Arrays.sort(rows, rc); 76 Arrays.sort(rows, rc);
70 - ArrayNode flows = generateArrayNode(rows);
71 -
72 rootNode = mapper.createObjectNode(); 77 rootNode = mapper.createObjectNode();
73 - rootNode.set("flows", flows); 78 + rootNode.set("flows", TableUtils.generateArrayNode(rows));
74 } 79 }
75 80
76 connection().sendMessage("flowDataResponse", 0, rootNode); 81 connection().sendMessage("flowDataResponse", 0, rootNode);
...@@ -191,7 +196,6 @@ public class FlowViewMessageHandler extends AbstractTabularViewMessageHandler { ...@@ -191,7 +196,6 @@ public class FlowViewMessageHandler extends AbstractTabularViewMessageHandler {
191 return sb; 196 return sb;
192 } 197 }
193 198
194 -
195 @Override 199 @Override
196 protected String[] columnIds() { 200 protected String[] columnIds() {
197 return COL_IDS; 201 return COL_IDS;
......
...@@ -15,13 +15,17 @@ ...@@ -15,13 +15,17 @@
15 */ 15 */
16 package org.onosproject.ui.impl; 16 package org.onosproject.ui.impl;
17 17
18 -import com.fasterxml.jackson.databind.node.ArrayNode;
19 import com.fasterxml.jackson.databind.node.ObjectNode; 18 import com.fasterxml.jackson.databind.node.ObjectNode;
20 import com.google.common.collect.ImmutableSet; 19 import com.google.common.collect.ImmutableSet;
21 import org.onosproject.net.AnnotationKeys; 20 import org.onosproject.net.AnnotationKeys;
22 import org.onosproject.net.Host; 21 import org.onosproject.net.Host;
23 import org.onosproject.net.HostLocation; 22 import org.onosproject.net.HostLocation;
24 import org.onosproject.net.host.HostService; 23 import org.onosproject.net.host.HostService;
24 +import org.onosproject.ui.UiMessageHandler;
25 +import org.onosproject.ui.table.AbstractTableRow;
26 +import org.onosproject.ui.table.RowComparator;
27 +import org.onosproject.ui.table.TableRow;
28 +import org.onosproject.ui.table.TableUtils;
25 29
26 import java.util.ArrayList; 30 import java.util.ArrayList;
27 import java.util.Arrays; 31 import java.util.Arrays;
...@@ -32,7 +36,7 @@ import static com.google.common.base.Strings.isNullOrEmpty; ...@@ -32,7 +36,7 @@ import static com.google.common.base.Strings.isNullOrEmpty;
32 /** 36 /**
33 * Message handler for host view related messages. 37 * Message handler for host view related messages.
34 */ 38 */
35 -public class HostViewMessageHandler extends AbstractTabularViewMessageHandler { 39 +public class HostViewMessageHandler extends UiMessageHandler {
36 40
37 /** 41 /**
38 * Creates a new message handler for the host messages. 42 * Creates a new message handler for the host messages.
...@@ -43,18 +47,21 @@ public class HostViewMessageHandler extends AbstractTabularViewMessageHandler { ...@@ -43,18 +47,21 @@ public class HostViewMessageHandler extends AbstractTabularViewMessageHandler {
43 47
44 @Override 48 @Override
45 public void process(ObjectNode message) { 49 public void process(ObjectNode message) {
50 + String type = eventType(message);
51 + if (type.equals("hostDataRequest")) {
52 + sendHostList(message);
53 + }
54 + }
55 +
56 + private void sendHostList(ObjectNode message) {
46 ObjectNode payload = payload(message); 57 ObjectNode payload = payload(message);
47 - String sortCol = string(payload, "sortCol", "id"); 58 + RowComparator rc = TableUtils.createRowComparator(payload);
48 - String sortDir = string(payload, "sortDir", "asc");
49 59
50 HostService service = get(HostService.class); 60 HostService service = get(HostService.class);
51 TableRow[] rows = generateTableRows(service); 61 TableRow[] rows = generateTableRows(service);
52 - RowComparator rc =
53 - new RowComparator(sortCol, RowComparator.direction(sortDir));
54 Arrays.sort(rows, rc); 62 Arrays.sort(rows, rc);
55 - ArrayNode hosts = generateArrayNode(rows);
56 ObjectNode rootNode = mapper.createObjectNode(); 63 ObjectNode rootNode = mapper.createObjectNode();
57 - rootNode.set("hosts", hosts); 64 + rootNode.set("hosts", TableUtils.generateArrayNode(rows));
58 65
59 connection().sendMessage("hostDataResponse", 0, rootNode); 66 connection().sendMessage("hostDataResponse", 0, rootNode);
60 } 67 }
...@@ -89,12 +96,11 @@ public class HostViewMessageHandler extends AbstractTabularViewMessageHandler { ...@@ -89,12 +96,11 @@ public class HostViewMessageHandler extends AbstractTabularViewMessageHandler {
89 HostLocation location = h.location(); 96 HostLocation location = h.location();
90 97
91 add(TYPE_IID, getTypeIconId(h)); 98 add(TYPE_IID, getTypeIconId(h));
92 - add(ID, h.id().toString()); 99 + add(ID, h.id());
93 - add(MAC, h.mac().toString()); 100 + add(MAC, h.mac());
94 - add(VLAN, h.vlan().toString()); 101 + add(VLAN, h.vlan());
95 - add(IPS, h.ipAddresses().toString()); 102 + add(IPS, h.ipAddresses());
96 - add(LOCATION, (location.deviceId().toString() + '/' + 103 + add(LOCATION, concat(location.deviceId(), "/", location.port()));
97 - location.port().toString()));
98 } 104 }
99 105
100 private String getTypeIconId(Host host) { 106 private String getTypeIconId(Host host) {
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.ui.impl; 16 package org.onosproject.ui.impl;
17 17
18 -import com.fasterxml.jackson.databind.node.ArrayNode;
19 import com.fasterxml.jackson.databind.node.ObjectNode; 18 import com.fasterxml.jackson.databind.node.ObjectNode;
20 import com.google.common.collect.ImmutableSet; 19 import com.google.common.collect.ImmutableSet;
21 import org.onosproject.core.ApplicationId; 20 import org.onosproject.core.ApplicationId;
...@@ -32,6 +31,11 @@ import org.onosproject.net.intent.MultiPointToSinglePointIntent; ...@@ -32,6 +31,11 @@ import org.onosproject.net.intent.MultiPointToSinglePointIntent;
32 import org.onosproject.net.intent.PathIntent; 31 import org.onosproject.net.intent.PathIntent;
33 import org.onosproject.net.intent.PointToPointIntent; 32 import org.onosproject.net.intent.PointToPointIntent;
34 import org.onosproject.net.intent.SinglePointToMultiPointIntent; 33 import org.onosproject.net.intent.SinglePointToMultiPointIntent;
34 +import org.onosproject.ui.UiMessageHandler;
35 +import org.onosproject.ui.table.AbstractTableRow;
36 +import org.onosproject.ui.table.RowComparator;
37 +import org.onosproject.ui.table.TableRow;
38 +import org.onosproject.ui.table.TableUtils;
35 39
36 import java.util.ArrayList; 40 import java.util.ArrayList;
37 import java.util.Arrays; 41 import java.util.Arrays;
...@@ -41,7 +45,7 @@ import java.util.Set; ...@@ -41,7 +45,7 @@ import java.util.Set;
41 /** 45 /**
42 * Message handler for intent view related messages. 46 * Message handler for intent view related messages.
43 */ 47 */
44 -public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler { 48 +public class IntentViewMessageHandler extends UiMessageHandler {
45 49
46 /** 50 /**
47 * Creates a new message handler for the intent messages. 51 * Creates a new message handler for the intent messages.
...@@ -52,18 +56,21 @@ public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler ...@@ -52,18 +56,21 @@ public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler
52 56
53 @Override 57 @Override
54 public void process(ObjectNode message) { 58 public void process(ObjectNode message) {
59 + String type = eventType(message);
60 + if (type.equals("intentDataRequest")) {
61 + sendIntentList(message);
62 + }
63 + }
64 +
65 + private void sendIntentList(ObjectNode message) {
55 ObjectNode payload = payload(message); 66 ObjectNode payload = payload(message);
56 - String sortCol = string(payload, "sortCol", "appId"); 67 + RowComparator rc = TableUtils.createRowComparator(payload);
57 - String sortDir = string(payload, "sortDir", "asc");
58 68
59 IntentService service = get(IntentService.class); 69 IntentService service = get(IntentService.class);
60 TableRow[] rows = generateTableRows(service); 70 TableRow[] rows = generateTableRows(service);
61 - RowComparator rc =
62 - new RowComparator(sortCol, RowComparator.direction(sortDir));
63 Arrays.sort(rows, rc); 71 Arrays.sort(rows, rc);
64 - ArrayNode intents = generateArrayNode(rows);
65 ObjectNode rootNode = mapper.createObjectNode(); 72 ObjectNode rootNode = mapper.createObjectNode();
66 - rootNode.set("intents", intents); 73 + rootNode.set("intents", TableUtils.generateArrayNode(rows));
67 74
68 connection().sendMessage("intentDataResponse", 0, rootNode); 75 connection().sendMessage("intentDataResponse", 0, rootNode);
69 } 76 }
...@@ -222,10 +229,10 @@ public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler ...@@ -222,10 +229,10 @@ public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler
222 public IntentTableRow(Intent intent) { 229 public IntentTableRow(Intent intent) {
223 ApplicationId appid = intent.appId(); 230 ApplicationId appid = intent.appId();
224 231
225 - add(APP_ID, String.valueOf(appid.id()) + " : " + appid.name()); 232 + add(APP_ID, concat(appid.id(), " : ", appid.name()));
226 - add(KEY, intent.key().toString()); 233 + add(KEY, intent.key());
227 add(TYPE, intent.getClass().getSimpleName()); 234 add(TYPE, intent.getClass().getSimpleName());
228 - add(PRIORITY, Integer.toString(intent.priority())); 235 + add(PRIORITY, intent.priority());
229 add(RESOURCES, formatResources(intent)); 236 add(RESOURCES, formatResources(intent));
230 add(DETAILS, formatDetails(intent)); 237 add(DETAILS, formatDetails(intent));
231 } 238 }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
16 16
17 package org.onosproject.ui.impl; 17 package org.onosproject.ui.impl;
18 18
19 -import com.fasterxml.jackson.databind.node.ArrayNode;
20 import com.fasterxml.jackson.databind.node.ObjectNode; 19 import com.fasterxml.jackson.databind.node.ObjectNode;
21 import com.google.common.collect.ImmutableSet; 20 import com.google.common.collect.ImmutableSet;
22 import com.google.common.collect.Maps; 21 import com.google.common.collect.Maps;
...@@ -24,7 +23,12 @@ import org.onosproject.net.ConnectPoint; ...@@ -24,7 +23,12 @@ import org.onosproject.net.ConnectPoint;
24 import org.onosproject.net.Link; 23 import org.onosproject.net.Link;
25 import org.onosproject.net.LinkKey; 24 import org.onosproject.net.LinkKey;
26 import org.onosproject.net.link.LinkService; 25 import org.onosproject.net.link.LinkService;
26 +import org.onosproject.ui.UiMessageHandler;
27 import org.onosproject.ui.impl.TopologyViewMessageHandlerBase.BiLink; 27 import org.onosproject.ui.impl.TopologyViewMessageHandlerBase.BiLink;
28 +import org.onosproject.ui.table.AbstractTableRow;
29 +import org.onosproject.ui.table.RowComparator;
30 +import org.onosproject.ui.table.TableRow;
31 +import org.onosproject.ui.table.TableUtils;
28 32
29 import java.util.ArrayList; 33 import java.util.ArrayList;
30 import java.util.Arrays; 34 import java.util.Arrays;
...@@ -36,7 +40,7 @@ import static org.onosproject.ui.impl.TopologyViewMessageHandlerBase.addLink; ...@@ -36,7 +40,7 @@ import static org.onosproject.ui.impl.TopologyViewMessageHandlerBase.addLink;
36 /** 40 /**
37 * Message handler for link view related messages. 41 * Message handler for link view related messages.
38 */ 42 */
39 -public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler { 43 +public class LinkViewMessageHandler extends UiMessageHandler {
40 44
41 /** 45 /**
42 * Creates a new message handler for the link messages. 46 * Creates a new message handler for the link messages.
...@@ -47,18 +51,21 @@ public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler { ...@@ -47,18 +51,21 @@ public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler {
47 51
48 @Override 52 @Override
49 public void process(ObjectNode message) { 53 public void process(ObjectNode message) {
54 + String type = eventType(message);
55 + if (type.equals("linkDataRequest")) {
56 + sendLinkList(message);
57 + }
58 + }
59 +
60 + private void sendLinkList(ObjectNode message) {
50 ObjectNode payload = payload(message); 61 ObjectNode payload = payload(message);
51 - String sortCol = string(payload, "sortCol", "one"); 62 + RowComparator rc = TableUtils.createRowComparator(payload, "one");
52 - String sortDir = string(payload, "sortDir", "asc");
53 63
54 LinkService service = get(LinkService.class); 64 LinkService service = get(LinkService.class);
55 TableRow[] rows = generateTableRows(service); 65 TableRow[] rows = generateTableRows(service);
56 - RowComparator rc =
57 - new RowComparator(sortCol, RowComparator.direction(sortDir));
58 Arrays.sort(rows, rc); 66 Arrays.sort(rows, rc);
59 - ArrayNode links = generateArrayNode(rows);
60 ObjectNode rootNode = mapper.createObjectNode(); 67 ObjectNode rootNode = mapper.createObjectNode();
61 - rootNode.set("links", links); 68 + rootNode.set("links", TableUtils.generateArrayNode(rows));
62 69
63 connection().sendMessage("linkDataResponse", 0, rootNode); 70 connection().sendMessage("linkDataResponse", 0, rootNode);
64 } 71 }
...@@ -99,8 +106,8 @@ public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler { ...@@ -99,8 +106,8 @@ public class LinkViewMessageHandler extends AbstractTabularViewMessageHandler {
99 ConnectPoint dst = link.one.dst(); 106 ConnectPoint dst = link.one.dst();
100 linkState(link); 107 linkState(link);
101 108
102 - add(ONE, src.elementId().toString() + "/" + src.port().toString()); 109 + add(ONE, concat(src.elementId(), "/", src.port()));
103 - add(TWO, dst.elementId().toString() + "/" + dst.port().toString()); 110 + add(TWO, concat(dst.elementId(), "/", dst.port()));
104 add(TYPE, linkType(link).toLowerCase()); 111 add(TYPE, linkType(link).toLowerCase());
105 add(STATE, linkState(link)); 112 add(STATE, linkState(link));
106 add(DIRECTION, link.two != null ? "A <--> B" : "A --> B"); 113 add(DIRECTION, link.two != null ? "A <--> B" : "A --> B");
......
...@@ -131,7 +131,8 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { ...@@ -131,7 +131,8 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
131 * Creates a new web-socket for serving data to GUI topology view. 131 * Creates a new web-socket for serving data to GUI topology view.
132 */ 132 */
133 public TopologyViewMessageHandler() { 133 public TopologyViewMessageHandler() {
134 - super(ImmutableSet.of("topoStart", "topoStop", 134 + super(ImmutableSet.of("topoStart",
135 + "topoStop",
135 "requestDetails", 136 "requestDetails",
136 "updateMeta", 137 "updateMeta",
137 "addHostIntent", 138 "addHostIntent",
......