in src/main/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClient.java [292:322]
public Map<String, Object> getConfiguration(String pid, int... expectedStatus) throws ClientException {
// make the request
SlingHttpResponse resp = this.doPost(URL_CONFIGURATION + "/" + pid, null);
// check the returned status
HttpUtils.verifyHttpStatus(resp, HttpUtils.getExpectedStatus(SC_OK, expectedStatus));
// get the JSON node
JsonNode rootNode = JsonUtils.getJsonNodeFromString(resp.getContent());
// go through the params
Map<String, Object> props = new HashMap<String, Object>();
if(rootNode.get("properties") == null)
return props;
JsonNode properties = rootNode.get("properties");
for(Iterator<String> it = properties.fieldNames(); it.hasNext();) {
String propName = it.next();
JsonNode value = properties.get(propName).get("value");
if(value != null) {
props.put(propName, value.asText());
continue;
}
value = properties.get(propName).get("values");
if(value != null) {
Iterator<JsonNode> iter = value.elements();
List<String> list = new ArrayList<String>();
while(iter.hasNext()) {
list.add(iter.next().asText());
}
props.put(propName, list.toArray(new String[list.size()]));
}
}
return props;
}