Package com.google.gwt.dev.json

Examples of com.google.gwt.dev.json.JsonObject


  /**
   * Exports the template variables for dev_mode_on.js.
   */
  JsonObject exportDevModeOnVars() {
    JsonObject out = JsonObject.create();
    out.put("moduleNames", exportOutputModuleNames()); // TODO: rename
    out.put("warnings", exportWarnings());
    return out;
  }
View Full Code Here


    Arrays.sort(files);

    JsonArray result = new JsonArray();
    for (File file : files) {
      if (file.isFile()) {
        JsonObject map = new JsonObject();
        map.put("name", file.getName());
        map.put("link", file.getName());
        result.add(map);
      }
    }
    return result;
  }
View Full Code Here

    }
    return result;
  }

  private JsonObject exportMap(SortedMap<String, String> bindings) {
    JsonObject out = new JsonObject();
    for (String name : bindings.keySet()) {
      out.put(name, bindings.get(name));
    }
    return out;
  }
View Full Code Here

    return Responses.newTimedResponse(barePage, "sent source map for module '" + moduleName + "'");
  }

  private Response makeDirectoryListPage(Outbox box) throws IOException {
    SourceMap map = SourceMap.load(box.findSourceMapForOnePermutation());
    JsonObject json = exporter.exportSourceMapDirectoryListVars(box, map);
    return Pages.newHtmlPage("config", json, "directorylist.html");
  }
View Full Code Here

  }

  private Response sendFileListPage(Outbox box, String rest) throws IOException {

    SourceMap map = SourceMap.load(box.findSourceMapForOnePermutation());
    JsonObject json = exporter.exportSourceMapFileListVars(box, map, rest);
    return Pages.newHtmlPage("config", json, "filelist.html");
  }
View Full Code Here

   */
  private Response doGet(String target, HttpServletRequest request, TreeLogger logger)
      throws IOException {

    if (target.equals("/")) {
      JsonObject json = jsonExporter.exportFrontPageVars();
      return Pages.newHtmlPage("config", json, "frontpage.html");
    }

    if (target.equals("/dev_mode_on.js")) {
      JsonObject json = jsonExporter.exportDevModeOnVars();
      return Responses.newJavascriptResponse("__gwt_codeserver_config", json,
          "dev_mode_on.js");
    }

    // Recompile on request from the bookmarklet.
    // This is a GET because a bookmarklet can call it from a different origin (JSONP).
    if (target.startsWith("/recompile/")) {
      String moduleName = target.substring("/recompile/".length());
      Outbox box = outboxes.findByOutputModuleName(moduleName);
      if (box == null) {
        return new ErrorPage("No such module: " + moduleName);
      }

      // We are passing properties from an unauthenticated GET request directly to the compiler.
      // This should be safe, but only because these are binding properties. For each binding
      // property, you can only choose from a set of predefined values. So all an attacker can do is
      // cause a spurious recompile, resulting in an unexpected permutation being loaded later.
      //
      // It would be unsafe to allow a configuration property to be changed.
      Job job = box.makeJob(getBindingProperties(request), logger);
      runner.submit(job);
      Job.Result result = job.waitForResult();
      JsonObject json = jsonExporter.exportRecompileResponse(result);
      return Responses.newJsonResponse(json);
    }

    // GET the Js that knows how to request the specific permutation recompile.
    if (target.startsWith("/recompile-requester/")) {
      String moduleName = target.substring("/recompile-requester/".length());
      Outbox box = outboxes.findByOutputModuleName(moduleName);
      if (box == null) {
        return new ErrorPage("No such module: " + moduleName);
      }

      try {
        String recompileJs = runner.getRecompileJs(logger, box);
        return Responses.newJavascriptResponse(recompileJs);
      } catch (ExecutionException e) {
        // Already logged.
        return new ErrorPage("Failed to generate the Js recompile requester.");
      }
    }

    if (target.startsWith("/log/")) {
      String moduleName = target.substring("/log/".length());
      Outbox box = outboxes.findByOutputModuleName(moduleName);
      if (box == null) {
        return new ErrorPage("No such module: " + moduleName);
      } else if (box.containsStubCompile()) {
        return new ErrorPage("This module hasn't been compiled yet.");
      } else {
        return makeLogPage(box);
      }
    }

    if (target.equals("/favicon.ico")) {
      InputStream faviconStream = getClass().getResourceAsStream("favicon.ico");
      if (faviconStream == null) {
        return new ErrorPage("icon not found");
      }
      // IE8 will not load the favicon in an img tag with the default MIME type,
      // so use "image/x-icon" instead.
      return Responses.newBinaryStreamResponse("image/x-icon", faviconStream);
    }

    if (target.equals("/policies/")) {
      return makePolicyIndexPage();
    }

    if (target.equals("/progress")) {
      // TODO: return a list of progress objects here, one for each job.
      JobEvent event = eventTable.getCompilingJobEvent();

      JsonObject json;
      if (event == null) {
        json = new JsonObject();
        json.put("status", "idle");
      } else {
        json = jsonExporter.exportProgressResponse(event);
      }
      return Responses.newJsonResponse(json);
    }
View Full Code Here

    Outbox box = outboxes.findByOutputModuleName(moduleName);
    if (box == null) {
      return new ErrorPage("No such module: " + moduleName);
    }

    JsonObject json = jsonExporter.exportModulePageVars(box);
    return Pages.newHtmlPage("config", json, "modulepage.html");
  }
