From 664b3d4d43ddb6360e9da26f0a04904aede63120 Mon Sep 17 00:00:00 2001 From: charitha Date: Thu, 6 Oct 2016 20:32:09 +0530 Subject: [PATCH] Fix issue in duplicate mapping --- .../mgt/core/service/GroupManagementProviderServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 11ea959225..1753f9696a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -616,7 +616,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid if (device == null) { throw new DeviceNotFoundException("Device not found for id '" + deviceIdentifier.getId() + "'"); } - this.groupDAO.addDevice(groupId, device.getId(), tenantId); + if (!this.groupDAO.isDeviceMappedToGroup(groupId, device.getId(), tenantId)){ + this.groupDAO.addDevice(groupId, device.getId(), tenantId); + } } GroupManagementDAOFactory.commitTransaction(); } catch (DeviceManagementException e) {