if (itemTO == null || itemTO.getIntMappingType() == null) {
LOG.error("Null mappingTO provided");
return null;
}
SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
SyncopeClientException requiredValuesMissing = new SyncopeClientException(
SyncopeClientExceptionType.RequiredValuesMissing);
if (itemTO.getIntAttrName() == null) {
if (IntMappingType.getEmbedded().contains(itemTO.getIntMappingType())) {
itemTO.setIntAttrName(itemTO.getIntMappingType().toString());
} else {
requiredValuesMissing.addElement("intAttrName");
}
}
// Throw composite exception if there is at least one element set
// in the composing exceptions
if (!requiredValuesMissing.isEmpty()) {
scce.addException(requiredValuesMissing);
}
// no mandatory condition implies mandatory condition false
if (!JexlUtil.isExpressionValid(itemTO.getMandatoryCondition() == null
? "false" : itemTO.getMandatoryCondition())) {
SyncopeClientException invalidMandatoryCondition = new SyncopeClientException(
SyncopeClientExceptionType.InvalidValues);
invalidMandatoryCondition.addElement(itemTO.getMandatoryCondition());
scce.addException(invalidMandatoryCondition);
}
if (scce.hasExceptions()) {
throw scce;
}
AbstractMappingItem item = (AbstractMappingItem) SerializationUtils.clone(prototype);
BeanUtils.copyProperties(itemTO, item, MAPPINGITEM_IGNORE_PROPERTIES);