1 4 package org.roller.presentation.bookmarks.actions; 5 6 import javax.servlet.http.HttpServletRequest ; 7 import javax.servlet.http.HttpServletResponse ; 8 9 import org.apache.struts.action.Action; 10 import org.apache.struts.action.ActionError; 11 import org.apache.struts.action.ActionErrors; 12 import org.apache.struts.action.ActionForm; 13 import org.apache.struts.action.ActionForward; 14 import org.apache.struts.action.ActionMapping; 15 import org.roller.RollerPermissionsException; 16 import org.roller.model.BookmarkManager; 17 import org.roller.pojos.BookmarkData; 18 import org.roller.pojos.FolderData; 19 import org.roller.presentation.RollerRequest; 20 import org.roller.presentation.bookmarks.formbeans.BookmarkFormEx; 21 22 29 public class BookmarkSaveAction extends Action 30 { 31 public ActionForward execute( 32 ActionMapping mapping, 33 ActionForm actionForm, 34 HttpServletRequest request, 35 HttpServletResponse response) 36 throws Exception 37 { 38 ActionForward forward = mapping.findForward("Bookmarks"); 39 try 40 { 41 BookmarkFormEx form = (BookmarkFormEx)actionForm; 42 RollerRequest rreq = RollerRequest.getRollerRequest(request); 43 BookmarkManager bmgr = rreq.getRoller().getBookmarkManager(); 44 45 BookmarkData bd = null; 46 if (null != form.getId() && !form.getId().trim().equals("")) 47 { 48 bd = bmgr.retrieveBookmark(form.getId()); 49 bd.save(); } 51 else 52 { 53 bd = bmgr.createBookmark(); 54 55 FolderData fd = bmgr.retrieveFolder( 57 request.getParameter(RollerRequest.FOLDERID_KEY)); 58 bd.setFolder(fd); 59 } 60 form.copyTo(bd, request.getLocale()); 61 bd.save(); 62 rreq.getRoller().commit(); 63 64 request.setAttribute( 65 RollerRequest.FOLDERID_KEY,bd.getFolder().getId()); 66 } 67 catch (RollerPermissionsException e) 68 { 69 ActionErrors errors = new ActionErrors(); 70 errors.add(null, new ActionError("error.permissions.deniedSave")); 71 saveErrors(request, errors); 72 forward = mapping.findForward("access-denied"); 73 } 74 return forward; 75 76 } 77 78 } 79 | Popular Tags |