Refine search
public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); // the object to pass parameters Map<String, Object> templateParameterMap = new HashMap<String, Object>(); String resultCode = invocation.getResultCode(); if (resultCode != null) { ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get( resultCode); Map<String, String> resultConfigParams = resultConfig.getParams(); for (Iterator<Entry<String, String>> i = resultConfigParams.entrySet().iterator(); i.hasNext(); ) { Map.Entry<String, String> e = i.next(); if (! predefinedResultParam.contains(e.getKey())) { templateParameterMap.put(e.getKey().toString(), e.getValue() == null ? "": conditionalParse(e.getValue().toString(), invocation)); } } } StdrUtil.getParameters(request).putAll(templateParameterMap); super.doExecute(finalLocation, invocation); }
private String getDetails(ActionInvocation invocation) { ActionProxy proxy = invocation.getProxy(); String methodName = proxy.getConfig().getMethodName(); if (methodName == null) methodName = "execute"; String actionClazz = ProfilingUtils.getJustClassName(proxy.getConfig().getClassName()); return proxy.getNamespace() + "/" + proxy.getActionName() + ".action (" + actionClazz + "." + methodName + "())"; }
ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); ActionProxy proxy = invocation.getProxy(); ActionConfig config = proxy.getConfig(); if (StringUtils.isNotBlank(config.getPackageName())) { sb.append(config.getPackageName()); sb.append("/"); String configName = config.getName(); if (configName.contains(ActionConfig.WILDCARD) || (configName.contains("{") && configName.contains("}"))) { sb.append(configName); sb.append("|"); sb.append(proxy.getMethod()); } else { sb.append(context);
@Override public String intercept(ActionInvocation invocation) throws Exception { ActionConfig config = invocation.getProxy().getConfig(); ActionContext ac = invocation.getInvocationContext(); Object action = invocation.getAction(); final Map<String, String> parameters = config.getParams(); ValueStack stack = ac.getValueStack(); Object obj = stack.findValue(aliasExpression); if (null == value) { Map<String, Object> contextParameters = ActionContext.getContext().getParameters();
@Override public String intercept(ActionInvocation invocation) throws Exception { ActionConfig config = invocation.getProxy().getConfig(); Object action = invocation.getAction(); final Map<String, String> parameters = config.getParams(); ActionContext ac = ActionContext.getContext(); Map<String, Object> contextMap = ac.getContextMap(); try { ReflectionContextState.setCreatingNullObjects(contextMap, true); ReflectionContextState.setReportingConversionErrors(contextMap, true); final ValueStack stack = ac.getValueStack(); return invocation.invoke();
ActionContext ctx = ActionContext.getContext(); if (outcome != null) { if (ctx == null || ctx.getActionInvocation() == null) { delegateToParentNavigation(facesContext, fromAction, outcome); } else { ActionConfig config = ctx.getActionInvocation().getProxy().getConfig(); Map results = config.getResults(); ctx.getActionInvocation().setResultCode(outcome); } else { delegateToParentNavigation(facesContext, fromAction, outcome);
@Override public String intercept(ActionInvocation invocation) throws Exception { String result; try { result = invocation.invoke(); } catch (Exception e) { if (isLogEnabled()) { handleLogging(e); } List<ExceptionMappingConfig> exceptionMappings = invocation.getProxy().getConfig().getExceptionMappings(); ExceptionMappingConfig mappingConfig = this.findMappingFromExceptions(exceptionMappings, e); if (mappingConfig != null && mappingConfig.getResult()!=null) { Map parameterMap = mappingConfig.getParams(); // create a mutable HashMap since some interceptors will remove parameters, and parameterMap is immutable invocation.getInvocationContext().setParameters(new HashMap<String, Object>(parameterMap)); result = mappingConfig.getResult(); publishException(invocation, new ExceptionHolder(e)); } else { throw e; } } return result; }
Object action = invocation.getAction(); HttpServletRequest req = ServletActionContext.getRequest(); Struts1Factory strutsFactory = new Struts1Factory(configuration); ActionMapping mapping = strutsFactory.createActionMapping(invocation.getProxy().getConfig()); ModuleConfig moduleConfig = strutsFactory.createModuleConfig(invocation.getProxy().getConfig().getPackageName()); req.setAttribute(Globals.MODULE_KEY, moduleConfig); req.setAttribute(Globals.MESSAGES_KEY, new WrapperMessageResources((TextProvider)invocation.getAction()));
ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); ActionProxy proxy = invocation.getProxy(); ActionConfig config = proxy.getConfig(); Map<String, ResultConfig> results = config.getResults(); ResultConfig resultConfig = results.get(Action.SUCCESS); String lastFinalLocation = null; Map<String, String> params = resultConfig.getParams(); if (resultConfig.getClassName().equals("org.apache.struts2.dispatcher.ServletDispatcherResult")) { lastFinalLocation = params.get("location"); } System.out.println("location: " + lastFinalLocation);
public String intercept(ActionInvocation invocation) throws Exception { Method invocationMethod = versionSupport.extractMethod(invocation); String configParam = (String) invocation.getProxy().getConfig().getParams().get(CONFIG_PARAM_NAME); RequireSecurityToken annotation = invocationMethod.getAnnotation(RequireSecurityToken.class); boolean isProtected = methodRequiresProtection(configParam, annotation); String token = ServletActionContext.getRequest().getParameter(REQUEST_PARAM_NAME); boolean validToken = tokenGenerator.validateToken(ServletActionContext.getRequest(), token); if (isProtected && !validToken) { if (token == null) { addInvalidTokenError(versionSupport.extractAction(invocation), SECURITY_TOKEN_REQUIRED_ERROR_KEY); } else { addInvalidTokenError(versionSupport.extractAction(invocation), VALIDATION_FAILED_ERROR_KEY); } ServletActionContext.getResponse().setStatus(403); return ActionSupport.INPUT; } return invocation.invoke(); }
/** * @param ac The action context * @return the parameters from the action mapping in the context. If none found, returns * an empty map. */ protected Map<String, String> retrieveParameters(ActionContext ac) { ActionConfig config = ac.getActionInvocation().getProxy().getConfig(); if (config != null) { return config.getParams(); } else { return Collections.emptyMap(); } }
invocationContext, proxy.getActionName(), proxy.getConfig(), resultCode); ResultConfig resultConfig = this.proxy.getConfig().getResults().get(defaultErrorResultName); if (resultConfig != null) { this.result = objectFactory.buildResult(resultConfig, invocationContext.getContextMap()); LOG.debug("Found default error result.");
public String intercept(ActionInvocation invocation) throws Exception { // Get the action configuration defined in struts.xml ActionConfig config = invocation.getProxy().getConfig(); // Get the SUCCESS result configured for that Action ResultConfig success = config.getResults().get("success"); // Get the class of the SUCCESS result Object clazz = success.getClass(); /* .... oops, some error occurred !! We now need to redirect to the right global error result .... */ if (clazz instanceof org.apache.struts2.dispatcher.ServletDispatcherResult) { log.debug("Struts2 Result type: CLASSIC"); return "error"; } else if (clazz instanceof org.apache.struts2.json.JSONResult) { log.debug("Struts2 Result type: JSON"); return "jsonError"; } else { log.debug("Struts2 Result type: SOMETHING ELSE, returning default "); return "error"; } }
Map<String, String> vars) { String methodName = convertParam(orig.getMethodName(), vars); if (!orig.isAllowedMethod(methodName)) { return null; String className = convertParam(orig.getClassName(), vars); String pkgName = convertParam(orig.getPackageName(), vars); Map<String,String> params = replaceParameters(orig.getParams(), vars); for (String name : orig.getResults().keySet()) { ResultConfig result = orig.getResults().get(name); name = convertParam(name, vars); ResultConfig r = new ResultConfig.Builder(name, convertParam(result.getClassName(), vars)) for (ExceptionMappingConfig ex : orig.getExceptionMappings()) { String name = convertParam(ex.getName(), vars); String exClassName = convertParam(ex.getExceptionClassName(), vars); return new ActionConfig.Builder(pkgName, orig.getName(), className) .methodName(methodName) .addParams(params) .addResultConfigs(results) .addInterceptors(orig.getInterceptors()) .addExceptionMappings(exs) .location(orig.getLocation()) .build();
// Get the action configuration defined in struts.xml ActionConfig config = invocation.getProxy().getConfig(); // Get the SUCCESS result configured for that Action ResultConfig success = config.getResults().get("success"); // Iterate the Params, friendly printing :) for (Map.Entry<String, String> entry : success.getParams().entrySet()) { System.out.println("<param name=\"" + entry.getKey() + "\">" + entry.getValue() + "</param>"); }
Map<String, String> params = new TreeMap<String, String>(baseConfig.getParams()); 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()); results.putAll(baseConfig.getResults()); List<InterceptorMapping> interceptors = new ArrayList<InterceptorMapping>(baseConfig.getInterceptors());
if ( !StringUtils.equals( expectedAction.clazz, xwActionConfig.getClassName() ) ) " but got " + quote( xwActionConfig.getClassName() ) + " instead, on action " + quote( expectedAction.name ) + " in package " + quote( expectedPackage.name ) + "." ); if ( !StringUtils.equals( expectedAction.method, xwActionConfig.getMethodName() ) ) " but got " + quote( xwActionConfig.getMethodName() ) + " instead, on action " + quote( expectedAction.name ) + " in package " + quote( expectedPackage.name ) + "." ); Map<?, ?> xwResultMap = xwActionConfig.getResults();
public Object buildAction(String actionName, String namespace, ActionConfig config, Map<String, Object> extraContext) throws Exception { return objectFactory.buildBean(config.getClassName(), extraContext); }
public ModuleConfig getModuleConfig() { if (moduleConfig == null) { moduleConfig = strutsFactory.createModuleConfig(delegate.getPackageName()); } return moduleConfig; }