svn commit: r1293791 - in /struts/struts2/trunk/xwork-core/src: main/java/com/opensymphony/xwork2/validator/ test/java/com/opensymphony/xwork2/validator/
Author: lukaszlenart Date: Sun Feb 26 09:28:10 2012 New Revision: 1293791 URL: http://svn.apache.org/viewvc?rev=1293791&view=rev Log: WW-3753 - adheres AnnotationActionValidatorManager to ActionValidatorManager interface's contract Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManager.java struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManagerTest.java Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManager.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManager.java?rev=1293791&r1=1293790&r2=1293791&view=diff == --- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManager.java (original) +++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManager.java Sun Feb 26 09:28:10 2012 @@ -75,7 +75,7 @@ public class AnnotationActionValidatorMa } public List getValidators(Class clazz, String context, String method) { -final String validatorKey = buildValidatorKey(clazz); +final String validatorKey = buildValidatorKey(clazz, context); final List cfgs; if (validatorCache.containsKey(validatorKey)) { @@ -216,23 +216,36 @@ public class AnnotationActionValidatorMa * @param clazz the action. * @return a validator key which is the class name plus context. */ -protected static String buildValidatorKey(Class clazz) { +protected static String buildValidatorKey(Class clazz, String context) { ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); ActionProxy proxy = invocation.getProxy(); ActionConfig config = proxy.getConfig(); -//the key needs to use the name of the action from the config file, -//instead of the url, so wild card actions will have the same validator -//see WW-2996 StringBuilder sb = new StringBuilder(clazz.getName()); sb.append("/"); if (StringUtils.isNotBlank(config.getPackageName())) { sb.append(config.getPackageName()); sb.append("/"); } -sb.append(config.getName()); -sb.append("|"); -sb.append(proxy.getMethod()); + +// the key needs to use the name of the action from the config file, +// instead of the url, so wild card actions will have the same validator +// see WW-2996 + +// UPDATE: +// WW-3753 Using the config name instead of the context only for +// wild card actions to keep the flexibility provided +// by the original design (such as mapping different contexts +// to the same action and method if desired) +String configName = config.getName(); +if (configName.contains(ActionConfig.WILDCARD)) { +sb.append(configName); +sb.append("|"); +sb.append(proxy.getMethod()); +} else { +sb.append(context); +} + return sb.toString(); } Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java?rev=1293791&r1=1293790&r2=1293791&view=diff == --- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java (original) +++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java Sun Feb 26 09:28:10 2012 @@ -19,7 +19,6 @@ import com.opensymphony.xwork2.ActionInv import com.opensymphony.xwork2.ActionProxy; import com.opensymphony.xwork2.Validateable; import com.opensymphony.xwork2.inject.Inject; -import com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor; import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor; import com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil; import com.opensymphony.xwork2.util.logging.Logger; @@ -206,7 +205,8 @@ public class ValidationInterceptor exten //the action name has to be from the url, otherwise validators that use aliases, like //MyActio-someaction-validator.xml will not be found, see WW-3194 -String context = proxy.getActionName(); +//UPDATE: see WW-3753 +String context = this.getValidationContext(proxy); String met
svn commit: r1293795 - /struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptorTest.java
Author: lukaszlenart Date: Sun Feb 26 09:52:12 2012 New Revision: 1293795 URL: http://svn.apache.org/viewvc?rev=1293795&view=rev Log: WW-3753 - adheres AnnotationActionValidatorManager to ActionValidatorManager interface's contract Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptorTest.java Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptorTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptorTest.java?rev=1293795&r1=1293794&r2=1293795&view=diff == --- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptorTest.java (original) +++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptorTest.java Sun Feb 26 09:52:12 2012 @@ -21,12 +21,12 @@ package org.apache.struts2.interceptor.validation; -import org.apache.struts2.StrutsTestCase; -import org.easymock.EasyMock; - import com.mockobjects.dynamic.Mock; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.ActionProxy; import com.opensymphony.xwork2.config.entities.ActionConfig; +import org.apache.struts2.StrutsTestCase; public class AnnotationValidationInterceptorTest extends StrutsTestCase { @@ -52,7 +52,6 @@ public class AnnotationValidationInterce } public void testShouldNotSkip() throws Exception { -mockActionProxy.expectAndReturn("getMethod", "execute"); mockActionProxy.expectAndReturn("getActionName", "foo"); mockActionProxy.expectAndReturn("getMethod", "execute"); mockActionProxy.expectAndReturn("getConfig", config); @@ -86,7 +85,6 @@ public class AnnotationValidationInterce } public void testShouldNotSkipBase() throws Exception { -mockActionProxy.expectAndReturn("getMethod", "dontSkipMeBase"); mockActionProxy.expectAndReturn("getActionName", "foo"); mockActionProxy.expectAndReturn("getMethod", "execute"); mockActionProxy.expectAndReturn("getConfig", config);
[CONF] Confluence Changes in the last 24 hours
This is a daily summary of all recent changes in Confluence. - Updated Spaces: - Apache ActiveMQ CPP (https://cwiki.apache.org/confluence/display/AMQCPP) Pages - General Build Issues created by tabish121 (03:50 PM) https://cwiki.apache.org/confluence/display/AMQCPP/General+Build+Issues Apache CXF (https://cwiki.apache.org/confluence/display/CXF) Pages - Resources and Articles edited by ashakirin (10:50 AM) https://cwiki.apache.org/confluence/display/CXF/Resources+and+Articles Apache CXF Documentation (https://cwiki.apache.org/confluence/display/CXF20DOC) Pages - Custom Transport created by ashakirin (09:19 AM) https://cwiki.apache.org/confluence/display/CXF20DOC/Custom+Transport Apache Deft (https://cwiki.apache.org/confluence/display/DEFT) Pages - Architecture edited by jmeehan (12:08 PM) https://cwiki.apache.org/confluence/display/DEFT/Architecture Apache Flex (https://cwiki.apache.org/confluence/display/FLEX) Pages - FAQ edited by martin.heidegger (09:51 AM) https://cwiki.apache.org/confluence/display/FLEX/FAQ App Examples edited by masuland (04:52 AM) https://cwiki.apache.org/confluence/display/FLEX/App+Examples Comments https://cwiki.apache.org/confluence/display/FLEX/Bug+Reports (1) https://cwiki.apache.org/confluence/display/FLEX/Feature+Requests (1) OpenJPA (https://cwiki.apache.org/confluence/display/openjpa) Pages - Intro edited by kwsut...@gmail.com (02:37 PM) https://cwiki.apache.org/confluence/display/openjpa/Intro Apache Struts 2 Plugin Registry (https://cwiki.apache.org/confluence/display/S2PLUGINS) Pages - .bookmarks edited by ang (12:59 PM) https://cwiki.apache.org/confluence/display/S2PLUGINS/.bookmarks Roger Mbiama created by ang (12:40 PM) https://cwiki.apache.org/confluence/display/S2PLUGINS/Roger+Mbiama ADT3 created by ang (12:38 PM) https://cwiki.apache.org/confluence/display/S2PLUGINS/ADT3 ADP3 created by ang (12:28 PM) https://cwiki.apache.org/confluence/display/S2PLUGINS/ADP3 Conversation Plugin created by rees.byars (10:17 AM) https://cwiki.apache.org/confluence/display/S2PLUGINS/Conversation+Plugin Struts2 Conversation Scope Plugin - Version 1.3 created by rees.byars (10:03 AM) https://cwiki.apache.org/confluence/display/S2PLUGINS/2012/02/26/Struts2+Conversation+Scope+Plugin+-+Version+1.3 Struts2 Conversation Scope Plugin Released edited by rees.byars (09:55 AM) https://cwiki.apache.org/confluence/display/S2PLUGINS/2012/02/12/Struts2+Conversation+Scope+Plugin+Released Change your notification preferences: https://cwiki.apache.org/confluence/users/viewnotifications.action