final String nonSecureGadgetDataKey = gadgetSpecUrl;
if (fetchDataByKey(nonSecureGadgetDataKey, receiveDataCommand)) {
return;
}
JSONObject request = new JSONObject();
JSONObject requestContext = new JSONObject();
JSONArray gadgets = new JSONArray();
JSONObject gadget = new JSONObject();
try {
gadget.put("url", new JSONString(gadgetSpecUrl));
gadgets.set(0, gadget);
requestContext.put("container", new JSONString("wave"));
request.put("context", requestContext);
request.put("gadgets", gadgets);
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, GADGET_METADATA_PATH);
builder.sendRequest(request.toString(), new RequestCallback() {
public void onError(Request request, Throwable exception) {
receiveDataCommand.onError("Error retrieving metadata from the server.", exception);
}
public void onResponseReceived(Request request, Response response) {
JSONObject gadgetMetadata = null;
try {
gadgetMetadata =
JSONParser.parseLenient(response.getText()).isObject().get("gadgets").isArray().get(
0).isObject();
} catch (NullPointerException exception) {