From do-not-reply at jboss.org Wed Feb 1 14:10:59 2012 Content-Type: multipart/mixed; boundary="===============2133378309388841146==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: gatein-commits at lists.jboss.org Subject: [gatein-commits] gatein SVN: r8349 - portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/validator. Date: Wed, 01 Feb 2012 14:10:59 -0500 Message-ID: <201202011910.q11JAx2l004873@svn01.web.mwc.hst.phx2.redhat.com> --===============2133378309388841146== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: chris.laprun(a)jboss.com Date: 2012-02-01 14:10:58 -0500 (Wed, 01 Feb 2012) New Revision: 8349 Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/validat= or/UserConfigurableValidator.java Log: - GTNPORTAL-1673: Added documentation. Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/= validator/UserConfigurableValidator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/valida= tor/UserConfigurableValidator.java 2012-02-01 18:56:16 UTC (rev 8348) +++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/valida= tor/UserConfigurableValidator.java 2012-02-01 19:10:58 UTC (rev 8349) @@ -38,7 +38,27 @@ import java.util.Properties; import java.util.regex.Pattern; = -/** @author Chris Laprun */ +/** + * A user-configurable validator. Several aspects of this validator can be= configured via properties in the + * configuration.properties file found in the GateIn configuration directo= ry (${gatein.conf.dir}. The validator + * supports several configurations that can be activated when a validator = instance is created by passing it the name of + * the configuration to be activated. A configuration is created by adding= an entry in configuration.properties using + * the {@link #KEY_PREFIX} prefix followed by the name of the configuratio= n, a period '.' and the name of the + * validation aspect to modify. + *

+ * Currently supported validation aspects, where {configuration} is a conf= iguration's name: + *

+ * + * Currently used configurations in the code are defined by the {@link #US= ERNAME} and {@link #GROUPMEMBERSHIP} names. + * + * @author Chris Laprun + */ @Serialized public class UserConfigurableValidator extends MultipleConditionsValidator { @@ -72,7 +92,7 @@ { // extract property key String propertyKey =3D key.substring(length, key.indexOf= ('.', length)); - if(!configurations.containsKey(propertyKey)) + if (!configurations.containsKey(propertyKey)) { configurations.put(propertyKey, new ValidatorConfigur= ation(propertyKey, properties)); } @@ -96,17 +116,17 @@ this(USERNAME, DEFAULT_LOCALIZATION_KEY); } = - public UserConfigurableValidator(String validatorName, String messageLo= calizationKey) + public UserConfigurableValidator(String configurationName, String messa= geLocalizationKey) { this.exceptionOnMissingMandatory =3D true; this.trimValue =3D true; localizationKey =3D messageLocalizationKey !=3D null ? messageLocali= zationKey : DEFAULT_LOCALIZATION_KEY; - this.validatorName =3D validatorName !=3D null ? validatorName : USE= RNAME; + this.validatorName =3D configurationName !=3D null ? configurationNa= me : USERNAME; } = - public UserConfigurableValidator(String validatorName) + public UserConfigurableValidator(String configurationName) { - this(validatorName, DEFAULT_LOCALIZATION_KEY); + this(configurationName, DEFAULT_LOCALIZATION_KEY); } = @Override @@ -161,10 +181,10 @@ boolean isUser =3D USERNAME.equals(propertyKey); String prefixedKey =3D KEY_PREFIX + propertyKey; = - String property =3D properties.getProperty(prefixedKey + ".min.le= ngth"); + String property =3D properties.getProperty(prefixedKey + ".length= .min"); minLength =3D property !=3D null ? Integer.valueOf(property) : (i= sUser ? UsernameValidator.DEFAULT_MIN_LENGTH : 0); = - property =3D properties.getProperty(prefixedKey + ".max.length"); + property =3D properties.getProperty(prefixedKey + ".length.max"); maxLength =3D property !=3D null ? Integer.valueOf(property) : (i= sUser ? UsernameValidator.DEFAULT_MAX_LENGTH : Integer.MAX_VALUE); = pattern =3D properties.getProperty(prefixedKey + ".regexp", Utils= .USER_NAME_VALIDATOR_REGEX); --===============2133378309388841146==--