1 18 21 package org.apache.roller.ui.authoring.struts.actions; 22 23 import java.util.LinkedList ; 24 25 import javax.servlet.http.HttpServletRequest ; 26 import javax.servlet.http.HttpServletResponse ; 27 28 import org.apache.struts.action.Action; 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.ui.core.BasePageModel; 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 42 48 public class BookmarkEditAction extends Action 49 { 50 public ActionForward execute( 51 ActionMapping mapping, 52 ActionForm actionForm, 53 HttpServletRequest request, 54 HttpServletResponse response) 55 throws Exception 56 { 57 RollerRequest rreq = RollerRequest.getRollerRequest(request); 58 RollerSession rses = RollerSession.getRollerSession(request); 59 BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager(); 60 BookmarkFormEx form = (BookmarkFormEx)actionForm; 61 62 FolderData parentFolder = null; 63 if (null!=rreq.getBookmark() && null==request.getParameter("correct")) 64 { 65 BookmarkData bd = rreq.getBookmark(); 68 form.copyFrom(bd, request.getLocale()); 69 request.setAttribute("state","edit"); 70 71 parentFolder = bd.getFolder(); 73 74 request.setAttribute("model", new BasePageModel( 75 "bookmarkForm.edit.title", request, response, mapping)); 76 } 77 else if (null != request.getParameter("correct")) 78 { 79 request.setAttribute("state","correcting"); 81 82 parentFolder = bmgr.getFolder(rreq.getFolder().getId()); 84 85 request.setAttribute("model", new BasePageModel( 86 "bookmarkForm.correct.title", request, response, mapping)); 87 } 88 else 89 { 90 request.setAttribute("state","add"); 92 93 parentFolder = bmgr.getFolder(rreq.getFolder().getId()); 95 96 request.setAttribute("model", new BasePageModel( 97 "bookmarkForm.add.title", request, response, mapping)); 98 } 99 100 if (null != parentFolder) 102 { 103 request.setAttribute( 104 RequestConstants.FOLDER_ID, parentFolder.getId()); 105 106 LinkedList folderPath = new LinkedList (); 107 folderPath.add(0, parentFolder); 108 FolderData parent = parentFolder.getParent(); 109 while (parent != null) 110 { 111 folderPath.add(0, parent); 112 parent = parent.getParent(); 113 } 114 request.setAttribute("parentFolder", parentFolder); 115 request.setAttribute("folderPath", folderPath); 116 } 117 return mapping.findForward("BookmarkForm"); 118 } 119 120 } 121 | Popular Tags |