protected void setRoleOwners(final RoleSyncResultHandler rhandler)
throws UnauthorizedRoleException, NotFoundException {
for (Map.Entry<Long, String> entry : rhandler.getRoleOwnerMap().entrySet()) {
RoleMod roleMod = new RoleMod();
roleMod.setId(entry.getKey());
if (StringUtils.isBlank(entry.getValue())) {
roleMod.setRoleOwner(null);
roleMod.setUserOwner(null);
} else {
Long userId = syncUtilities.findMatchingAttributableId(
ObjectClass.ACCOUNT,
entry.getValue(),
rhandler.getProfile().getSyncTask().getResource(),
rhandler.getProfile().getConnector());
if (userId == null) {
Long roleId = syncUtilities.findMatchingAttributableId(
ObjectClass.GROUP,
entry.getValue(),
rhandler.getProfile().getSyncTask().getResource(),
rhandler.getProfile().getConnector());
if (roleId != null) {
roleMod.setRoleOwner(new ReferenceMod(roleId));
}
} else {
roleMod.setUserOwner(new ReferenceMod(userId));
}
}
rwfAdapter.update(roleMod);
}