public String getPrefix() { return delegate.getNamespace(); }
/** * returns the Map of all the ActionConfigs available in the current package. * ActionConfigs defined in ancestor packages will be included in this Map. * * @return a Map of ActionConfig Objects with the action name as the key * @see ActionConfig */ public Map<String, ActionConfig> getAllActionConfigs() { Map<String, ActionConfig> retMap = new LinkedHashMap<String, ActionConfig>(); if (!parents.isEmpty()) { for (PackageConfig parent : parents) { retMap.putAll(parent.getAllActionConfigs()); } } retMap.putAll(getActionConfigs()); return retMap; }
/** * returns the Map of all the global ResultConfigs available in the current package. * Global ResultConfigs defined in ancestor packages will be included in this Map. * * @return a Map of Result Objects with the result name as the key * @see ResultConfig */ public Map<String, ResultConfig> getAllGlobalResults() { Map<String, ResultConfig> retMap = new LinkedHashMap<String, ResultConfig>(); if (!parents.isEmpty()) { for (PackageConfig parentConfig : parents) { retMap.putAll(parentConfig.getAllGlobalResults()); } } retMap.putAll(getGlobalResultConfigs()); return retMap; }
/** * returns the List of all the ExceptionMappingConfigs available in the current package. * ExceptionMappingConfigs defined in ancestor packages will be included in this list. * * @return a List of ExceptionMappingConfigs Objects with the result type name as the key * @see ExceptionMappingConfig */ public List<ExceptionMappingConfig> getAllExceptionMappingConfigs() { List<ExceptionMappingConfig> allExceptionMappings = new ArrayList<ExceptionMappingConfig>(); if (!parents.isEmpty()) { for (PackageConfig parentContext : parents) { allExceptionMappings.addAll(parentContext.getAllExceptionMappingConfigs()); } } allExceptionMappings.addAll(getGlobalExceptionMappingConfigs()); return allExceptionMappings; }
String ns = pkg.getNamespace(); String pathPrefix = determinePath(actionConfig, ns); ActionConfig chainedToConfig = pkg.getActionConfigs().get(chainedTo); if (chainedToConfig != null) { LOG.trace("Action [{}] used as chain result for [{}] and result [{}]", chainedTo, actionName, resultCode); ResultTypeConfig chainResultType = pkg.getAllResultTypeConfigs().get("chain"); result = buildResult(chainedTo, resultCode, chainResultType, actionContext);
Map<String, ResultConfig> results = new TreeMap<String, ResultConfig>(); if (!baseConfig.getPackageName().equals(packageContext.getName()) && packageContexts.containsKey(baseConfig.getPackageName())) { results.putAll(packageContexts.get(baseConfig.getPackageName()).getAllGlobalResults()); } else { results.putAll(packageContext.getAllGlobalResults()); String defaultInterceptorRefName = packageContext.getFullDefaultInterceptorRef(); new LinkedHashMap<String, String>(), packageContext.getLocation(), objectFactory)); .addParams(params) .addResultConfigs(results) .defaultClassName(packageContext.getDefaultClassRef()) // fill in default if non class has been provided .interceptors(interceptors) .addExceptionMappings(packageContext.getAllExceptionMappingConfigs()) .build();
if (!packageConfig.isAbstract()) { String namespace = packageConfig.getNamespace(); Map<String, ActionConfig> configs = namespaceActionConfigs.get(namespace); Map<String, ActionConfig> actionConfigs = packageConfig.getAllActionConfigs(); if (packageConfig.getFullDefaultActionRef() != null) { namespaceConfigs.put(namespace, packageConfig.getFullDefaultActionRef());
ResultTypeConfig redirectResultTypeConfig = parentPackage.getAllResultTypeConfigs().get("redirect"); String redirectNamespace = namespace + "/" + actionName; LOG.trace("Checking if there is an action named index in the namespace {}", redirectNamespace); if (redirectNamespace.equals(packageConfig.getNamespace())) { LOG.trace("Action is not a default - redirecting"); return buildActionConfig(redirectNamespace + "/", redirectResultTypeConfig);
/** * Add Struts ActionMappings (from XWork ExceptionConfigs). */ private void initActionMappings() { if (_actionMappings == null) { _actionMappings = new HashMap(); for (Iterator i = delegate.getActionConfigs().entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); String actionPath = '/' + (String) entry.getKey(); com.opensymphony.xwork2.config.entities.ActionConfig actionConfig = (com.opensymphony.xwork2.config.entities.ActionConfig) entry.getValue(); _actionMappings.put(actionPath, strutsFactory.createActionMapping(actionConfig, actionPath, this)); } } }
private void setDefaultResults(Map<String, ResultConfig> results, PackageConfig packageContext) { String defaultResult = packageContext.getFullDefaultResultType(); for (Map.Entry<String, ResultConfig> entry : results.entrySet()) { if (entry.getValue() == null) { ResultTypeConfig resultTypeConfig = packageContext.getAllResultTypeConfigs().get(defaultResult); entry.setValue(new ResultConfig.Builder(null, resultTypeConfig.getClassName()).build()); } } }
ResultTypeConfig resultTypeConfig = packageConfig.getAllResultTypeConfigs().get(info.type); if (resultTypeConfig == null) { throw new ConfigurationException("The Result type [" + info.type + "] which is" + " by the file extension or is the default result type for the PackageConfig of the" + " action, could not be found as a result-type defined for the Struts/XWork package [" + packageConfig.getName() + "]");
/** * returns the Map of all InterceptorConfigs and InterceptorStackConfigs available in the current package. * InterceptorConfigs defined in ancestor packages will be included in this Map. * * @return a Map of InterceptorConfig and InterceptorStackConfig Objects with the ref-name as the key * @see InterceptorConfig * @see InterceptorStackConfig */ public Map<String, Object> getAllInterceptorConfigs() { Map<String, Object> retMap = new LinkedHashMap<String, Object>(); if (!parents.isEmpty()) { for (PackageConfig parentContext : parents) { retMap.putAll(parentContext.getAllInterceptorConfigs()); } } retMap.putAll(getInterceptorConfigs()); return retMap; }
/** * returns the Map of all the ResultTypeConfigs available in the current package. * ResultTypeConfigs defined in ancestor packages will be included in this Map. * * @return a Map of ResultTypeConfig Objects with the result type name as the key * @see ResultTypeConfig */ public Map<String, ResultTypeConfig> getAllResultTypeConfigs() { Map<String, ResultTypeConfig> retMap = new LinkedHashMap<String, ResultTypeConfig>(); if (!parents.isEmpty()) { for (PackageConfig parentContext : parents) { retMap.putAll(parentContext.getAllResultTypeConfigs()); } } retMap.putAll(getResultTypeConfigs()); return retMap; }
ActionConfig indexActionConfig = pkgConfig.build().getAllActionConfigs().get("index"); if (indexActionConfig == null) { continue; String parentNamespace = namespace.substring(0, lastSlash); PackageConfig.Builder parent = byNamespace.get(parentNamespace); if (parent == null || parent.build().getAllActionConfigs().get(parentAction) == null) { if (parent == null) { parent = new PackageConfig.Builder(parentNamespace).namespace(parentNamespace). addParents(pkgConfig.build().getParents()); packageConfigs.put(parentNamespace, parent); if (parent.build().getAllActionConfigs().get(parentAction) == null) { parent.addActionConfig(parentAction, indexActionConfig); if (pkgConfig.build().getAllActionConfigs().get("") == null) { LOG.trace("Creating index ActionConfig with an action name of [] for the action class [{}]", indexActionConfig.getClassName()); pkgConfig.addActionConfig("", indexActionConfig);
public String getFullDefaultResultType() { return target.getFullDefaultResultType(); }
protected ActionConfig buildActionConfig(String path, ResultTypeConfig resultTypeConfig) { Map<String, ResultConfig> results = new HashMap<>(); HashMap<String, String> params = new HashMap<>(); if (resultTypeConfig.getParams() != null) { params.putAll(resultTypeConfig.getParams()); } params.put(resultTypeConfig.getDefaultResultParam(), path); PackageConfig pkg = configuration.getPackageConfig(defaultParentPackageName); List<InterceptorMapping> interceptors = InterceptorBuilder.constructInterceptorReference(pkg, pkg.getFullDefaultInterceptorRef(), Collections.<String, String>emptyMap(), null, objectFactory); ResultConfig config = new ResultConfig.Builder(Action.SUCCESS, resultTypeConfig.getClassName()). addParams(params).build(); results.put(Action.SUCCESS, config); return new ActionConfig.Builder(defaultParentPackageName, "execute", ActionSupport.class.getName()). addInterceptors(interceptors). addResultConfigs(results). addAllowedMethod(pkg.getGlobalAllowedMethods()). build(); }
public ResultTypeConfig getResultType(String type) { return target.getAllResultTypeConfigs().get(type); }
/** * gets the default interceptor-ref name. If this is not set on this PackageConfig, it searches the parent * PackageConfigs in order until it finds one. */ public String getFullDefaultInterceptorRef() { if ((defaultInterceptorRef == null) && !parents.isEmpty()) { for (PackageConfig parent : parents) { String parentDefault = parent.getFullDefaultInterceptorRef(); if (parentDefault != null) { return parentDefault; } } } return defaultInterceptorRef; }
PackageConfig packageConfig = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getPackageConfig("default"); Map<String, Object> interceptorConfigs = packageConfig.getInterceptorConfigs(); InterceptorConfig interceptorConfig = (InterceptorConfig)interceptorConfigs.get("theInterceptor"); Map<String, String> params = interceptorConfig.getParams();
/** * Add Struts ActionForwards (from XWork ResultConfigs). */ private void initActionForwards() { if (_actionForwards == null) { _actionForwards = new HashMap(); for (Iterator i = delegate.getGlobalResultConfigs().entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); String name = (String) entry.getKey(); ResultConfig config = (ResultConfig) entry.getValue(); _actionForwards.put(name, strutsFactory.createActionForward(config)); } } }