Merge pull request #751 from sinthuja/master

adding the if condition for only newRoles list iteration.
revert-70aa11f8
Megala Uthayakumar 7 years ago committed by GitHub
commit 47bdbc7c14

@ -367,7 +367,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
@Override
public void manageGroupSharing(int groupId, List<String> newRoles)
throws GroupManagementException, RoleDoesNotExistException {
if (newRoles != null) {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
UserStoreManager userStoreManager;
try {
@ -376,6 +375,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
tenantId).getUserStoreManager();
List<String> currentUserRoles = getRoles(groupId);
GroupManagementDAOFactory.beginTransaction();
if (newRoles != null) {
for (String role : newRoles) {
if (!userStoreManager.isExistingRole(role)) {
throw new RoleDoesNotExistException("Role '" + role + "' does not exists in the user store.");
@ -387,6 +387,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
groupDAO.addRole(groupId, role, tenantId);
}
}
}
for (String role : currentUserRoles) {
// Removing old roles from db which are not available in the new roles list.
groupDAO.removeRole(groupId, role, tenantId);
@ -402,9 +403,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} finally {
GroupManagementDAOFactory.closeConnection();
}
} else {
throw new GroupManagementException("No roles provided to complete the operation.");
}
}
/**

Loading…
Cancel
Save