Ejemplo n.º 1
0
  @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;
  }
Ejemplo n.º 2
0
  @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);
    }
  }
Ejemplo n.º 3
0
  @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;
  }