adding the if condition for only newRoles list iteration.

revert-70aa11f8
sinthuja 8 years ago
parent e7490dd278
commit 3340d94acf

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

Loading…
Cancel
Save