Beispiel #1
0
  public ActionForward execute(
      ActionMapping actionMapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // browser cache expire time;
    int expire = 2 * 60;
    if (request.getParameter("nocache") != null) { // for just modified and
      // view it
      expire = 0;
      return actionMapping.findForward(FormBeanUtil.FORWARD_SUCCESS_NAME);
    }

    String threadId = request.getParameter("thread");
    if ((threadId == null) || (!UtilValidate.isInteger(threadId))) {
      response.sendError(404);
      return null;
    }

    ForumMessageService forumMessageService =
        (ForumMessageService) WebAppUtil.getService("forumMessageService", request);
    ForumThread forumThread = forumMessageService.getThread(new Long(threadId));
    if (forumThread == null) {
      response.sendError(404);
      return null;
    }

    long modelLastModifiedDate = forumThread.getState().getModifiedDate2();

    if (!ToolsUtil.checkHeaderCache(expire, modelLastModifiedDate, request, response)) {
      return null; // response is 304
    }

    return actionMapping.findForward(FormBeanUtil.FORWARD_SUCCESS_NAME);
  }