public static void populateTreeNodeWith_Controller_Path(TreeNode treeNode, KStrutsMappings_Controller_Path path) { addListIfNotEmpty(treeNode, path.resolvedViews, "resolved views:", false); addListIfNotEmpty(treeNode, path.notResolvedViews, "NOT resolved views:", false); addNodeIfNonEmpty(treeNode, "input", path.input); addNodeIfNonEmpty(treeNode, "validate", path.validate); addListIfNotEmpty(treeNode, path.forwards, "forward:", true); /*if (path.forwards.Count > 0) * foreach (var forward in path.forwards) * addNodeIfNonEmpty(treeNode, "forward", forward.ToString()); */ }
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); }