CORD GUI - Shenanigans to deal with : in JSON key.
Change-Id: I3b6e235a7b769dd268fa9152e50de254efc30568
Showing
2 changed files
with
22 additions
and
12 deletions
... | @@ -47,8 +47,9 @@ import static org.onosproject.cord.gui.model.XosFunctionDescriptor.URL_FILTER; | ... | @@ -47,8 +47,9 @@ import static org.onosproject.cord.gui.model.XosFunctionDescriptor.URL_FILTER; |
47 | public class CordModelCache extends JsonFactory { | 47 | public class CordModelCache extends JsonFactory { |
48 | 48 | ||
49 | private static final String KEY_SSID_MAP = "ssidmap"; | 49 | private static final String KEY_SSID_MAP = "ssidmap"; |
50 | - // FIXME: should not be a colon in the key..... Scott to fix on XOS | 50 | + private static final String KEY_SSID = "service_specific_id"; |
51 | - private static final String KEY_SSID = "service_specific_id:"; | 51 | + // FIXME: remove once the key has been fixed |
52 | + private static final String KEY_SSID_ALT = "service_specific_id:"; | ||
52 | private static final String KEY_SUB_ID = "subscriber_id"; | 53 | private static final String KEY_SUB_ID = "subscriber_id"; |
53 | 54 | ||
54 | private static final int DEMO_SSID = 1234; | 55 | private static final int DEMO_SSID = 1234; |
... | @@ -85,19 +86,34 @@ public class CordModelCache extends JsonFactory { | ... | @@ -85,19 +86,34 @@ public class CordModelCache extends JsonFactory { |
85 | ObjectNode map = XosManager.INSTANCE.initXosSubscriberLookups(); | 86 | ObjectNode map = XosManager.INSTANCE.initXosSubscriberLookups(); |
86 | initLookupMap(map); | 87 | initLookupMap(map); |
87 | log.info("{} entries in SSID->SubID lookup map", LOOKUP.size()); | 88 | log.info("{} entries in SSID->SubID lookup map", LOOKUP.size()); |
89 | + // force DEMO subscriber to be installed by default | ||
90 | + init("foo@bar"); | ||
88 | } | 91 | } |
89 | 92 | ||
90 | private void initLookupMap(ObjectNode map) { | 93 | private void initLookupMap(ObjectNode map) { |
91 | ArrayNode array = (ArrayNode) map.get(KEY_SSID_MAP); | 94 | ArrayNode array = (ArrayNode) map.get(KEY_SSID_MAP); |
92 | Iterator<JsonNode> iter = array.elements(); | 95 | Iterator<JsonNode> iter = array.elements(); |
96 | + StringBuilder msg = new StringBuilder(); | ||
93 | while (iter.hasNext()) { | 97 | while (iter.hasNext()) { |
94 | ObjectNode node = (ObjectNode) iter.next(); | 98 | ObjectNode node = (ObjectNode) iter.next(); |
95 | - String ssidStr = node.get(KEY_SSID).asText(); | 99 | + |
100 | + // FIXME: clean up once the colon has been removed from the key | ||
101 | + JsonNode s = node.get(KEY_SSID); | ||
102 | + if (s == null) { | ||
103 | + s = node.get(KEY_SSID_ALT); | ||
104 | + if (s == null) { | ||
105 | + log.error("missing {} property!", KEY_SSID); | ||
106 | + continue; | ||
107 | + } | ||
108 | + } | ||
109 | + | ||
110 | + String ssidStr = s.asText(); | ||
96 | int ssid = Integer.valueOf(ssidStr); | 111 | int ssid = Integer.valueOf(ssidStr); |
97 | int subId = node.get(KEY_SUB_ID).asInt(); | 112 | int subId = node.get(KEY_SUB_ID).asInt(); |
98 | LOOKUP.put(ssid, subId); | 113 | LOOKUP.put(ssid, subId); |
99 | - log.info("... binding SSID {} to sub-id {}", ssid, subId); | 114 | + msg.append(String.format("\n..binding SSID %s to sub-id %s", ssid, subId)); |
100 | } | 115 | } |
116 | + log.info(msg.toString()); | ||
101 | } | 117 | } |
102 | 118 | ||
103 | private int lookupSubId(int ssid) { | 119 | private int lookupSubId(int ssid) { | ... | ... |
... | @@ -120,10 +120,7 @@ public class XosManagerRestUtils { | ... | @@ -120,10 +120,7 @@ public class XosManagerRestUtils { |
120 | log.info("REST GET request returned error code {}", | 120 | log.info("REST GET request returned error code {}", |
121 | response.getStatus()); | 121 | response.getStatus()); |
122 | } | 122 | } |
123 | - String jsonString = response.getEntity(String.class); | 123 | + return response.getEntity(String.class); |
124 | - log.info("JSON read:\n{}", jsonString); | ||
125 | - | ||
126 | - return jsonString; | ||
127 | } | 124 | } |
128 | 125 | ||
129 | /** | 126 | /** |
... | @@ -157,10 +154,7 @@ public class XosManagerRestUtils { | ... | @@ -157,10 +154,7 @@ public class XosManagerRestUtils { |
157 | log.info("REST PUT request returned error code {}", | 154 | log.info("REST PUT request returned error code {}", |
158 | response.getStatus()); | 155 | response.getStatus()); |
159 | } | 156 | } |
160 | - String jsonString = response.getEntity(String.class); | 157 | + return response.getEntity(String.class); |
161 | - log.info("JSON read:\n{}", jsonString); | ||
162 | - | ||
163 | - return jsonString; | ||
164 | } | 158 | } |
165 | 159 | ||
166 | /** | 160 | /** | ... | ... |
-
Please register or login to post a comment