/** * Checks if name of parameter can be accepted or thrown away * * @param name parameter name * @param action current action * @return true if parameter is accepted */ protected boolean isAcceptableParameter(String name, Object action) { ParameterNameAware parameterNameAware = (action instanceof ParameterNameAware) ? (ParameterNameAware) action : null; return acceptableName(name) && (parameterNameAware == null || parameterNameAware.acceptableParameterName(name)); }
/** * @param allowed The allowed paramters as comma separated String. */ public void setAllowed(String allowed) { setAllowedCollection(asCollection(allowed)); }
/** * @param blocked The blocked paramters as comma separated String. */ public void setBlocked(String blocked) { setBlockedCollection(asCollection(blocked)); }
public String intercept(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); if (action instanceof ValidationAware) { ValidationAware validationAware = (ValidationAware) action; validationAware.addFieldError("field", "field error"); validationAware.addActionMessage("action message"); validationAware.addActionError("action error"); } return invocation.invoke(); }
protected boolean acceptableName(String name) { boolean accepted = isWithinLengthLimit(name) && !isExcluded(name) && isAccepted(name); if (devMode && accepted) { // notify only when in devMode LOG.debug("Parameter [#0] was accepted and will be appended to action!", name); } return accepted; }
/** * Add error to action in cases where token is required, but is missing or invalid. Implementations may * wish to override this method, but most should be able to get away with just overriding * {@link #internationaliseErrorMessage} * * @param action the action to add the error message to * @param errorMessageKey the error message key that will be used to internationalise the message */ protected void addInvalidTokenError(Action action, String errorMessageKey) { if (action instanceof ValidationAware) ((ValidationAware)action).addActionError(internationaliseErrorMessage(action, errorMessageKey)); }
/** * Reads the locale from the session, and if not found from the * current invocation (=browser) * * @param invocation the current invocation * @param session the current session * @return the read locale */ protected Locale readStoredLocale(ActionInvocation invocation, Map<String, Object> session) { Locale locale = this.readStoredLocalFromSession(invocation, session); if (locale != null) { return locale; } return this.readStoredLocalFromCurrentInvocation(invocation); }
@Override public String intercept(ActionInvocation invocation) throws Exception { if (! shouldLog()) { return invocation.invoke(); } else { return invokeUnderTiming(invocation); } }
@Override public String intercept(ActionInvocation invocation) throws Exception { if (applyInterceptor(invocation)) { return doIntercept(invocation); } return invocation.invoke(); }
protected void find() { //get requested locale Map<String, Object> params = actionInvocation.getInvocationContext().getParameters(); storage = Storage.SESSION.toString(); requestedLocale = findLocaleParameter(params, parameterName); if (requestedLocale != null) { return; } requestedLocale = findLocaleParameter(params, requestOnlyParameterName); if (requestedLocale != null) { storage = Storage.NONE.toString(); } }
/** * Determines if we should log the time. * * @return true to log, false to not log. */ protected boolean shouldLog() { // default check first if (logLevel == null && logCategory == null) { return LOG.isInfoEnabled(); } // okay user have set some parameters return isLoggerEnabled(getLoggerToUse(), logLevel); }
public String intercept(ActionInvocation invocation) throws Exception { ActionContext invocationContext = invocation.getInvocationContext(); Object action = invocation.getAction(); if (action instanceof ValidationAware) { ValidationAware va = (ValidationAware) action; va.addFieldError("field", "message"); } .... }
protected LocaleFinder(ActionInvocation invocation) { actionInvocation = invocation; find(); }
public String invoke() throws Exception { for (Object preResultListener : preResultListeners) { PreResultListener listener = (PreResultListener) preResultListener; listener.beforeResult(this, resultCode); } return resultCode; }
protected Object getOverrideExpr(ActionInvocation invocation, Object value) { return escape(value); }
/** * Return the depth to the superclass matching. 0 means ex matches exactly. Returns -1 if there's no match. * Otherwise, returns depth. Lowest depth wins. * * @param exceptionMapping the mapping classname * @param t the cause * @return the depth, if not found -1 is returned. */ public int getDepth(String exceptionMapping, Throwable t) { return getDepth(exceptionMapping, t.getClass(), 0); }
@Override public String intercept(ActionInvocation invocation) throws Exception { logMessage(invocation, START_MESSAGE); String result = invocation.invoke(); logMessage(invocation, FINISH_MESSAGE); return result; }
protected boolean isWithinLengthLimit( String name ) { boolean matchLength = name.length() <= paramNameMaxLength; if (!matchLength) { notifyDeveloper("Parameter [#0] is too long, allowed length is [#1]", name, String.valueOf(paramNameMaxLength)); } return matchLength; }
/** * @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(); }
/** * Same as {@link #applyMethod(Set, Set, String)}, except that <code>excludeMethods</code> * and <code>includeMethods</code> are supplied as comma separated string. * * @param excludeMethods comma seperated string of methods to exclude. * @param includeMethods comma seperated string of methods to include. * @param method the specified method to check * @return <tt>true</tt> if the method should be applied. */ public static boolean applyMethod(String excludeMethods, String includeMethods, String method) { Set<String> includeMethodsSet = TextParseUtil.commaDelimitedStringToSet(includeMethods == null? "" : includeMethods); Set<String> excludeMethodsSet = TextParseUtil.commaDelimitedStringToSet(excludeMethods == null? "" : excludeMethods); return applyMethod(excludeMethodsSet, includeMethodsSet, method); }