use of co.cask.cdap.config.Config in project cdap by caskdata.
the class DashboardHttpHandler method list.
@Path("/")
@GET
public void list(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespace) throws Exception {
JsonArray jsonArray = new JsonArray();
List<Config> configList = dashboardStore.list(namespace);
for (Config config : configList) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(ID, config.getId());
jsonObject.add(CONFIG_PROPERTY, JSON_PARSER.parse(config.getProperties().get(CONFIG_PROPERTY)));
jsonArray.add(jsonObject);
}
responder.sendJson(HttpResponseStatus.OK, jsonArray.toString());
}
use of co.cask.cdap.config.Config in project cdap by caskdata.
the class DashboardHttpHandler method get.
@Path("/{dashboard-id}")
@GET
public void get(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespace, @PathParam("dashboard-id") String id) throws Exception {
try {
Config dashConfig = dashboardStore.get(namespace, id);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(ID, id);
// Dashboard Config is stored in ConfigStore as serialized JSON string with CONFIG_PROPERTY key.
// When we send the data back, we send it as JSON object instead of sending the serialized string.
jsonObject.add(CONFIG_PROPERTY, JSON_PARSER.parse(dashConfig.getProperties().get(CONFIG_PROPERTY)));
responder.sendJson(HttpResponseStatus.OK, jsonObject.toString());
} catch (ConfigNotFoundException e) {
responder.sendString(HttpResponseStatus.NOT_FOUND, "Dashboard not found");
}
}
Aggregations