public static JSONObject getConfiguration(final View view) throws ViewException { final JSONObject configuration = new JSONObject(); final List<Bundle> bundles = view.getBundles(); for (Bundle s : bundles) { final String conf = s.getConfig(); final String state = s.getState(); final String name = s.getBundleinstance(); try { // setup bundle node in config JSONObject bundle = new JSONObject(); configuration.put(name, bundle); // setup conf for bundle if (conf != null) { bundle.put("conf", new JSONObject(conf)); } else { log.warn("Could not get configuration fragment for bundle '", name, "'"); } // setup state for bundle if (state != null) { bundle.put("state", new JSONObject(state)); } else { log.warn("Could not get state fragment for bundle '", name, "'"); } } catch (Exception ex) { log.error("Malformed JSON in configuration fragment for bundle", name, conf); } } return configuration; }