1 18 21 package org.apache.roller.ui.authoring.struts.actions; 22 23 import javax.servlet.http.HttpServletRequest ; 24 import javax.servlet.http.HttpServletResponse ; 25 26 import org.apache.struts.action.Action; 27 import org.apache.struts.action.ActionError; 28 import org.apache.struts.action.ActionErrors; 29 import org.apache.struts.action.ActionForm; 30 import org.apache.struts.action.ActionForward; 31 import org.apache.struts.action.ActionMapping; 32 import org.apache.roller.model.BookmarkManager; 33 import org.apache.roller.model.RollerFactory; 34 import org.apache.roller.pojos.FolderData; 35 import org.apache.roller.pojos.PermissionsData; 36 import org.apache.roller.pojos.WebsiteData; 37 import org.apache.roller.ui.core.RollerRequest; 38 import org.apache.roller.ui.core.RollerSession; 39 import org.apache.roller.ui.authoring.struts.formbeans.FolderFormEx; 40 import org.apache.roller.ui.core.RequestConstants; 41 import org.apache.roller.util.cache.CacheManager; 42 43 50 public class FolderSaveAction extends Action 51 { 52 public ActionForward execute( 53 ActionMapping mapping, 54 ActionForm actionForm, 55 HttpServletRequest request, 56 HttpServletResponse response) 57 throws Exception 58 { 59 ActionForward forward = mapping.findForward("Bookmarks"); 60 FolderFormEx form = (FolderFormEx)actionForm; 61 RollerRequest rreq = RollerRequest.getRollerRequest(request); 62 RollerSession rses = RollerSession.getRollerSession(request); 63 BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager(); 64 WebsiteData website = null; 65 66 FolderData fd = null; 67 if (null != form.getId() && !form.getId().trim().equals("")) 68 { 69 fd = bmgr.getFolder(form.getId()); 70 website = fd.getWebsite(); 71 } 72 else 73 { 74 fd = new FolderData(); 75 String parentId = request.getParameter(RequestConstants.PARENT_ID); 76 FolderData parent = bmgr.getFolder(parentId); 77 website = parent.getWebsite(); 78 fd.setParent(parent); 79 fd.setWebsite(website); 80 } 81 82 if (fd.getWebsite().hasUserPermissions( 83 rses.getAuthenticatedUser(), PermissionsData.AUTHOR)) 84 { 85 form.copyTo(fd, request.getLocale()); 87 bmgr.saveFolder(fd); 88 RollerFactory.getRoller().flush(); 89 90 CacheManager.invalidate(fd); 91 } 92 else 93 { 94 ActionErrors errors = new ActionErrors(); 95 errors.add(null, new ActionError("error.permissions.deniedSave")); 96 saveErrors(request, errors); 97 forward = mapping.findForward("access-denied"); 98 } 99 if (null != fd.getParent()) 100 { 101 request.setAttribute( 102 RequestConstants.FOLDER_ID, fd.getParent().getId()); 103 } 104 return forward; 105 } 106 } 107 | Popular Tags |