if (beforeObj == null) {
// 1. get accountId
final String accountId = task.getAccountId();
// 2. get name
final Name name = (Name) AttributeUtil.find(Name.NAME, attributes);
// 3. check if:
// * accountId is not blank;
// * accountId is not equal to Name.
if (StringUtils.isNotBlank(accountId) && (name == null || !accountId.equals(name.getNameValue()))) {
// 3.a retrieve uid
final Uid uid = (Uid) AttributeUtil.find(Uid.NAME, attributes);
// 3.b add Uid if not provided
if (uid == null) {
attributes.add(AttributeBuilder.build(Uid.NAME, Collections.singleton(accountId)));
}
}
// 4. provision entry
LOG.debug("Create {} on {}", attributes, task.getResource().getName());
connector.create(task.getPropagationMode(), new ObjectClass(task.getObjectClassName()),
attributes, null, propagationAttempted);
} else {
// 1. check if rename is really required
final Name newName = (Name) AttributeUtil.find(Name.NAME, attributes);
LOG.debug("Rename required with value {}", newName);
if (newName != null && newName.equals(beforeObj.getName())
&& !newName.getNameValue().equals(beforeObj.getUid().getUidValue())) {
LOG.debug("Remote object name unchanged");
attributes.remove(newName);
}