@RequestMapping( value = "/{siteId}/{pageId}/remoteAttachmentAction.form", method = RequestMethod.POST) protected void remoteAttachmentAction( @PathVariable String siteId, @PathVariable String pageId, HttpServletRequest request, HttpServletResponse response) throws Exception { try { AuthRequest ar = getLoggedInAuthRequest(request, response, "message.can.not.create.attachment"); ar.req = request; NGPage ngp = registerRequiredProject(ar, siteId, pageId); ar.assertNotFrozen(ngp); ar.assertMember("Unable to create attachments."); String action = ar.reqParam("action"); String symbol = ar.reqParam("symbol"); String visibility = ar.defParam("visibility", "*MEM*"); String comment = ar.defParam("comment", ""); String attachmentDisplayName = ar.defParam("name", ""); String isNewUpload = ar.defParam("isNewUpload", "yes"); String readonly = ar.defParam("readOnly", "off"); UserPage uPage = ar.getUserPage(); ResourceEntity ent = uPage.getResourceFromSymbol(symbol); if ("Link Document".equalsIgnoreCase(action)) { FolderAccessHelper fah = new FolderAccessHelper(ar); if (isNewUpload.equals("yes")) { fah.attachDocument(ent, ngp, comment, attachmentDisplayName, visibility, readonly); } else { AttachmentHelper.updateRemoteAttachment( ar, ngp, comment, ent.getPath(), ent.getFolderId(), attachmentDisplayName, visibility); } } else { throw new ProgramLogicError("Don't understand the operation: " + action); } ngp.saveFile(ar, "Modified attachments"); response.sendRedirect(ar.baseURL + "t/" + siteId + "/" + pageId + "/attachment.htm"); } catch (Exception ex) { throw new NGException( "nugen.operation.fail.project.remote.attachment", new Object[] {pageId, siteId}, ex); } }
@RequestMapping(value = "/{siteId}/{pageId}/linkRepository.htm", method = RequestMethod.GET) protected ModelAndView linkRepository( @PathVariable String siteId, @PathVariable String pageId, HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView modelAndView = null; try { AuthRequest ar = AuthRequest.getOrCreate(request, response); NGPage ngp = registerRequiredProject(ar, siteId, pageId); if (!ar.isLoggedIn()) { return showWarningView(ar, "nugen.project.link.doc.to.project.login.msg"); } if (!ar.isMember()) { request.setAttribute("roleName", "Members"); return showWarningView(ar, "nugen.attachment.linkattachmenttoproject.memberlogin"); } if (ngp.isFrozen()) { return showWarningView(ar, "nugen.generatInfo.Frozen"); } String symbol = ar.reqParam("symbol"); ResourceEntity remoteFile = ar.getUserPage().getResourceFromSymbol(symbol); modelAndView = createNamedView(siteId, pageId, ar, "linkfromrepository_form", "Project Documents"); request.setAttribute("subTabId", "nugen.projecthome.subtab.link.from.repository"); request.setAttribute("isNewUpload", "yes"); request.setAttribute("symbol", remoteFile.getSymbol()); request.setAttribute("realRequestURL", ar.getRequestURL()); request.setAttribute("title", ngp.getFullName()); } catch (Exception ex) { throw new NGException( "nugen.operation.fail.project.link.to.repository.page", new Object[] {pageId, siteId}, ex); } return modelAndView; }