예제 #1
0
    @Override
    public void handle(HttpExchange t) throws IOException {
      LOGGER.debug("root req " + t.getRequestURI());
      if (RemoteUtil.deny(t)) {
        throw new IOException("Access denied");
      }
      if (t.getRequestURI().getPath().contains("favicon")) {
        RemoteUtil.sendLogo(t);
        return;
      }

      HashMap<String, Object> vars = new HashMap<>();
      vars.put("logs", getLogs(true));
      if (configuration.getUseCache()) {
        vars.put(
            "cache",
            "http://"
                + PMS.get().getServer().getHost()
                + ":"
                + PMS.get().getServer().getPort()
                + "/console/home");
      }

      String response = parent.getResources().getTemplate("doc.html").execute(vars);
      RemoteUtil.respond(t, response, 200, "text/html");
    }
예제 #2
0
    @Override
    public void handle(HttpExchange t) throws IOException {
      LOGGER.debug("root req " + t.getRequestURI());
      if (RemoteUtil.deny(t)) {
        throw new IOException("Access denied");
      }
      if (t.getRequestURI().getPath().contains("favicon")) {
        RemoteUtil.sendLogo(t);
        return;
      }

      HashMap<String, Object> vars = new HashMap<>();
      vars.put("serverName", configuration.getServerName());
      vars.put("profileName", configuration.getProfileName());

      String response = parent.getResources().getTemplate("start.html").execute(vars);
      RemoteUtil.respond(t, response, 200, "text/html");
    }
예제 #3
0
  public void handle(HttpExchange t) throws IOException {
    // System.out.println(t.getRequestURI().toString());
    /*
     * InputStream is = t.getRequestBody(); byte[] temp = new
     * byte[is.available()]; is.read(temp); String title=new String(temp);
     */
    String title_str = t.getRequestURI().toString();
    // System.out.println("title_str:" + title_str);
    /*
     * Pattern tit_pat=Pattern.compile("\\/cate_db\\/do\\?t\\=(.*?)\\=");
     * Matcher tit_mat=tit_pat.matcher(title_str); String tt="";
     * while(tit_mat.find()) { tt=tit_mat.group(1);
     * System.out.println("title:"+tt); }
     */
    title_str = title_str.replaceFirst("/cate_tb/do\\?t=", "");
    // System.out.println("title_str:" + title_str);
    String de_title = new String(Base64.decode(title_str));
    System.out.println("de_title:" + de_title);
    String res = "";
    try {
      res = my_ewa.predict_from_seg_line(de_title);
    } catch (Exception e) {
    }
    ;
    System.out.println("res is :" + res);
    // res=res.replace("\001", "$");
    String encode_res = Base64.encodeBytes(res.getBytes());
    encode_res = encode_res.replaceAll("\\s+", "");
    System.out.println("encode_res:" + encode_res);

    String response = encode_res;
    t.sendResponseHeaders(200, response.length());
    OutputStream os = t.getResponseBody();
    os.write(response.getBytes());
    os.close();
  }
예제 #4
0
    @Override
    public void handle(HttpExchange t) throws IOException {
      LOGGER.debug("file req " + t.getRequestURI());

      String path = t.getRequestURI().getPath();
      String response = null;
      String mime = null;
      int status = 200;

      if (path.contains("crossdomain.xml")) {
        response =
            "<?xml version=\"1.0\"?>"
                + "<!-- http://www.bitsontherun.com/crossdomain.xml -->"
                + "<cross-domain-policy>"
                + "<allow-access-from domain=\"*\" />"
                + "</cross-domain-policy>";
        mime = "text/xml";

      } else if (path.startsWith("/files/log/")) {
        String filename = path.substring(11);
        if (filename.equals("info")) {
          String log = PMS.get().getFrame().getLog();
          log = log.replaceAll("\n", "<br>");
          String fullLink = "<br><a href=\"/files/log/full\">Full log</a><br><br>";
          String x = fullLink + log;
          if (StringUtils.isNotEmpty(log)) {
            x = x + fullLink;
          }
          response = "<html><title>UMS LOG</title><body>" + x + "</body></html>";
        } else {
          File file = parent.getResources().getFile(filename);
          if (file != null) {
            filename = file.getName();
            HashMap<String, Object> vars = new HashMap<>();
            vars.put("title", filename);
            vars.put(
                "brush",
                filename.endsWith("debug.log")
                    ? "debug_log"
                    : filename.endsWith(".log") ? "log" : "conf");
            vars.put("log", RemoteUtil.read(file).replace("<", "&lt;"));
            response = parent.getResources().getTemplate("util/log.html").execute(vars);
          } else {
            status = 404;
          }
        }
        mime = "text/html";

      } else if (parent.getResources().write(path.substring(7), t)) {
        // The resource manager found and sent the file, all done.
        return;

      } else {
        status = 404;
      }

      if (status == 404 && response == null) {
        response = "<html><body>404 - File Not Found: " + path + "</body></html>";
        mime = "text/html";
      }

      RemoteUtil.respond(t, response, status, mime);
    }