private void writeJSON(final PrintWriter pw) throws IOException {
final List<Repository> repositories = this.getRepositories();
final List<ExtendedFeature> features = this.getFeatures(repositories);
final String statusLine = this.getStatusLine(features);
final JSONWriter jw = new JSONWriter(pw);
try {
jw.object();
jw.key("status");
jw.value(statusLine);
jw.key("repositories");
jw.array();
for (Repository r : repositories) {
jw.object();
jw.key("name");
jw.value(r.getName());
jw.key("url");
String uri = r.getURI().toString();
jw.value(uri);
jw.key("actions");
jw.array();
boolean enable = true;
if (uri.startsWith("bundle")) {
enable = false;
}
action(jw, enable, "refreshRepository", "Refresh", "refresh");
action(jw, enable, "removeRepository", "Remove", "delete");
jw.endArray();
jw.endObject();
}
jw.endArray();
jw.key("features");
jw.array();
for (ExtendedFeature f : features) {
featureInfo(jw, f);
}
jw.endArray();
jw.endObject();
} catch (JSONException je) {
throw new IOException(je.toString());
}
}