Ejemplo n.º 1
0
  @RequestMapping(value = "/deleteReminder.ajax", method = RequestMethod.POST)
  protected void deleteReminder(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    String message = "";
    AuthRequest ar = null;
    try {
      ar = getLoggedInAuthRequest(request, response, "message.must.be.login");
      String containerId = ar.reqParam("containerId");
      NGContainer ngc = NGPageIndex.getContainerByKeyOrFail(containerId);
      ar.setPageAccessLevels(ngc);
      String rid = ar.reqParam("rid");

      ReminderMgr rMgr = ngc.getReminderMgr();

      ReminderRecord rRec = rMgr.findReminderByID(rid);

      if (rRec != null) {
        rMgr.removeReminder(rid);
        message = NGWebUtils.getJSONMessage(Constant.SUCCESS, "", "");
      } else {
        throw new NGException(
            "nugen.exception.no.attachment.found", new Object[] {rid, ngc.getFullName()});
      }
      ngc.saveContent(ar, "Modified attachments");
    } catch (Exception ex) {
      message = NGWebUtils.getExceptionMessageForAjaxRequest(ex, ar.getLocale());
      ar.logException("Caught by deleteReminder.ajax", ex);
    }
    NGWebUtils.sendResponse(ar, message);
  }
Ejemplo n.º 2
0
  @RequestMapping(value = "/unDeleteAttachment.ajax", method = RequestMethod.POST)
  protected void unDeleteAttachment(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    String message = "";
    AuthRequest ar = null;
    try {
      ar = getLoggedInAuthRequest(request, response, "message.must.be.login");
      String containerId = ar.reqParam("containerId");
      NGContainer ngc = NGPageIndex.getContainerByKeyOrFail(containerId);
      ar.setPageAccessLevels(ngc);
      String aid = ar.reqParam("aid");
      AttachmentRecord attachment = ngc.findAttachmentByID(aid);
      if (attachment == null) {
        throw new NGException(
            "nugen.exception.no.attachment.found", new Object[] {aid, ngc.getFullName()});
      }
      attachment.clearDeleted();
      message = NGWebUtils.getJSONMessage(Constant.SUCCESS, "", "");
      ngc.saveContent(ar, "Modified attachments");
    } catch (Exception ex) {
      message = NGWebUtils.getExceptionMessageForAjaxRequest(ex, ar.getLocale());
      ar.logException("Caught by getFileAccessName.ajax", ex);
    }
    NGWebUtils.sendResponse(ar, message);
  }
Ejemplo n.º 3
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);
    }
  }