@Component
public class DerivedSchemaDataBinder {
private AbstractDerSchema populate(final AbstractDerSchema derSchema, final DerivedSchemaTO derSchemaTO) {
SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
if (StringUtils.isBlank(derSchemaTO.getExpression())) {
SyncopeClientException requiredValuesMissing =
new SyncopeClientException(SyncopeClientExceptionType.RequiredValuesMissing);
requiredValuesMissing.addElement("expression");
scce.addException(requiredValuesMissing);
} else if (!JexlUtil.isExpressionValid(derSchemaTO.getExpression())) {
SyncopeClientException invalidMandatoryCondition = new SyncopeClientException(
SyncopeClientExceptionType.InvalidValues);
invalidMandatoryCondition.addElement(derSchemaTO.getExpression());
scce.addException(invalidMandatoryCondition);
}
if (scce.hasExceptions()) {
throw scce;
}
BeanUtils.copyProperties(derSchemaTO, derSchema);