Search in sources :

Example 1 with MidpointFormValidator

use of com.evolveum.midpoint.web.util.validation.MidpointFormValidator in project midpoint by Evolveum.

the class PageAdminObjectDetails method performCustomValidation.

protected Collection<SimpleValidationError> performCustomValidation(PrismObject<O> object, Collection<ObjectDelta<? extends ObjectType>> deltas) throws SchemaException {
    Collection<SimpleValidationError> errors = null;
    if (object == null) {
        if (getObjectWrapper() != null && getObjectWrapper().getObject() != null) {
            // otherwise original object could get corrupted e.g. by applying the delta below
            object = getObjectWrapper().getObject().clone();
            for (ObjectDelta delta : deltas) {
                // because among deltas there can be also ShadowType deltas
                if (UserType.class.isAssignableFrom(delta.getObjectTypeClass())) {
                    delta.applyTo(object);
                }
            }
        }
    } else {
        object = object.clone();
    }
    performAdditionalValidation(object, deltas, errors);
    for (MidpointFormValidator validator : getFormValidatorRegistry().getValidators()) {
        if (errors == null) {
            errors = validator.validateObject(object, deltas);
        } else {
            errors.addAll(validator.validateObject(object, deltas));
        }
    }
    return errors;
}
Also used : SimpleValidationError(com.evolveum.midpoint.web.util.validation.SimpleValidationError) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) MidpointFormValidator(com.evolveum.midpoint.web.util.validation.MidpointFormValidator)

Aggregations

ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 MidpointFormValidator (com.evolveum.midpoint.web.util.validation.MidpointFormValidator)1 SimpleValidationError (com.evolveum.midpoint.web.util.validation.SimpleValidationError)1