View Full Code Here

    logger.endImpl(dummyThreeEvent);
    logger.endImpl(dummyOneEvent);
    logger.flush();

    Reader jsonReader = extractJsonFromWriter(writer);
    JsonObject parsedObject = JsonObject.parse(jsonReader);
    assertTrue("dummyOne", compareJsonToEvent(parsedObject, dummyOne));

    JsonObject dataObject = parsedObject.get("data").asObject();
    assertNotNull(dataObject);

    JsonArray childArray = parsedObject.get("children").asArray();
    assertNotNull(childArray);
    assertEquals(2, childArray.getLength());

    JsonObject child = childArray.get(0).asObject();
    assertTrue("dummyTwo", compareJsonToEvent(child, dummyTwo));

    child = childArray.get(1).asObject();
    assertTrue("dummyThree", compareJsonToEvent(child, dummyThree));
  }
View Full Code Here

    logger.addDataImpl("extraMiddle", "valueMiddle");
    logger.endImpl(dummyOneEvent, "extraEnd", "valueEnd");
    logger.flush();

    Reader jsonReader = extractJsonFromWriter(writer);
    JsonObject parsedObject = JsonObject.parse(jsonReader);
    assertEquals("valueStart", parsedObject.get("data").asObject().get(
        "extraStart").asString().getString());
    assertEquals(
        "valueMiddle",
        parsedObject.get("data").asObject().get("extraMiddle").asString().getString());
    assertEquals(
        "valueEnd",
        parsedObject.get("data").asObject().get("extraEnd").asString().getString());
  }
View Full Code Here

    Event dummyThreeEvent = logger.startImpl(null, dummyThree);
    logger.endImpl(dummyThreeEvent);
    logger.flush();

    Reader jsonReader = extractJsonFromWriter(writer);
    JsonObject dummyOneObject = JsonObject.parse(jsonReader).asObject();
    JsonObject dummyTwoObject = JsonObject.parse(jsonReader).asObject();
    JsonObject dummyThreeObject = JsonObject.parse(jsonReader).asObject();

    assertTrue(compareJsonToEvent(dummyOneObject, dummyOne));
    assertTrue(compareJsonToEvent(dummyTwoObject, dummyTwo));
    assertTrue(compareJsonToEvent(dummyThreeObject, dummyThree));
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.json.JsonObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.