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