public static void populateTreeNodeWith_ActionServlet(TreeNode treeNode, KStrutsMappings_ActionServlet strutsActionServet) { addNodeIfNonEmpty(treeNode, "url pattern", strutsActionServet.urlPattern); addNodeIfNonEmpty(treeNode, "load on startup", strutsActionServet.loadOnStartUp); addNodeIfNonEmpty(treeNode, "debug", strutsActionServet.debug); addNodeIfNonEmpty(treeNode, "validate", strutsActionServet.validate); addNodeIfNonEmpty(treeNode, "detail", strutsActionServet.detail); addNodeIfNonEmpty(treeNode, "rule sets", strutsActionServet.ruleSets); addNodeIfNonEmpty(treeNode, "application", strutsActionServet.application); var currentUrlPattern = (strutsActionServet.urlPattern[strutsActionServet.urlPattern.Length - 1] == '*') ? strutsActionServet.urlPattern.Substring(0, strutsActionServet.urlPattern.Length - 1) : strutsActionServet.urlPattern; foreach (var filter in strutsActionServet.filters) { if (filter.urlPattern == "/*" || filter.urlPattern.StartsWith(currentUrlPattern)) { var nodeText = string.Format("Filter: {0} --> {1} --> {2}", filter.name, filter.urlPattern, filter.@class); treeNode.Nodes.Add(nodeText); } } /*treeNode.Nodes.Add("debug: " + strutsActionServet.debug); * * treeNode.Nodes.Add("detail: " + strutsActionServet.detail); * treeNode.Nodes.Add("rule sets: " + strutsActionServet.ruleSets); * treeNode.Nodes.Add("application: " + strutsActionServet.ruleSets);*/ foreach (var configFile in strutsActionServet.configFiles) { treeNode.Nodes.Add("config file: " + configFile); } foreach (var chainConfigFile in strutsActionServet.chainConfigFiles) { treeNode.Nodes.Add("chainConfig file: " + chainConfigFile); } if (strutsActionServet.controllers.Count > 0) { var controllersNode = O2Forms.newTreeNode(treeNode.Nodes, "controllers", 0, strutsActionServet.controllers); controllersNode.Nodes.Add("DummyNode"); } if (strutsActionServet.formsBeans.Count > 0) { var controllersNode = O2Forms.newTreeNode(treeNode.Nodes, "form beans", 0, strutsActionServet.formsBeans); controllersNode.Nodes.Add("DummyNode"); } }
private static IStrutsMappings_ActionServlet calculateActionServlet(IWebXml webXml, IWebXml_Servlet_Mapping servletMapping, IWebXml_Servlet servlet, IStrutsConfigXml strutsConfigXml) { var actionServlet = new KStrutsMappings_ActionServlet { name = servlet.servletName, loadOnStartUp = servlet.loadOnStartUp, urlPattern = servletMapping.urlPattern }; try { foreach (var param in servlet.initParam) { switch (param.Key) { case "config": var configFiles = param.Value.Split(','); foreach (var configFile in configFiles) { actionServlet.configFiles.Add(configFile.Trim()); } break; case "debug": actionServlet.debug = param.Value; break; case "detail": actionServlet.detail = param.Value; break; case "rulesets": actionServlet.ruleSets = param.Value; break; case "validate": actionServlet.validate = param.Value; break; case "application": actionServlet.application = param.Value; break; case "chainConfig": var chainConfigFiles = param.Value.Split(','); foreach (var chainConfigFile in chainConfigFiles) { actionServlet.chainConfigFiles.Add(chainConfigFile.Trim()); } break; default: PublicDI.log.error("in calculateActionServlet, unsupported servlet.initParam key value: {0}", param.Key); break; } } // map filters foreach (var filter in ((KWebXml)webXml).getFiltersDictionary()) { var strutsFilter = new KStrutsMappings_Filter { name = filter.Key.filterName, urlPattern = filter.Key.urlPattern, dispatcher = filter.Key.dispatcher, @class = filter.Value.filterClass }; actionServlet.filters.Add(strutsFilter); } // map paths and mapped view foreach (var actionMapping in strutsConfigXml.actionmappings) { var actionType = actionMapping.type ?? "[no type defined]"; // populate controller dictionary if (false == actionServlet.controllers.ContainsKey(actionType)) { actionServlet.controllers.Add(actionType, new KStrutsMappings_Controller { name = actionMapping.name, type = actionMapping.type }); } var controler = actionServlet.controllers[actionType]; // calculate paths var path = new KStrutsMappings_Controller_Path { path = actionMapping.path, input = actionMapping.input, validate = actionMapping.validate, forwards = actionMapping.forwards }; foreach (var forward in actionMapping.forwards) { addMappedView(path, forward.path, strutsConfigXml.resolvedViews); } //path.resolvedViews.Add(forward.path); //if (false == string.IsNullOrEmpty(path.input)) // path.resolvedViews.Add(path.input); addMappedView(path, path.input, strutsConfigXml.resolvedViews); controler.paths.Add(path); } // map beans foreach (var formBean in strutsConfigXml.formBeans) { actionServlet.formsBeans.Add(formBean.name, formBean); } // finally map the beans to the controllers foreach (var controller in actionServlet.controllers) { if (controller.Value.name != null) { if (actionServlet.formsBeans.ContainsKey(controller.Value.name)) { controller.Value.formBean = actionServlet.formsBeans[controller.Value.name]; } } } } catch (Exception ex) { PublicDI.log.error("in calculateActionServlet: {0}", ex.Message); } return(actionServlet); }