コード例 #1
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);
  }