}
/** convert an instance description into a json object **/
private static JSONObject asJSON(final InstanceDescription instanceDescription)
throws JSONException {
JSONObject obj = new JSONObject();
obj.put("slingId", instanceDescription.getSlingId());
obj.put("isLeader", instanceDescription.isLeader());
ClusterView cluster = instanceDescription.getClusterView();
if (cluster != null) {
obj.put("cluster", cluster.getId());
}
JSONObject propertiesObj = new JSONObject();
Map<String, String> propertiesMap = instanceDescription.getProperties();
for (Iterator<Entry<String, String>> it = propertiesMap.entrySet()
.iterator(); it.hasNext();) {
Entry<String, String> entry = it.next();
propertiesObj.put(entry.getKey(), entry.getValue());
}
obj.put("properties", propertiesObj);
return obj;
}