@RequestMapping(value = "/setEditMode.ajax", method = RequestMethod.POST) protected void setEditAttachmentMode(HttpServletRequest request, HttpServletResponse response) throws Exception { String responseText = null; AuthRequest ar = null; try { ar = getLoggedInAuthRequest(request, response, "message.must.be.login"); String aid = ar.reqParam("aid"); String pageId = ar.reqParam("pageId"); String isEditMode = ar.reqParam("editing"); NGContainer ngp = NGPageIndex.getContainerByKeyOrFail(pageId); AttachmentRecord attachment = ngp.findAttachmentByIDOrFail(aid); // attachment.clearDeleted(); if (attachment != null) { if (isEditMode.equals("true")) { attachment.setEditMode(ar); } else { attachment.clearEditMode(); } responseText = NGWebUtils.getJSONMessage(Constant.SUCCESS, "", ""); } else { throw new NGException( "nugen.exception.no.attachment.found", new Object[] {aid, ngp.getFullName()}); } ngp.saveContent(ar, "Modified attachments"); } catch (Exception ex) { responseText = NGWebUtils.getExceptionMessageForAjaxRequest(ex, ar.getLocale()); ar.logException("Caught by setEditMode.ajax", ex); } NGWebUtils.sendResponse(ar, responseText); }
@RequestMapping(value = "/getDocumentDetail.ajax", method = RequestMethod.POST) public void createLeaflet(HttpServletRequest request, HttpServletResponse response) throws Exception { String responseText = null; AuthRequest ar = null; try { ar = getLoggedInAuthRequest(request, response, "message.must.be.login"); String aid = ar.reqParam("aid"); String pageId = ar.reqParam("pageId"); NGContainer ngp = NGPageIndex.getContainerByKeyOrFail(pageId); AttachmentRecord attachment = ngp.findAttachmentByIDOrFail(aid); JSONObject paramMap = new JSONObject(); paramMap.put(Constant.MSG_TYPE, Constant.SUCCESS); paramMap.put("aid", aid); paramMap.put("description", attachment.getComment()); paramMap.put("permission", String.valueOf(attachment.getVisibility())); paramMap.put("accessName", attachment.getDisplayName()); responseText = paramMap.toString(); } catch (Exception ex) { responseText = NGWebUtils.getExceptionMessageForAjaxRequest(ex, ar.getLocale()); ar.logException("Caught by getDocumentDetail.ajax", ex); } NGWebUtils.sendResponse(ar, responseText); }
@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); }
@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); }