Ejemplo n.º 1
0
  private void databases(HttpServletResponse response) {

    try {

      JSONArray json = new JSONArray();

      for (String dbName : DBUtils.getLocalDBNames()) {

        JSONArray tables = new JSONArray();
        for (String tableName : DBUtils.getTableNames(new TemplateLocalhostConnection(), dbName)) {

          JSONObject table = new JSONObject();
          table.put("table", tableName);
          table.put(
              "size", DBUtils.getTableCount(new TemplateLocalhostConnection(), dbName, tableName));
          tables.add(table);
        }

        JSONObject database = new JSONObject();
        database.put("name", dbName);
        database.put("tables", tables);
        json.add(database);
      }

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

    } catch (Exception e) {
      new TalesException(new Throwable(), e);
    }
  }
Ejemplo n.º 2
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);
    }
  }