[CONF] Confluence Changes in the last 24 hours
- This is a daily summary of all recent changes in Confluence. - Updated Spaces: - Apache Camel (CAMEL) http://cwiki.apache.org/confluence/display/CAMEL | |-Pages Added or Edited in This Space |-- Camel 2.0.0 Release was last edited by davsclaus (01:58 AM). | http://cwiki.apache.org/confluence/display/CAMEL/Camel+2.0.0+Release OpenWebBeans (OWB) http://cwiki.apache.org/confluence/display/OWB | |-Pages Added or Edited in This Space |-- Index was created by ipv6guru (07:12 PM). | http://cwiki.apache.org/confluence/display/OWB/Index Apache Shindig (SHINDIG) http://cwiki.apache.org/confluence/display/SHINDIG | |-Pages Added or Edited in This Space |-- Logo Contest was last edited by vsiveton (11:19 AM). | http://cwiki.apache.org/confluence/display/SHINDIG/Logo+Contest Apache Struts 2 Documentation (WW) http://cwiki.apache.org/confluence/display/WW | |-New Comments in This Space |-- http://cwiki.apache.org/confluence/display/WW/Home (1) Apache Lucene Mahout (MAHOUT) http://cwiki.apache.org/confluence/display/MAHOUT | |-Pages Added or Edited in This Space |-- BuildingMahout was last edited by adeneche (04:26 AM). | http://cwiki.apache.org/confluence/display/MAHOUT/BuildingMahout - CONFLUENCE INFORMATION This message is automatically generated by Confluence Unsubscribe or edit your notifications preferences http://cwiki.apache.org/confluence/users/viewnotifications.action If you think it was sent incorrectly contact one of the administrators http://cwiki.apache.org/confluence/administrators.action If you want more information on Confluence, or have a bug to report see http://www.atlassian.com/software/confluence
svn commit: r759781 - in /struts/sandbox/trunk/struts2-oval-plugin/src: main/java/org/apache/struts2/interceptor/ test/java/org/apache/struts2/interceptor/ test/resources/
Author: musachy Date: Sun Mar 29 20:37:40 2009 New Revision: 759781 URL: http://svn.apache.org/viewvc?rev=759781&view=rev Log: Add alwaysInvokevalidate and programmatic attributes Modified: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/OValValidationInterceptorTest.java struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleField.java struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/oval-test.xml Modified: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java?rev=759781&r1=759780&r2=759781&view=diff == --- struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java (original) +++ struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java Sun Mar 29 20:37:40 2009 @@ -21,8 +21,10 @@ package org.apache.struts2.interceptor; import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor; +import com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.Validateable; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.validator.ValidatorContext; import com.opensymphony.xwork2.validator.DelegatingValidatorContext; @@ -48,6 +50,32 @@ public class OValValidationInterceptor extends MethodFilterInterceptor { private static final Logger LOG = LoggerFactory.getLogger(OValValidationInterceptor.class); +private final static String VALIDATE_PREFIX = "validate"; +private final static String ALT_VALIDATE_PREFIX = "validateDo"; + +private boolean alwaysInvokeValidate = true; +private boolean programmatic = true; + +/** + * Determines if {...@link com.opensymphony.xwork2.Validateable}'s validate() should be called, + * as well as methods whose name that start with "validate". Defaults to "true". + * + * @param programmatic true then validate() is invoked. + */ +public void setProgrammatic(boolean programmatic) { +this.programmatic = programmatic; +} + +/** + * Determines if {...@link com.opensymphony.xwork2.Validateable}'s validate() should always + * be invoked. Default to "true". + * + * @param alwaysInvokeValidate true then validate() is always invoked. + */ +public void setAlwaysInvokeValidate(String alwaysInvokeValidate) { +this.alwaysInvokeValidate = Boolean.parseBoolean(alwaysInvokeValidate); +} + protected String doIntercept(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); ActionProxy proxy = invocation.getProxy(); @@ -58,6 +86,50 @@ LOG.debug("Validating [#0/#1] with method [#2]", invocation.getProxy().getNamespace(), invocation.getProxy().getActionName(), methodName); } +//OVal vallidatio (no XML yet) +performOValValidation(action, valueStack, methodName); + +//Validatable.valiedate() and validateX() +performProgrammaticValidation(invocation, action); + +return invocation.invoke(); +} + +private void performProgrammaticValidation(ActionInvocation invocation, Object action) throws Exception { +if (action instanceof Validateable && programmatic) { +// keep exception that might occured in validateXXX or validateDoXXX +Exception exception = null; + +Validateable validateable = (Validateable) action; +if (LOG.isDebugEnabled()) { +LOG.debug("Invoking validate() on action [#0]", validateable.toString()); +} + +try { +PrefixMethodInvocationUtil.invokePrefixMethod( +invocation, +new String[]{VALIDATE_PREFIX, ALT_VALIDATE_PREFIX}); +} +catch (Exception e) { +// If any exception occurred while doing reflection, we want +// validate() to be executed +LOG.warn("An exception occured while executing the prefix method", e); +exception = e; +} + + +if (alwaysInvokeValidate) { +validateable.validate(); +} + +if (exception != null) { +// rethrow if something is wrong while doing validateXXX / validateDoXXX +throw exception; +} +} +} +
svn commit: r759802 - in /struts/sandbox/trunk/struts2-oval-plugin: ./ src/main/java/org/apache/struts2/interceptor/ src/main/resources/ src/test/java/org/apache/struts2/interceptor/ src/test/resource
Author: musachy Date: Mon Mar 30 00:15:50 2009 New Revision: 759802 URL: http://svn.apache.org/viewvc?rev=759802&view=rev Log: Add XML support Added: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/DefaultOValValidationManager.java struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationManager.java struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldsXml.java struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldsXml-validation.xml Modified: struts/sandbox/trunk/struts2-oval-plugin/pom.xml struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/struts-plugin.xml struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/OValValidationInterceptorTest.java struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/oval-test.xml Modified: struts/sandbox/trunk/struts2-oval-plugin/pom.xml URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/pom.xml?rev=759802&r1=759801&r2=759802&view=diff == --- struts/sandbox/trunk/struts2-oval-plugin/pom.xml (original) +++ struts/sandbox/trunk/struts2-oval-plugin/pom.xml Mon Mar 30 00:15:50 2009 @@ -50,8 +50,14 @@ 1.31 + +com.thoughtworks.xstream +xstream +1.3.1 + + - + org.easymock easymock 2.0 Added: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/DefaultOValValidationManager.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/DefaultOValValidationManager.java?rev=759802&view=auto == --- struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/DefaultOValValidationManager.java (added) +++ struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/DefaultOValValidationManager.java Mon Mar 30 00:15:50 2009 @@ -0,0 +1,139 @@ +package org.apache.struts2.interceptor; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.util.FileManager; +import com.opensymphony.xwork2.util.logging.Logger; +import com.opensymphony.xwork2.util.logging.LoggerFactory; +import net.sf.oval.configuration.xml.XMLConfigurer; +import net.sf.oval.configuration.Configurer; + +import java.util.List; +import java.util.Map; +import java.util.ArrayList; +import java.util.Set; +import java.util.TreeSet; +import java.util.HashMap; + + +public class DefaultOValValidationManager implements OValValidationManager { +private static final Logger LOG = LoggerFactory.getLogger(DefaultOValValidationManager.class); + +private static final String VALIDATION_CONFIG_SUFFIX = "-validation.xml"; +private final Map> validatorCache = new HashMap>(); +private final Map validatorFileCache = new HashMap(); + +public synchronized List getConfigurers(Class clazz, String context) { +final String validatorKey = buildValidatorKey(clazz, context); + +if (validatorCache.containsKey(validatorKey)) { +if (FileManager.isReloadingConfigs()) { +validatorCache.put(validatorKey, buildXMLConfigurers(clazz, context, true, null)); +} +} else { +validatorCache.put(validatorKey, buildXMLConfigurers(clazz, context, false, null)); +} + +// get the set of validator configs +return validatorCache.get(validatorKey); +} + +protected static String buildValidatorKey(Class clazz, String context) { +StringBuilder sb = new StringBuilder(clazz.getName()); +sb.append("/"); +sb.append(context); +return sb.toString(); +} + +private List buildXMLConfigurers(Class clazz, String context, boolean checkFile, Set checked) { +List xmlConfigurers = new ArrayList(); + +if (checked == null) { +checked = new TreeSet(); +} else if (checked.contains(clazz.getName())) { +return xmlConfigurers; +} + +if (clazz.isInterface()) { +for (Class anInterface : clazz.getInterfaces()) { +xmlConfigurers.addAll(buildXMLConfigurers(anInterface, context, checkFile, checked)); +} +} else { +if (!clazz.equals(Object.class)) { + xmlConfigurers.addAll(buildXMLConfigurers(clazz.getSuperclass(), context, checkFile, checked)); +} +} + +// look for validators for implemented interfaces +
svn commit: r759834 - in /struts/sandbox/trunk/struts2-oval-plugin/src: main/java/org/apache/struts2/interceptor/ test/java/org/apache/struts2/interceptor/ test/resources/ test/resources/org/apache/st
Author: musachy Date: Mon Mar 30 02:48:48 2009 New Revision: 759834 URL: http://svn.apache.org/viewvc?rev=759834&view=rev Log: Add XML support Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldsXML.java - copied, changed from r759802, struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldsXml.java struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldsXML-validation.xml - copied, changed from r759802, struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldsXml-validation.xml Removed: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldsXml.java struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldsXml-validation.xml Modified: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/DefaultOValValidationManager.java struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/OValValidationInterceptorTest.java struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/oval-test.xml Modified: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/DefaultOValValidationManager.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/DefaultOValValidationManager.java?rev=759834&r1=759833&r2=759834&view=diff == --- struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/DefaultOValValidationManager.java (original) +++ struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/DefaultOValValidationManager.java Mon Mar 30 02:48:48 2009 @@ -6,6 +6,7 @@ import com.opensymphony.xwork2.util.logging.LoggerFactory; import net.sf.oval.configuration.xml.XMLConfigurer; import net.sf.oval.configuration.Configurer; +import net.sf.oval.configuration.annotation.AnnotationsConfigurer; import java.util.List; import java.util.Map; @@ -27,10 +28,22 @@ if (validatorCache.containsKey(validatorKey)) { if (FileManager.isReloadingConfigs()) { -validatorCache.put(validatorKey, buildXMLConfigurers(clazz, context, true, null)); +List configurers = buildXMLConfigurers(clazz, context, true, null); + +//add an annotation configurer +AnnotationsConfigurer annotationsConfigurer = new AnnotationsConfigurer(); +configurers.add(annotationsConfigurer); + +validatorCache.put(validatorKey, configurers); } } else { -validatorCache.put(validatorKey, buildXMLConfigurers(clazz, context, false, null)); +List configurers = buildXMLConfigurers(clazz, context, false, null); + +//add an annotation configurer +AnnotationsConfigurer annotationsConfigurer = new AnnotationsConfigurer(); +configurers.add(annotationsConfigurer); + +validatorCache.put(validatorKey, configurers); } // get the set of validator configs @@ -45,21 +58,21 @@ } private List buildXMLConfigurers(Class clazz, String context, boolean checkFile, Set checked) { -List xmlConfigurers = new ArrayList(); +List configurers = new ArrayList(); if (checked == null) { checked = new TreeSet(); } else if (checked.contains(clazz.getName())) { -return xmlConfigurers; +return configurers; } if (clazz.isInterface()) { for (Class anInterface : clazz.getInterfaces()) { -xmlConfigurers.addAll(buildXMLConfigurers(anInterface, context, checkFile, checked)); +configurers.addAll(buildXMLConfigurers(anInterface, context, checkFile, checked)); } } else { if (!clazz.equals(Object.class)) { - xmlConfigurers.addAll(buildXMLConfigurers(clazz.getSuperclass(), context, checkFile, checked)); +configurers.addAll(buildXMLConfigurers(clazz.getSuperclass(), context, checkFile, checked)); } } @@ -69,24 +82,24 @@ continue; } -addIfNotNull(xmlConfigurers, buildClassValidatorConfigs(anInterface1, checkFile)); +addIfNotNull(configurers, buildClassValidatorConfigs(anInterface1, checkFile)); if (context != null) { -addIfNotNull(xmlConfigurers, buildAliasValidatorConfigs(anInterface1, context, checkFile)); +addI