@RequestMapping(value = "/{siteId}/{pageId}/remindAttachment.htm", method = RequestMethod.GET)
  protected ModelAndView remindAttachment(
      @PathVariable String siteId,
      @PathVariable String pageId,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    AuthRequest ar = AuthRequest.getOrCreate(request, response);
    try {
      NGPage ngp = registerRequiredProject(ar, siteId, pageId);
      ar.setPageAccessLevels(ngp);

      String rid = ar.reqParam("rid");
      ReminderMgr mgr = ngp.getReminderMgr();
      ReminderRecord reminderRecord = mgr.findReminderByIDOrFail(rid);
      if (AccessControl.canAccessReminder(ar, ngp, reminderRecord)) {
        request.setAttribute("subTabId", "nugen.projecthome.subtab.upload.document");
        return createNamedView(siteId, pageId, ar, "remind_attachment", "Project Documents");
      }

      if (!ar.isLoggedIn()) {
        request.setAttribute("property_msg_key", "nugen.project.remind.doc.login.msg");
      } else if (!ar.isMember()) {
        request.setAttribute("property_msg_key", "nugen.attachment.remind.doc.memberlogin");
      } else {
        // basically, the reminder should have been display, and we have no idea now why not
        throw new Exception(
            "Program Logic Error ... something is wrong with the canAccessReminder method");
      }
      return createNamedView(siteId, pageId, ar, "Warning", "Project Documents");

    } catch (Exception ex) {
      Exception extd =
          new NGException(
              "nugen.operation.fail.project.reminder.attachment.page",
              new Object[] {pageId, siteId},
              ex);
      return displayException(request, extd);
    }
  }
  @RequestMapping(value = "/{siteId}/{pageId}/upload.form", method = RequestMethod.POST)
  protected ModelAndView uploadFile(
      @PathVariable String siteId,
      @PathVariable String pageId,
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam("fname") MultipartFile file)
      throws Exception {

    ModelAndView modelAndView = null;
    try {
      AuthRequest ar = AuthRequest.getOrCreate(request, response);
      NGPage ngp = registerRequiredProject(ar, siteId, pageId);
      // Handling special case for Multipart request
      ar.req = request;

      ReminderRecord reminderRecord = null;

      boolean requestFromReminder = false;
      String rid = ar.defParam("rid", null);
      String go = ar.defParam("go", null);

      boolean canAccessToReminder = false;
      if (rid != null) {
        // rid is not null its mean request to upload a document has come from 'Reminders To Share
        // Document'
        requestFromReminder = true;
        ReminderMgr mgr = ngp.getReminderMgr();
        reminderRecord = mgr.findReminderByIDOrFail(rid);
        canAccessToReminder = AccessControl.canAccessReminder(ar, ngp, reminderRecord);
      }
      if (!requestFromReminder || !canAccessToReminder) {
        ar.assertLoggedIn(ar.getMessageFromPropertyFile("message.can.not.upload.attachment", null));
      }

      ar.assertNotFrozen(ngp);
      request.setCharacterEncoding("UTF-8");

      if (file.getSize() == 0) {
        throw new NGException("nugen.exceptionhandling.no.file.attached", null);
      }

      if (file.getSize() > 500000000) {
        throw new NGException(
            "nugen.exceptionhandling.file.size.exceeded", new Object[] {"500000000"});
      }

      String fileName = file.getOriginalFilename();

      if (fileName == null || fileName.length() == 0) {
        throw new NGException("nugen.exceptionhandling.filename.empty", null);
      }

      String visibility = ar.defParam("visibility", "*MEM*");
      String comment = ar.defParam("comment", "");
      String name = ar.defParam("name", null);

      AttachmentHelper.uploadNewDocument(ar, ngp, file, name, visibility, comment, "");

      if (reminderRecord != null) {
        reminderRecord.setClosed();
        ngp.save();
      }
      if (go == null) {
        modelAndView = createRedirectView(ar, "attachment.htm");
      } else {
        response.sendRedirect(go);
      }
    } catch (Exception ex) {
      throw new NGException(
          "nugen.operation.fail.project.upload.document", new Object[] {pageId, siteId}, ex);
    }
    return modelAndView;
  }