@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); }