示例#1
0
  @Override
  protected void onRequest(RequestWrapper<WebSession> req) throws IOException {
    tokenLogin(req);

    User user = req.getSession().getUser();
    if (user == null) {
      redirectToLogin(req);
      return;
    }

    if (!user.isAdmin()) {
      req.sendErrorForbidden();
      return;
    }

    // TODO show message
    webApplication
        .getTaskManager()
        .start(webApplication.autowire(new BackupApplicationDataDirTask()));

    HtmlBuilder html = createDefaultHtmlWithHeader(req, "Backup running", 3, "admin.html");
    html.startBODY();
    html.H1("Backup initiated");
    html.startP();
    html.text("All clients are blocked until backup is completed.");
    html.endP();
    html.endBODY();
    html.endHTML();
    html.flush();
  }