Simon Hunt

CORD GUI - Shenanigans to deal with : in JSON key.

Change-Id: I3b6e235a7b769dd268fa9152e50de254efc30568
......@@ -47,8 +47,9 @@ import static org.onosproject.cord.gui.model.XosFunctionDescriptor.URL_FILTER;
public class CordModelCache extends JsonFactory {
private static final String KEY_SSID_MAP = "ssidmap";
// FIXME: should not be a colon in the key..... Scott to fix on XOS
private static final String KEY_SSID = "service_specific_id:";
private static final String KEY_SSID = "service_specific_id";
// FIXME: remove once the key has been fixed
private static final String KEY_SSID_ALT = "service_specific_id:";
private static final String KEY_SUB_ID = "subscriber_id";
private static final int DEMO_SSID = 1234;
......@@ -85,19 +86,34 @@ public class CordModelCache extends JsonFactory {
ObjectNode map = XosManager.INSTANCE.initXosSubscriberLookups();
initLookupMap(map);
log.info("{} entries in SSID->SubID lookup map", LOOKUP.size());
// force DEMO subscriber to be installed by default
init("foo@bar");
}
private void initLookupMap(ObjectNode map) {
ArrayNode array = (ArrayNode) map.get(KEY_SSID_MAP);
Iterator<JsonNode> iter = array.elements();
StringBuilder msg = new StringBuilder();
while (iter.hasNext()) {
ObjectNode node = (ObjectNode) iter.next();
String ssidStr = node.get(KEY_SSID).asText();
// FIXME: clean up once the colon has been removed from the key
JsonNode s = node.get(KEY_SSID);
if (s == null) {
s = node.get(KEY_SSID_ALT);
if (s == null) {
log.error("missing {} property!", KEY_SSID);
continue;
}
}
String ssidStr = s.asText();
int ssid = Integer.valueOf(ssidStr);
int subId = node.get(KEY_SUB_ID).asInt();
LOOKUP.put(ssid, subId);
log.info("... binding SSID {} to sub-id {}", ssid, subId);
msg.append(String.format("\n..binding SSID %s to sub-id %s", ssid, subId));
}
log.info(msg.toString());
}
private int lookupSubId(int ssid) {
......
......@@ -120,10 +120,7 @@ public class XosManagerRestUtils {
log.info("REST GET request returned error code {}",
response.getStatus());
}
String jsonString = response.getEntity(String.class);
log.info("JSON read:\n{}", jsonString);
return jsonString;
return response.getEntity(String.class);
}
/**
......@@ -157,10 +154,7 @@ public class XosManagerRestUtils {
log.info("REST PUT request returned error code {}",
response.getStatus());
}
String jsonString = response.getEntity(String.class);
log.info("JSON read:\n{}", jsonString);
return jsonString;
return response.getEntity(String.class);
}
/**
......