LOG.error("Invalid resource name specified: {}, ignoring...", resourceName);
} else if (attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION).isEmpty()) {
LOG.warn("Requesting propagation for {} but no propagation mapping provided for {}",
attrUtil.getType(), resource);
} else {
PropagationTask task = new PropagationTask();
task.setResource(resource);
task.setObjectClassName(connObjectUtil.fromAttributable(subject).getObjectClassValue());
task.setSubjectType(attrUtil.getType());
if (!deleteOnResource) {
task.setSubjectId(subject.getId());
}
task.setPropagationOperation(operation);
task.setPropagationMode(resource.getPropagationMode());
task.setOldAccountId(propByRes.getOldAccountId(resource.getName()));
Map.Entry<String, Set<Attribute>> preparedAttrs = prepareAttributes(attrUtil, subject, password,
vAttrsToBeRemoved, vAttrsToBeUpdated, enable, resource);
task.setAccountId(preparedAttrs.getKey());
// Check if any of mandatory attributes (in the mapping) is missing or not received any value:
// if so, add special attributes that will be evaluated by PropagationTaskExecutor
List<String> mandatoryMissing = new ArrayList<String>();
List<String> mandatoryNullOrEmpty = new ArrayList<String>();
for (AbstractMappingItem item : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
if (!item.isAccountid()
&& JexlUtil.evaluateMandatoryCondition(item.getMandatoryCondition(), subject)) {
Attribute attr = AttributeUtil.find(item.getExtAttrName(), preparedAttrs.getValue());
if (attr == null) {
mandatoryMissing.add(item.getExtAttrName());
} else if (attr.getValue() == null || attr.getValue().isEmpty()) {
mandatoryNullOrEmpty.add(item.getExtAttrName());
}
}
}
if (!mandatoryMissing.isEmpty()) {
preparedAttrs.getValue().add(AttributeBuilder.build(
PropagationTaskExecutor.MANDATORY_MISSING_ATTR_NAME, mandatoryMissing));
}
if (!mandatoryNullOrEmpty.isEmpty()) {
preparedAttrs.getValue().add(AttributeBuilder.build(
PropagationTaskExecutor.MANDATORY_NULL_OR_EMPTY_ATTR_NAME, mandatoryNullOrEmpty));
}
task.setAttributes(preparedAttrs.getValue());
tasks.add(task);
LOG.debug("PropagationTask created: {}", task);
}
}