}
public PropagationByResource update(final SyncopeRole role, final RoleMod roleMod) {
PropagationByResource propByRes = new PropagationByResource();
SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
Set<String> currentResources = role.getResourceNames();
// name
SyncopeClientException invalidRoles = new SyncopeClientException(SyncopeClientExceptionType.InvalidRoles);
if (roleMod.getName() != null) {
SyncopeRole otherRole = roleDAO.find(roleMod.getName(),
role.getParent() == null ? null : role.getParent().getId());
if (otherRole == null || role.equals(otherRole)) {
if (!roleMod.getName().equals(role.getName())) {
propByRes.addAll(ResourceOperation.UPDATE, currentResources);
for (String resource : currentResources) {
propByRes.addOldAccountId(resource, role.getName());
}
role.setName(roleMod.getName());
}
} else {
LOG.error("Another role exists with the same name and the same parent role: " + otherRole);
invalidRoles.addElement(roleMod.getName());
scce.addException(invalidRoles);
}
}
if (roleMod.getInheritOwner() != null) {
role.setInheritOwner(roleMod.getInheritOwner());