*/
public static void checkValueConstraints(QPropertyDefinition pd, QValue[] values)
throws ConstraintViolationException, RepositoryException {
// check multi-value flag
if (!pd.isMultiple() && values != null && values.length > 1) {
throw new ConstraintViolationException("the property is not multi-valued");
}
QValueConstraint[] constraints = pd.getValueConstraints();
if (constraints == null || constraints.length == 0) {
// no constraints to check
return;
}
if (values != null && values.length > 0) {
// check value constraints on every value
for (QValue value : values) {
// constraints are OR-ed together
boolean satisfied = false;
ConstraintViolationException cve = null;
for (int j = 0; j < constraints.length && !satisfied; j++) {
try {
constraints[j].check(value);
satisfied = true;
} catch (ConstraintViolationException e) {
cve = e;
} catch (InvalidConstraintException e) {
cve = new ConstraintViolationException(e.getMessage(), e);
}
}
if (!satisfied) {
// re-throw last exception we encountered
throw cve;