1 package org.nextime.ion.backoffice.action.content; 2 3 4 import java.io.IOException ; 5 6 import javax.servlet.ServletException ; 7 import javax.servlet.http.HttpServletRequest ; 8 import javax.servlet.http.HttpServletResponse ; 9 import org.apache.struts.action.ActionForm; 10 import org.apache.struts.action.ActionForward; 11 import org.apache.struts.action.ActionMapping; 12 import org.nextime.ion.backoffice.action.BaseAction; 13 import org.nextime.ion.backoffice.tree.TreeControl; 14 import org.nextime.ion.backoffice.tree.TreeControlNode; 15 import org.nextime.ion.backoffice.tree.WcmTreeBuilder; 16 import org.nextime.ion.backoffice.exception.BackofficeSecurityException; 17 import org.nextime.ion.backoffice.security.SecurityManagerImpl; 18 19 import org.nextime.ion.framework.business.Section; 20 import org.nextime.ion.framework.business.User; 21 import org.nextime.ion.framework.helper.IdGenerator; 22 import org.nextime.ion.framework.mapping.Mapping; 23 24 25 26 public class CreateSectionAction extends BaseAction { 27 28 public ActionForward perform(ActionMapping mapping, 29 ActionForm form, 30 HttpServletRequest request, 31 HttpServletResponse response) 32 throws IOException , ServletException { 33 34 checkUser(request); 36 37 try { 39 Mapping.begin(); 40 if (!new SecurityManagerImpl().canCreateSection(Section.getInstance(request.getParameter("id").toString()), User.getInstance(request.getSession().getAttribute("userLogin")+""))) { 41 throw new Exception (); 42 } 43 } catch (Exception e) { 44 throw new BackofficeSecurityException(); 45 } finally { 46 Mapping.rollback(); 47 } 48 49 TreeControl tree = (TreeControl)request.getSession().getAttribute("treeControlTest"); 51 String selectedId = request.getParameter("id") ; 52 TreeControlNode node = tree.findNode(selectedId); 53 54 try { 55 Mapping.begin(); 56 57 Section section = Section.getInstance(selectedId); 58 String newId = IdGenerator.nextSectionId(); 59 Section newSection = Section.create(section,newId); 60 newSection.setMetaData("status","offline"); 61 request.setAttribute("id",newId); 62 TreeControlNode newNode = WcmTreeBuilder.buildNode(newSection); 64 node.addChild(newNode); 65 newNode.rebuildLast(); 66 67 Mapping.commit(); 68 } catch(Exception e) { 69 Mapping.rollback(); 70 throw new ServletException (e); 71 } 72 73 return (mapping.findForward("ok")); 75 76 } 77 78 } 79 | Popular Tags |