static Map extractOSGiConfiguration()

in src/main/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClient.java [340:375]


    static Map<String, Object> extractOSGiConfiguration(final JsonNode rootNode) {
        // bundle_location is not set, the configuration does not exist
        if ( rootNode.get("bundle_location") == null ) {
            return null;
        }

        final Map<String, Object> result = new HashMap<String, Object>();
        // go through the properties
        final JsonNode propertiesNode = rootNode.get("properties");
        if ( propertiesNode != null ) {
            for(Iterator<String> it = propertiesNode.fieldNames(); it.hasNext();) {
                final String propName = it.next();
                final JsonNode propNode = propertiesNode.get(propName);

                final boolean isSet = propNode.get("is_set").booleanValue();
                if ( isSet ) {
                    JsonNode value = propNode.get("value");
                    if (value != null) {
                        result.put(propName, value.asText());
                    } else {
                        value = propNode.get("values");
                        if (value != null) {
                            final Iterator<JsonNode> iter = value.elements();
                            List<String> list = new ArrayList<String>();
                            while(iter.hasNext()) {
                                list.add(iter.next().asText());
                            }
                            result.put(propName, list.toArray(new String[list.size()]));
                        }
                    }
                }
            }
        }

        return result;
    }