Package com.google.gwt.dev.codeserver.Pages

Examples of com.google.gwt.dev.codeserver.Pages.ErrorPage


      throw new RuntimeException("invalid request (shouldn't happen): " + target);
    }

    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.");
    }

    String rootDir = SOURCEMAP_PATH + moduleName + "/";
    String rest = target.substring(rootDir.length());

    if (rest.isEmpty()) {
      return makeDirectoryListPage(box);
    } else if (rest.equals("gwtSourceMap.json")) {
      // This URL is no longer used by debuggers (we use the strong name) but is used for testing.
      // It's useful not to need the strong name to download the sourcemap.
      // (But this only works when there is one permutation.)
      return makeSourceMapPage(moduleName, box.findSourceMapForOnePermutation(), request);
    } else if (rest.endsWith("/")) {
      return sendFileListPage(box, rest);
    } else if (rest.endsWith(".java")) {
      return makeSourcePage(box, rest, request.getQueryString(), logger);
    } else {
      String strongName = getStrongNameFromSourcemapFilename(rest);
      if (strongName != null) {
        File sourceMap = box.findSourceMap(strongName).getAbsoluteFile();
        return makeSourceMapPage(moduleName, sourceMap, request);
      } else {
        return new ErrorPage("page not found");
      }
    }
  }
View Full Code Here


  private Response makeSourcePage(Outbox box, String sourcePath, String query, TreeLogger logger)
      throws IOException {

    InputStream pageBytes = box.openSourceFile(sourcePath);
    if (pageBytes == null) {
      return new ErrorPage("unknown source file: " + sourcePath);
    }

    if (query != null && query.equals("html")) {
      return makeHtmlSourcePage(box, sourcePath, pageBytes, logger);
    } else {
View Full Code Here

    // 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);
    }
View Full Code Here

    int secondSlash = target.indexOf('/', 1);
    String moduleName = target.substring(1, secondSlash);
    Outbox box = outboxes.findByOutputModuleName(moduleName);
    if (box == null) {
      return new ErrorPage("No such module: " + moduleName);
    }

    final String contentEncoding;
    File file = box.getOutputFile(target);
    if (!file.isFile()) {
      // perhaps it's compressed
      file = box.getOutputFile(target + ".gz");
      if (!file.isFile()) {
        return new ErrorPage("not found: " + file.toString());
      }
      contentEncoding = "gzip";
    } else {
      contentEncoding = null;
    }
View Full Code Here

  }

  private Response makeModulePage(String moduleName) {
    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

  private Response makePolicyFilePage(String target) throws IOException {

    int secondSlash = target.indexOf('/', 1);
    if (secondSlash < 1) {
      return new ErrorPage("invalid URL for policy file: " + target);
    }

    String rest = target.substring(secondSlash + 1);
    if (rest.contains("/") || !rest.endsWith(".gwt.rpc")) {
      return new ErrorPage("invalid name for policy file: " + rest);
    }

    File fileToSend = outboxes.findPolicyFile(rest);
    if (fileToSend == null) {
      return new ErrorPage("Policy file not found: " + rest);
    }

    return Responses.newFileResponse("text/plain", fileToSend);
  }
View Full Code Here

   */
  private Response makeLogPage(final Outbox box)
       throws IOException {
    final File file = box.getCompileLog();
    if (!file.isFile()) {
      return new ErrorPage("log file not found");
    }

    return new Response() {

      @Override
View Full Code Here

  /**
   * A HTTP response that sends a file.
   */
  static Response newFileResponse(final String mimeType, final File file) {
    if (!file.isFile()) {
      return new ErrorPage("file not found: " + file.toString());
    }

    return new Response() {
      @Override
      public void send(HttpServletRequest request, HttpServletResponse response, TreeLogger logger)
View Full Code Here

  static Response newJavascriptResponse(final String variableName, final JsonObject json,
      final String resourceName) {

    final URL resource = WebServer.class.getResource(resourceName);
    if (resource == null) {
      return new ErrorPage("resource not found: " + resourceName);
    }

    return new Response() {
      @Override
      public void send(HttpServletRequest request, HttpServletResponse response, TreeLogger logger)
View Full Code Here

   * @param replacement the replacement
   */
  static Response newTextTemplateResponse(final String mimeType, final File file,
      final String templateVariable, final String replacement) {
    if (!file.isFile()) {
      return new ErrorPage("file not found: " + file.toString());
    }

    return new Response() {
      @Override
      public void send(HttpServletRequest request, HttpServletResponse response, TreeLogger logger)
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.codeserver.Pages.ErrorPage

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.