1 61 62 package org.nextime.ion.backoffice.action.content; 63 64 import java.io.IOException ; 65 import java.util.ArrayList ; 66 import java.util.StringTokenizer ; 67 68 import javax.servlet.ServletException ; 69 import javax.servlet.http.HttpServletRequest ; 70 import javax.servlet.http.HttpServletResponse ; 71 import javax.servlet.http.HttpSession ; 72 73 import org.apache.struts.action.ActionForm; 74 import org.apache.struts.action.ActionForward; 75 import org.apache.struts.action.ActionMapping; 76 import org.apache.struts.action.ActionServlet; 77 import org.nextime.ion.backoffice.action.BaseAction; 78 import org.nextime.ion.backoffice.tree.TreeBuilder; 79 import org.nextime.ion.backoffice.tree.TreeControl; 80 import org.nextime.ion.backoffice.tree.TreeControlNode; 81 82 90 91 public class SetUpTreeAction extends BaseAction { 92 93 public static final int INIT_PLUGIN_MAX = 10; 94 public static final String TREEBUILDER_KEY = "treebuilders"; 95 public static final String ROOTNODENAME_KEY = "rootnodename"; 96 97 99 114 public ActionForward perform( 115 ActionMapping mapping, 116 ActionForm form, 117 HttpServletRequest request, 118 HttpServletResponse response) 119 throws IOException , ServletException { 120 121 checkUser(request); 123 124 HttpSession session = request.getSession(); 125 126 if( request.getParameter("clean")!=null ) { 128 session.removeAttribute("treeControlTest"); 129 } 130 131 if (session.getAttribute("treeControlTest") == null) { 132 133 ActionServlet servlet = getServlet(); 134 135 137 String rootnodeName = servlet.getInitParameter("rootNodeName"); 139 140 String treeBuildersStr = 141 "org.nextime.ion.backoffice.tree.WcmTreeBuilder"; 142 143 145 148 TreeControlNode root = 149 new TreeControlNode( 150 "ROOT-NODE", 151 "root.gif", 152 rootnodeName, 153 "setUpTree.x?select=ROOT-NODE", 154 "content", 155 true); 156 157 TreeControl control = new TreeControl(root); 158 159 if (treeBuildersStr != null) { 160 Class treeBuilderImpl; 161 TreeBuilder treeBuilderBase; 162 163 ArrayList treeBuilders = new ArrayList (INIT_PLUGIN_MAX); 164 int i = 0; 165 StringTokenizer st = new StringTokenizer (treeBuildersStr, ","); 166 while (st.hasMoreTokens()) { 167 treeBuilders.add(st.nextToken().trim()); 168 } 169 170 if (treeBuilders.size() == 0) 171 treeBuilders.add(treeBuildersStr.trim()); 172 173 for (i = 0; i < treeBuilders.size(); i++) { 174 175 try { 176 treeBuilderImpl = 177 Class.forName((String ) treeBuilders.get(i)); 178 treeBuilderBase = 179 (TreeBuilder) treeBuilderImpl.newInstance(); 180 treeBuilderBase.buildTree(control, servlet, request); 181 } catch (Throwable t) { 182 t.printStackTrace(System.out); 183 } 184 } 185 } 186 187 session = request.getSession(); 188 session.setAttribute("treeControlTest", control); 189 190 String name = request.getParameter("select"); 191 if (name != null) { 192 control.selectNode(name); 193 } 194 195 } 196 197 return (mapping.findForward("view")); 198 199 } 200 } 201 | Popular Tags |