*/
protected void handlePropertyDefinition(Element propertyDefinition, Class clazz, MutableBeanValidationConfiguration configuration) {
String propertyName = propertyDefinition.getAttribute(NAME_ATTR);
if (!StringUtils.hasText(propertyName)) {
logger.error("Could not parse property element. Missing or empty 'name' attribute");
throw new ValidationConfigurationException("Could not parse property element. Missing 'name' attribute");
}
PropertyDescriptor propertyDescriptor = BeanUtils.getPropertyDescriptor(clazz, propertyName);
if (propertyDescriptor == null) {
logger.error("Property '" + propertyName + "' does not exist in class '" + clazz.getName() + "'");
}
if (propertyDefinition.hasAttribute(CASCADE_ATTR) && "true".equals(propertyDefinition.getAttribute(CASCADE_ATTR)))
{
CascadeValidation cascadeValidation = new CascadeValidation(propertyName);
if (propertyDefinition.hasAttribute(CASCADE_CONDITION_ATTR)) {
String conditionExpression = propertyDefinition.getAttribute(CASCADE_CONDITION_ATTR);
cascadeValidation.setApplicabilityCondition(conditionExpressionParser.parse(conditionExpression));
}
configuration.addCascadeValidation(cascadeValidation);
}
NodeList nodes = propertyDefinition.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element ruleDefinition = (Element) node;
PropertyValidationElementHandler handler = handlerRegistry.findPropertyHandler(ruleDefinition, clazz, propertyDescriptor);
if (handler == null) {
logger.error("Could not handle element '" + ruleDefinition.getTagName() +
"'. Please make sure the proper validation rule definition handler is registered");
throw new ValidationConfigurationException("Could not handle element '" + ruleDefinition.getTagName() + "'");
}
handler.handle(ruleDefinition, propertyName, configuration);
}
}