Example #1
0
 String replaceStringLiterals(String content) {
   content =
       content.replaceAll(
           "%backup_initiated_by%",
           HtmlUtils.htmlEscape(backupService.backupRunningSinceISO8601()));
   content =
       content.replaceAll(
           "%backup_started_by%", HtmlUtils.htmlEscape(backupService.backupStartedBy()));
   return content;
 }
Example #2
0
  @Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws IOException, ServletException {
    if (backupService == null) {
      SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
    }

    String url = ((HttpServletRequest) request).getRequestURI();
    if (isBackupFinishJsonUrl(url)) {
      ((HttpServletResponse) response).setHeader("Cache-Control", "private, max-age=0, no-cache");
      ((HttpServletResponse) response).setDateHeader("Expires", 0);
      generateResponseForIsBackupFinishedAPI(response);
      return;
    }
    if (backupService.isBackingUp()) {
      ((HttpServletResponse) response).setHeader("Cache-Control", "private, max-age=0, no-cache");
      ((HttpServletResponse) response).setDateHeader("Expires", 0);
      if (isAPIUrl(url) && !isMessagesJson(url)) {
        generateAPIResponse(request, response);
      } else {
        generateHTMLResponse(response);
      }
    } else {
      chain.doFilter(request, response);
    }
  }
Example #3
0
 private void generateResponseForIsBackupFinishedAPI(ServletResponse response) {
   response.setContentType("application/json");
   JsonObject json = new JsonObject();
   json.addProperty("is_backing_up", backupService.isBackingUp());
   try {
     response.getWriter().print(json);
   } catch (IOException e) {
     LOGGER.error(String.format("General IOException: %s", e.getMessage()));
   }
 }