Esempio n. 1
0
  private void errors(HttpServletResponse response) {

    try {

      // gets the errors
      JSONArray array = new JSONArray();

      for (Log log : LogsDB.getErrors(Globals.DASHBOARD_MAX_ERRORS)) {

        JSONObject obj = new JSONObject();
        obj.put("added", log.getAdded().toString());
        obj.put("id", log.getId());
        obj.put("publicDNS", log.getPublicDNS());
        obj.put("pid", log.getPid());
        obj.put("logType", log.getLogType());
        obj.put("methodPath", log.getMethodPath());
        obj.put("lineNumber", log.getLineNumber());

        array.add(obj);
      }

      // response
      response.setContentType("application/json");
      response.setStatus(HttpServletResponse.SC_OK);
      response.getWriter().println(array);

    } catch (Exception e) {
      new TalesException(new Throwable(), e);
    }
  }
Esempio n. 2
0
  private void getLog(HttpServletRequest request, HttpServletResponse response) {

    try {

      int id = Integer.parseInt(request.getParameter("id"));
      Log log = LogsDB.getLog(id);

      JSONObject obj = new JSONObject();
      obj.put("id", log.getId());
      obj.put("publicDNS", log.getPublicDNS());
      obj.put("pid", log.getPid());
      obj.put("logType", log.getLogType());
      obj.put("methodPath", log.getMethodPath());
      obj.put("lineNumber", log.getLineNumber());
      obj.put("added", log.getAdded());
      obj.put("data", log.getData());

      response.setContentType("application/json");
      response.setStatus(HttpServletResponse.SC_OK);
      response.getWriter().println(obj);

    } catch (Exception e) {
      new TalesException(new Throwable(), e);
    }
  }
Esempio n. 3
0
  private void delete() {

    try {

      // makes sure that we dont delete a server with dbs -- we ignore tales logs
      if (DBUtils.getLocalTalesDBNames().size() == 0
          || (DBUtils.getLocalTalesDBNames().size() == 1
              && DBUtils.getLocalTalesDBNames().get(0).contains(LogsDB.getDBName()))) {

        forceDelete();

      } else {
        Logger.log(
            new Throwable(),
            "DELETE: cant delete server, it contains tales databases. Delete all the tales databases before trying to delete the server.");
      }

    } catch (Exception e) {
      new TalesException(new Throwable(), e);
    }
  }