return null;
}
}
}
/* perform actual validation */
ValidatorActionHelper result = null;
String name = null;
HashMap params = new HashMap (rparams.length);
/* put required params into hash */
for (int i = 0; i < rparams.length; i ++) {
name = rparams[i];
if (name == null || "".equals (name.trim ())) {
if (getLogger().isDebugEnabled()) {
getLogger().debug ("Wrong syntax of the 'validate' parameter");
}
return null;
}
name = name.trim ();
params.put (name, req.getParameter (name));
}
for (int i = 0; i < rparams.length; i ++) {
name = rparams[i].trim ();
result = validateParameter (name, null, desc,
params, true);
if (!result.isOK()) {
if (getLogger().isDebugEnabled()) {
getLogger().debug ("Validation failed for parameter " + name);
}
allOK = false;
}
actionMap.put (name, result.getObject());
resultMap.put (name, result.getResult());
}
}
/*
* new set-based method
*/
if (!"".equals (valsetstr.trim ())) {
if (getLogger().isDebugEnabled()) {
getLogger().debug ("Validating parameters "
+ "from given constraint-set " + valsetstr);
}
// go over all constraint sets
// untill the requested set is found
// set number will be in j
Configuration cset = null;
String setname = null;
int j = 0;
boolean found = false;
for (j = 0; j < csets.length; j ++) {
setname = csets[j].getAttribute ("name", "");
if (valsetstr.trim().equals (setname.trim ())) {
found = true;
break;
}
}
if (!found) {
if (getLogger().isDebugEnabled()) {
getLogger().debug ("Given set "
+ valsetstr
+ " does not exist in a description file");
}
return null;
}
cset = csets[j];
/* get the list of params to be validated */
Configuration[] set = cset.getChildren ("validate");
/* perform actuall validation */
ValidatorActionHelper result = null;
String name = null;
HashMap params = new HashMap (set.length);
if (getLogger().isDebugEnabled()) {
getLogger().debug ("Given set "
+ valsetstr
+ " contains " + set.length + " rules");
}
/* put required params into hash */
for (int i = 0; i < set.length; i ++) {
name = set[i].getAttribute ("name", "").trim();
if ("".equals(name)) {
if (getLogger().isDebugEnabled()) {
getLogger().debug ("Wrong syntax "
+ " of 'validate' children nr. " + i);
}
return null;
}
Object[] values = req.getParameterValues(name);
if (values != null) {
switch (values.length) {
case 0: params.put(name,null); break;
case 1: params.put(name,values[0]); break;
default: params.put(name,values);
}
} else {
params.put(name,values);
}
}
String rule = null;
for (int i = 0; i < set.length; i ++) {
name = set[i].getAttribute ("name", null);
rule = set[i].getAttribute("rule",name);
result = validateParameter (name, rule, set[i],
desc, params, true);
if (!result.isOK()) {
if (getLogger().isDebugEnabled()) {
getLogger().debug ("Validation failed for parameter " + name);
}
allOK = false;
}
actionMap.put (name, result.getObject());
resultMap.put (name, result.getResult());
}
}
if (!allOK) {