Merge pull request 'Fix group update issue' (#19) from vigneshan/device-mgt-core:fix/group-update-issue into master

Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/19
This commit is contained in:
Pahansith Gunathilake 2022-11-24 11:44:29 +00:00
commit d68c5e04bd

View File

@ -194,8 +194,8 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
GroupManagementDAOFactory.beginTransaction(); GroupManagementDAOFactory.beginTransaction();
DeviceGroup existingGroup = this.groupDAO.getGroup(groupId, tenantId); DeviceGroup existingGroup = this.groupDAO.getGroup(groupId, tenantId);
if (existingGroup != null) { if (existingGroup != null) {
boolean existingGroupName = this.groupDAO.getGroup(deviceGroup.getName(), tenantId) != null; DeviceGroup existingGroupByName = this.groupDAO.getGroup(deviceGroup.getName(), tenantId);
if (existingGroupName) { if (existingGroupByName != null && existingGroupByName.getGroupId() != groupId) {
throw new GroupAlreadyExistException("Group already exists with name '" + deviceGroup.getName() + "'."); throw new GroupAlreadyExistException("Group already exists with name '" + deviceGroup.getName() + "'.");
} }
List<DeviceGroup> groupsToUpdate = new ArrayList<>(); List<DeviceGroup> groupsToUpdate = new ArrayList<>();