if (before == 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.hasText(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
connector.create(task.getPropagationMode(), ObjectClass.ACCOUNT, 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(before.getName())
&& !before.getUid().getUidValue().equals(newName.getNameValue())) {
LOG.debug("Remote object name unchanged");
attributes.remove(newName);
}