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.BookmarkData; 35 import org.apache.roller.pojos.FolderData; 36 import org.apache.roller.pojos.PermissionsData; 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.BookmarkFormEx; 40 import org.apache.roller.ui.core.RequestConstants; 41 import org.apache.roller.util.cache.CacheManager; 42 43 50 public class BookmarkSaveAction 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 BookmarkFormEx form = (BookmarkFormEx)actionForm; 61 RollerRequest rreq = RollerRequest.getRollerRequest(request); 62 BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager(); 63 64 BookmarkData bd = null; 65 if (null != form.getId() && !form.getId().trim().equals("")) 66 { 67 bd = bmgr.getBookmark(form.getId()); 68 } 69 else 70 { 71 bd = new BookmarkData(); 72 FolderData fd = bmgr.getFolder( 73 request.getParameter(RequestConstants.FOLDER_ID)); 74 bd.setFolder(fd); 75 } 76 RollerSession rses = RollerSession.getRollerSession(request); 77 if (bd.getFolder().getWebsite().hasUserPermissions( 78 rses.getAuthenticatedUser(), PermissionsData.AUTHOR)) 79 { 80 form.copyTo(bd, request.getLocale()); 81 bmgr.saveBookmark(bd); 82 RollerFactory.getRoller().flush(); 83 84 CacheManager.invalidate(bd); 85 86 request.setAttribute( 87 RequestConstants.FOLDER_ID, bd.getFolder().getId()); 88 } 89 else 90 { 91 ActionErrors errors = new ActionErrors(); 92 errors.add(null, new ActionError("error.permissions.deniedSave")); 93 saveErrors(request, errors); 94 forward = mapping.findForward("access-denied"); 95 } 96 return forward; 97 98 } 99 100 } 101 | Popular Tags |