myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r919484 - /myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/
Date Fri, 05 Mar 2010 16:49:38 GMT
Author: gpetracek
Date: Fri Mar  5 16:49:38 2010
New Revision: 919484

URL: http://svn.apache.org/viewvc?rev=919484&view=rev
Log:
cleanup

Modified:
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptor.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptorInternals.java

Modified: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptor.java?rev=919484&r1=919483&r2=919484&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptor.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptor.java
Fri Mar  5 16:49:38 2010
@@ -39,7 +39,7 @@
 @UsageInformation(UsageCategory.INTERNAL)
 public class BeanValidationModuleValidationInterceptor extends AbstractValidationInterceptor
 {
-    private BeanValidationModuleValidationInterceptorInternals bviUtils =
+    BeanValidationModuleValidationInterceptorInternals bviUtils =
             new BeanValidationModuleValidationInterceptorInternals(this.logger);
 
     @Override
@@ -60,7 +60,7 @@
 
         if (propertyDetails != null)
         {
-            bviUtils.initComponentWithPropertyDetails(facesContext, uiComponent, propertyDetails);
+            initComponentWithPropertyDetails(facesContext, uiComponent, propertyDetails);
         }
 
         if (logger.isTraceEnabled())
@@ -69,6 +69,13 @@
         }
     }
 
+    protected void initComponentWithPropertyDetails(FacesContext facesContext,
+                                                    UIComponent uiComponent,
+                                                    PropertyDetails propertyDetails)
+    {
+        this.bviUtils.initComponentWithPropertyDetails(facesContext, uiComponent, propertyDetails);
+    }
+
     protected void processValidation(FacesContext facesContext, UIComponent uiComponent,
Object convertedObject)
     {
         PropertyInformation propertyInformation = getPropertyInformation(facesContext, uiComponent);
@@ -117,6 +124,14 @@
         Set<ConstraintViolation> violations = this.bviUtils
                 .validate(facesContext, uiComponent, convertedObject, propertyInformation);
 
+        processConstraintViolations(facesContext, uiComponent, convertedObject, violations);
+    }
+
+    protected void processConstraintViolations(FacesContext facesContext,
+                                             UIComponent uiComponent,
+                                             Object convertedObject,
+                                             Set<ConstraintViolation> violations)
+    {
         if(violations != null && !violations.isEmpty())
         {
             BeanValidationUtils.processConstraintViolations(facesContext, uiComponent, convertedObject,
violations);

Modified: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptorInternals.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptorInternals.java?rev=919484&r1=919483&r2=919484&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptorInternals.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptorInternals.java
Fri Mar  5 16:49:38 2010
@@ -26,10 +26,10 @@
 import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
 import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
 import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
-import org.apache.myfaces.extensions.validator.internal.ToDo;
-import org.apache.myfaces.extensions.validator.internal.Priority;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 
 import javax.faces.component.UIComponent;
@@ -40,8 +40,8 @@
 import javax.validation.metadata.BeanDescriptor;
 import javax.validation.metadata.ConstraintDescriptor;
 import javax.validation.metadata.ElementDescriptor;
-import java.util.Map;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -92,7 +92,7 @@
         {
             return;
         }
-        else if(foundGroups.length == 0)
+        else if (foundGroups.length == 0)
         {
             foundGroups = new Class[]{Default.class};
         }
@@ -105,6 +105,14 @@
             return;
         }
 
+        processElementDescriptor(facesContext, uiComponent, foundGroups, elementDescriptor);
+    }
+
+    void processElementDescriptor(FacesContext facesContext,
+                                  UIComponent uiComponent,
+                                  Class[] foundGroups,
+                                  ElementDescriptor elementDescriptor)
+    {
         Map<String, Object> metaData;
 
         for (ConstraintDescriptor<?> constraintDescriptor :
@@ -135,10 +143,10 @@
             result.putAll(transformMetaData(metaDataTransformer, constraintDescriptor));
         }
 
-        if(!constraintDescriptor.isReportAsSingleViolation())
+        if (!constraintDescriptor.isReportAsSingleViolation())
         {
             Set<ConstraintDescriptor<?>> composingConstraints = constraintDescriptor.getComposingConstraints();
-            if(composingConstraints != null && !composingConstraints.isEmpty())
+            if (composingConstraints != null && !composingConstraints.isEmpty())
             {
                 result.putAll(transformComposingConstraints(composingConstraints, elementClass));
             }
@@ -151,7 +159,7 @@
             Set<ConstraintDescriptor<?>> composingConstraints, Class elementClass)
     {
         Map<String, Object> result = new HashMap<String, Object>();
-        for(ConstraintDescriptor constraintDescriptor : composingConstraints)
+        for (ConstraintDescriptor constraintDescriptor : composingConstraints)
         {
             result.putAll(transformConstraintDescriptorToMetaData(constraintDescriptor, elementClass));
         }
@@ -186,9 +194,9 @@
 
     @SuppressWarnings({"unchecked"})
     Set<ConstraintViolation> validate(FacesContext facesContext,
-                  UIComponent uiComponent,
-                  Object convertedObject,
-                  PropertyInformation propertyInformation)
+                                      UIComponent uiComponent,
+                                      Object convertedObject,
+                                      PropertyInformation propertyInformation)
     {
         Class baseBeanClass = getBaseClassType(propertyInformation);
         String propertyName = getPropertyToValidate(propertyInformation);
@@ -210,24 +218,24 @@
                 .validateValue(baseBeanClass, propertyName, convertedObject, groups);
     }
 
-    private Class getBaseClassType(PropertyInformation propertyInformation)
+    Class getBaseClassType(PropertyInformation propertyInformation)
     {
         return ExtValUtils.getPropertyDetails(propertyInformation).getBaseObject().getClass();
     }
 
-    private String getPropertyToValidate(PropertyInformation propertyInformation)
+    String getPropertyToValidate(PropertyInformation propertyInformation)
     {
         return ExtValUtils.getPropertyDetails(propertyInformation).getProperty();
     }
 
-    private Class[] resolveGroups(FacesContext facesContext, UIComponent uiComponent)
+    Class[] resolveGroups(FacesContext facesContext, UIComponent uiComponent)
     {
         return ExtValBeanValidationContext.getCurrentInstance().getGroups(
                 facesContext.getViewRoot().getViewId(),
                 uiComponent.getClientId(facesContext));
     }
 
-    private ElementDescriptor getDescriptorFor(Class targetClass, String property)
+    ElementDescriptor getDescriptorFor(Class targetClass, String property)
     {
         BeanDescriptor beanDescriptor = ExtValBeanValidationContext.getCurrentInstance().getValidatorFactory()
                 .getValidator().getConstraintsForClass(targetClass);



Mime
View raw message