mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
adding the if condition for only newRoles list iteration.
This commit is contained in:
parent
e7490dd278
commit
3340d94acf
@ -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…
Reference in New Issue
Block a user