Java Doc for AbstractValidatorAction.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » acting » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » apache lenya 2.0 » org.apache.cocoon.acting 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.cocoon.acting.AbstractAction
   org.apache.cocoon.acting.AbstractConfigurableAction
      org.apache.cocoon.acting.ConfigurableServiceableAction
         org.apache.cocoon.acting.AbstractComplementaryConfigurableAction
            org.apache.cocoon.acting.AbstractValidatorAction

All known Subclasses:   org.apache.cocoon.acting.FormValidatorAction,  org.apache.cocoon.acting.SessionValidatorAction,
AbstractValidatorAction
abstract public class AbstractValidatorAction extends AbstractComplementaryConfigurableAction (Code)
Abstract implementation of action that needs to perform validation of parameters (from session, from request, etc.). All `validator' actions share the same description xml file. In such file every parameter is described via its name, type and its constraints. One large description file can be used among all validator actions, because each action should explicitely specify which parameters to validate - through a sitemap parameter.

Variant 1

 <map:act type="validator">
 <parameter name="descriptor" value="context://descriptor.xml">
 <parameter name="validate" value="username,password">
 </map:act>
 

The list of parameters to be validated is specified as a comma separated list of their names. descriptor.xml can therefore be used among many various actions. If the list contains only of *, all parameters in the file will be validated.

Variant 2

 <map:act type="validator">
 <parameter name="descriptor" value="context://descriptor.xml">
 <parameter name="constraint-set" value="is-logged-in">
 </map:act>
 

The parameter "constraint-set" tells to take a given "constraint-set" from description file and test all parameters against given criteria. This variant is more powerful, more aspect oriented and more flexibile than the previous one, because it allows comparsion constructs, etc. See AbstractValidatorAction documentation.

For even more powerful validation, constraints can be grouped and used independently of the parameter name. If a validate element has a rule attribute, it uses the parameter with that name as a rule template and validates the parameter from the name attribute with that rule.

This action returns null when validation fails, otherwise it provides all validated parameters to the sitemap via {name} expression.

In addition a request attribute org.apache.cocoon.acting.FormValidatorAction.results contains the validation results in both cases and make it available to XSPs. The special parameter "*" contains either the validation result "OK", if all parameters were validated successfully, or "ERROR" otherwise. Mind you that redirections create new request objects and thus the result is not available for the target page.

 <root>
 <parameter name="username" type="string" nullable="no"/>
 <parameter name="role" type="string" nullable="no"/>
 <parameter name="oldpassword" type="string" nullable="no"/>
 <parameter name="newpassword" type="string" nullable="no"/>
 <parameter name="renewpassword" type="string" nullable="no"/>
 <parameter name="id" type="long" nullable="no"/>
 <parameter name="sallary" type="double" nullable="no"/>
 <parameter name="theme" type="string" nullable="yes" default="dflt"/>
 <constraint-set name="is-logged-in">
 <validate name="username"/>
 <validate name="role"/>
 </constraint-set>
 <constraint-set name="is-in-admin-role">
 <validate name="username"/>
 <validate name="role" equals-to="admin"/>
 </constraint-set>
 <constraint-set name="new-passwords-match">
 <validate name="oldpassword"/>
 <validate name="newpassword"/>
 <validate name="renewpassword"
 equals-to-param="newpass"/>
 </constraint-set>
 <constraint-set name="all">
 <include name="is-logged-in"/>
 <include name="is-in-admin-role"/>
 <include name="new-passwords-match"/>
 </constraint-set>
 </root>
 

The types recognized by validator and their attributes

stringnullable="yes|no" default="str"
longnullable="yes|no" default="123123"
doublenullable="yes|no" default="0.5"

Default value takes place only when specified parameter is nullable and really is null or empty. Long numbers may be specified in decimal, hex or octal values as accepted by java.Lang.decode (String s).

Constraints

matches-regexPOSIX regular expression
min-lenpositive integer
max-lenpositive integer
minDouble / Long
maxDouble / Long

Constraints can be defined globally for a parameter and can be overridden by redefinition in a constraint-set. Thus if e.g. a database field can take at maximum 200 character, this property can be set globally.

Values in parameter arrays are validated individually and the worst error is reported back.

The attributes recognized in "constraint-set"

equals-to-paramparameter name
equals-tostring constant

author:
   Martin Man
author:
   Christian Haul
version:
   CVS $Id: AbstractValidatorAction.java 433543 2006-08-22 06:22:54Z crossley $




Method Summary
public  Mapact(Redirector redirector, SourceResolver resolver, Map objectModel, String src, Parameters parameters)
    
abstract protected  HashMapcreateMapOfParameters(Map objectModel, Collection set)
     Reads parameter values for all parameters that are contained in the active constraint list.
protected  ConfigurationgetDescriptor(SourceResolver resolver, Map objectModel, Parameters parameters)
     Load the descriptor containing the constraints.
protected  CollectiongetSetOfParameterNamesFromSitemap(String valstr, Map desc)
     Get list of params to be validated from sitemap parameter and isolates the parameter names from the comma separated list.
protected  MapindexConfiguration(Configuration[] descriptor)
     Create an index map to an array of configurations by their name attribute.
protected  booleanisDescriptorReloadable()
     Checks the default setting for reloading the descriptor file.
abstract  booleanisStringEncoded()
    
protected  CollectionresolveConstraints(String valsetstr, Map consets)
     Recursively resolve constraint sets that may "include" other constraint sets and return a collection of all parameters to validate.
protected  MapsetResult(Map objectModel, Map actionMap, Map resultMap, boolean allOK)
     Add success indicator to resulting maps and clear actionMap if unsuccessful.
public  ValidatorActionHelpervalidateParameter(String name, Configuration constraints, Map conf, Map params, boolean isString)
     Try to validate given parameter.
Parameters:
  name - The name of the parameter to validate.
Parameters:
  constraints - Configuration of all constraints for thisparameter as taken from the description XML file.
Parameters:
  conf - Configuration of all parameters as taken from thedescription XML file.
Parameters:
  params - The map of parameters.
Parameters:
  isString - Indicates wheter given param to validate isstring (as taken from HTTP request for example) or wheteher itshould be regular instance of java.lang.Double, java.lang.Long,etc.
public  ValidatorActionHelpervalidateParameter(String name, String rule, Configuration constraints, Map conf, Map params, boolean isString)
     Try to validate given parameter.
Parameters:
  name - The actual name of the parameter to validate.
Parameters:
  rule - The name of the parameter element that contains therule that should be used for validation.
Parameters:
  constraints - Configuration of all constraints for thisparameter as taken from the description XML file.
Parameters:
  conf - Configuration of all parameters as taken from thedescription XML file.
Parameters:
  params - The map of parameters.
Parameters:
  isString - Indicates wheter given param to validate isstring (as taken from HTTP request for example) or wheteher itshould be regular instance of java.lang.Double, java.lang.Long,etc.
protected  booleanvalidateSetOfParameters(Map desc, Map actionMap, Map resultMap, Collection set, Map params, boolean isString)
     Validate all parameters in the set with the constraints contained in desc and the values from params.
protected  ValidatorActionHelpervalidateValue(String name, Configuration constraints, Configuration conf, Map params, boolean isString, String type)
     Validate a single parameter value.



Method Detail
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws Exception(Code)



createMapOfParameters
abstract protected HashMap createMapOfParameters(Map objectModel, Collection set)(Code)
Reads parameter values for all parameters that are contained in the active constraint list. If a parameter has multiple values, all are stored in the resulting map.
Parameters:
  objectModel - the object model
Parameters:
  set - a collection of parameter names HashMap



getDescriptor
protected Configuration getDescriptor(SourceResolver resolver, Map objectModel, Parameters parameters)(Code)
Load the descriptor containing the constraints.
Parameters:
  resolver -
Parameters:
  parameters - a Configuration containing the constraints or null if a problem occurred.



getSetOfParameterNamesFromSitemap
protected Collection getSetOfParameterNamesFromSitemap(String valstr, Map desc)(Code)
Get list of params to be validated from sitemap parameter and isolates the parameter names from the comma separated list.



indexConfiguration
protected Map indexConfiguration(Configuration[] descriptor)(Code)
Create an index map to an array of configurations by their name attribute. An empty array results in an empty map.
Parameters:
  descriptor - index map or empty map



isDescriptorReloadable
protected boolean isDescriptorReloadable()(Code)
Checks the default setting for reloading the descriptor file. boolean



isStringEncoded
abstract boolean isStringEncoded()(Code)
Are parameters encoded as strings? boolean



resolveConstraints
protected Collection resolveConstraints(String valsetstr, Map consets)(Code)
Recursively resolve constraint sets that may "include" other constraint sets and return a collection of all parameters to validate.
Parameters:
  valsetstr -
Parameters:
  consets - collection of all parameters to validate



setResult
protected Map setResult(Map objectModel, Map actionMap, Map resultMap, boolean allOK)(Code)
Add success indicator to resulting maps and clear actionMap if unsuccessful. Results are stored as request attributes.
Parameters:
  objectModel - the object model
Parameters:
  actionMap - a Map containing validated parameters
Parameters:
  resultMap - a Map containing validation results
Parameters:
  allOK - a boolean indicating if all validations were successful actionMap if allOK or null otherwise



validateParameter
public ValidatorActionHelper validateParameter(String name, Configuration constraints, Map conf, Map params, boolean isString)(Code)
Try to validate given parameter.
Parameters:
  name - The name of the parameter to validate.
Parameters:
  constraints - Configuration of all constraints for thisparameter as taken from the description XML file.
Parameters:
  conf - Configuration of all parameters as taken from thedescription XML file.
Parameters:
  params - The map of parameters.
Parameters:
  isString - Indicates wheter given param to validate isstring (as taken from HTTP request for example) or wheteher itshould be regular instance of java.lang.Double, java.lang.Long,etc. The validated parameter.



validateParameter
public ValidatorActionHelper validateParameter(String name, String rule, Configuration constraints, Map conf, Map params, boolean isString)(Code)
Try to validate given parameter.
Parameters:
  name - The actual name of the parameter to validate.
Parameters:
  rule - The name of the parameter element that contains therule that should be used for validation.
Parameters:
  constraints - Configuration of all constraints for thisparameter as taken from the description XML file.
Parameters:
  conf - Configuration of all parameters as taken from thedescription XML file.
Parameters:
  params - The map of parameters.
Parameters:
  isString - Indicates wheter given param to validate isstring (as taken from HTTP request for example) or wheteher itshould be regular instance of java.lang.Double, java.lang.Long,etc. The validated parameter.



validateSetOfParameters
protected boolean validateSetOfParameters(Map desc, Map actionMap, Map resultMap, Collection set, Map params, boolean isString)(Code)
Validate all parameters in the set with the constraints contained in desc and the values from params. Validation details are in resultMap and successful validated parameters in resultMap.
Parameters:
  desc -
Parameters:
  actionMap -
Parameters:
  resultMap -
Parameters:
  set -
Parameters:
  params -
Parameters:
  isString - boolean all parameters ok or not



validateValue
protected ValidatorActionHelper validateValue(String name, Configuration constraints, Configuration conf, Map params, boolean isString, String type)(Code)
Validate a single parameter value.
Parameters:
  name - String holding the name of the parameter
Parameters:
  constraints - Configuration holding the constraint set configuration for the parameter
Parameters:
  conf - Configuration holding the parameter configuration
Parameters:
  params - Map of parameter values to be validated
Parameters:
  isString - boolean indicating if the value is string encoded
Parameters:
  type - string holding the name of the datatype to validate value ValidatorActionHelper



Methods inherited from org.apache.cocoon.acting.AbstractComplementaryConfigurableAction
protected Configuration getConfiguration(String descriptor) throws ConfigurationException(Code)(Java Doc)
protected Configuration getConfiguration(String descriptor, boolean reloadable) throws ConfigurationException(Code)(Java Doc)
protected Configuration getConfiguration(String descriptor, SourceResolver resolver, boolean reloadable) throws ConfigurationException(Code)(Java Doc)

Fields inherited from org.apache.cocoon.acting.ConfigurableServiceableAction
protected ServiceManager manager(Code)(Java Doc)

Methods inherited from org.apache.cocoon.acting.ConfigurableServiceableAction
public void service(ServiceManager manager) throws ServiceException(Code)(Java Doc)

Fields inherited from org.apache.cocoon.acting.AbstractConfigurableAction
protected HashMap settings(Code)(Java Doc)

Methods inherited from org.apache.cocoon.acting.AbstractConfigurableAction
public void configure(Configuration conf) throws ConfigurationException(Code)(Java Doc)

Fields inherited from org.apache.cocoon.acting.AbstractAction
final protected static Map EMPTY_MAP(Code)(Java Doc)


www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.