1 4 package org.roller.presentation.bookmarks.actions; 5 6 import org.apache.struts.action.Action; 7 import org.apache.struts.action.ActionForm; 8 import org.apache.struts.action.ActionForward; 9 import org.apache.struts.action.ActionMapping; 10 import org.roller.model.BookmarkManager; 11 import org.roller.pojos.BookmarkData; 12 import org.roller.pojos.FolderData; 13 import org.roller.pojos.WebsiteData; 14 import org.roller.presentation.RollerRequest; 15 import org.roller.presentation.bookmarks.formbeans.BookmarkFormEx; 16 import org.roller.presentation.forms.BookmarkForm; 17 18 import java.util.LinkedList ; 19 20 import javax.servlet.http.HttpServletRequest ; 21 import javax.servlet.http.HttpServletResponse ; 22 23 29 public class BookmarkEditAction extends Action 30 { 31 public ActionForward execute( 32 ActionMapping mapping, 33 ActionForm actionForm, 34 HttpServletRequest request, 35 HttpServletResponse response) 36 throws Exception 37 { 38 RollerRequest rreq = RollerRequest.getRollerRequest(request); 39 WebsiteData wd = rreq.getWebsite(); 40 BookmarkManager bmgr = rreq.getRoller().getBookmarkManager(); 41 BookmarkFormEx form = (BookmarkFormEx)actionForm; 42 43 FolderData parentFolder = null; 44 if (null!=rreq.getBookmark() && null==request.getParameter("correct")) 45 { 46 BookmarkData bd = rreq.getBookmark(); 49 form.copyFrom(bd, request.getLocale()); 50 request.setAttribute("state","edit"); 51 52 parentFolder = bd.getFolder(); 54 } 55 else if (null != request.getParameter("correct")) 56 { 57 request.setAttribute("state","correcting"); 59 60 parentFolder = bmgr.retrieveFolder(rreq.getFolder().getId()); 62 } 63 else 64 { 65 request.setAttribute("state","add"); 67 68 parentFolder = bmgr.retrieveFolder(rreq.getFolder().getId()); 70 } 71 72 if (null != parentFolder) 74 { 75 request.setAttribute( 76 RollerRequest.FOLDERID_KEY, parentFolder.getId()); 77 78 LinkedList folderPath = new LinkedList (); 79 folderPath.add(0, parentFolder); 80 FolderData parent = parentFolder.getParent(); 81 while (parent != null) 82 { 83 folderPath.add(0, parent); 84 parent = parent.getParent(); 85 } 86 request.setAttribute("parentFolder", parentFolder); 87 request.setAttribute("folderPath", folderPath); 88 } 89 90 return mapping.findForward("BookmarkForm"); 91 } 92 93 } 94 | Popular Tags |