public String getType() { return delegate.getExceptionClassName(); }
public Builder(ExceptionMappingConfig toClone) { target = new ExceptionMappingConfig(toClone); }
public String toString() { return "wrapper -> " + delegate.toString(); } }
String name = convertParam(ex.getName(), vars); String exClassName = convertParam(ex.getExceptionClassName(), vars); String exResult = convertParam(ex.getResult(), vars); Map<String,String> exParams = replaceParameters(ex.getParams(), vars); ExceptionMappingConfig e = new ExceptionMappingConfig.Builder(name, exClassName, exResult).addParams(exParams).build(); exs.add(e);
@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; }
/** * @deprecated since 2.3.15 please use #findMappingFromExceptions directly instead */ protected String findResultFromExceptions(List<ExceptionMappingConfig> exceptionMappings, Throwable t) { ExceptionMappingConfig result = findMappingFromExceptions(exceptionMappings, t); return result==null?null:result.getResult(); }
/** * Add Struts ExceptionConfigs (from XWork ExceptionMappingConfigs). */ private void initExceptionConfigs() { if (_exceptionConfigs == null) { _exceptionConfigs = new HashMap(); for (Iterator i = delegate.getGlobalExceptionMappingConfigs().iterator(); i.hasNext();) { ExceptionMappingConfig config = (ExceptionMappingConfig) i.next(); _exceptionConfigs.put(config.getExceptionClassName(), strutsFactory.createExceptionConfig(config)); } } }
public Builder(String name, String exceptionClassName, String result) { target = new ExceptionMappingConfig(name, exceptionClassName, result); }
/** * Try to find appropriate {@link ExceptionMappingConfig} based on provided Throwable * * @param exceptionMappings list of defined exception mappings * @param t caught exception * @return appropriate mapping or null */ protected ExceptionMappingConfig findMappingFromExceptions(List<ExceptionMappingConfig> exceptionMappings, Throwable t) { ExceptionMappingConfig config = null; // Check for specific exception mappings. if (exceptionMappings != null) { int deepest = Integer.MAX_VALUE; for (Object exceptionMapping : exceptionMappings) { ExceptionMappingConfig exceptionMappingConfig = (ExceptionMappingConfig) exceptionMapping; int depth = getDepth(exceptionMappingConfig.getExceptionClassName(), t); if (depth >= 0 && depth < deepest) { deepest = depth; config = exceptionMappingConfig; } } } return config; }
public ExceptionMappingConfig build() { embalmTarget(); ExceptionMappingConfig result = target; target = new ExceptionMappingConfig(target); return result; }