@RequestMapping(value = "/{siteId}/{pageId}/resendemailReminder.htm", method = RequestMethod.POST)
  protected ModelAndView resendEmailReminderForAttachment(
      @PathVariable String siteId,
      @PathVariable String pageId,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ModelAndView modelAndView = null;
    try {
      AuthRequest ar =
          getLoggedInAuthRequest(request, response, "message.can.not.resend.email.reminder");
      NGPage ngp = registerRequiredProject(ar, siteId, pageId);

      String reminderId = ar.reqParam("rid");
      String emailto = ar.defParam("emailto", null);
      ReminderRecord.reminderEmail(ar, pageId, reminderId, emailto, ngp);

      modelAndView = createRedirectView(ar, "reminders.htm");
    } catch (Exception ex) {
      throw new NGException(
          "nugen.operation.fail.project.resend.email.reminder", new Object[] {pageId, siteId}, ex);
    }
    return modelAndView;
  }
  @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;
  }
  @RequestMapping(value = "/{siteId}/{pageId}/emailReminder.form", method = RequestMethod.POST)
  protected ModelAndView submitEmailReminderForAttachment(
      @PathVariable String siteId,
      @PathVariable String pageId,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ModelAndView modelAndView = null;
    try {
      AuthRequest ar = getLoggedInAuthRequest(request, response, "message.can.not.send.email");
      NGPage ngp = registerRequiredProject(ar, siteId, pageId);
      ar.assertNotFrozen(ngp);

      String comment = ar.reqParam("comment");
      String pname = ar.defParam("pname", "");
      String assignee = ar.reqParam("assignee");
      String instruct = ar.reqParam("instruct");
      String subj = ar.reqParam("subj");
      String visibility = ar.reqParam("visibility");

      ReminderMgr rMgr = ngp.getReminderMgr();
      ReminderRecord rRec = rMgr.createReminder(ngp.getUniqueOnPage());
      rRec.setFileDesc(comment);
      rRec.setInstructions(instruct);
      rRec.setAssignee(assignee);
      rRec.setFileName(pname);
      rRec.setSubject(subj);
      rRec.setModifiedBy(ar.getBestUserId());
      rRec.setModifiedDate(ar.nowTime);
      rRec.setDestFolder(visibility);
      rRec.setSendNotification("yes");
      HistoryRecord.createHistoryRecord(
          ngp,
          rRec.getId(),
          HistoryRecord.CONTEXT_TYPE_DOCUMENT,
          ar.nowTime,
          HistoryRecord.EVENT_DOC_ADDED,
          ar,
          "Added Reminder for " + assignee);

      ngp.saveFile(ar, "Modified attachments");
      modelAndView = createRedirectView(ar, "reminders.htm");
    } catch (Exception ex) {
      throw new NGException(
          "nugen.operation.fail.project.email.reminder", new Object[] {pageId, siteId}, ex);
    }
    return modelAndView;
  }