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 aae1a3a46d..2e611eb031 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 @@ -1390,12 +1390,11 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid if (deviceGroup == null) { String errorMessage = "Invalid Group ID provided."; log.error(errorMessage); -// throw new GroupManagementException(errorMessage, e); throw new GroupManagementException(errorMessage); } List devices = getAllDevicesOfGroup(deviceGroup.getName(), false); for (Device device : devices) { - if ( !DEVICE_STATUS_REMOVED.equals(device.getEnrolmentInfo().getStatus().toString()) + if (!DEVICE_STATUS_REMOVED.equals(device.getEnrolmentInfo().getStatus().toString()) && !deviceIDs.contains(device.getDeviceIdentifier())) { deviceIDs.add(device.getDeviceIdentifier()); allDevices.add(device); @@ -1403,20 +1402,20 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - for (Device device: allDevices){ - if (DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID.equals(device.getType())){ + for (Device device : allDevices) { + if (DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID.equals(device.getType())) { deviceTypesOfGroups.setHasAndroid(true); break; } } - for (Device device: allDevices){ - if (DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS.equals(device.getType())){ + for (Device device : allDevices) { + if (DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS.equals(device.getType())) { deviceTypesOfGroups.setHasIos(true); break; } } - for (Device device: allDevices){ - if (DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS.equals(device.getType())){ + for (Device device : allDevices) { + if (DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS.equals(device.getType())) { deviceTypesOfGroups.setHasWindows(true); break; } @@ -1431,47 +1430,4 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid return deviceTypesOfGroups; } -// DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID.equals(device.getType()) - - -// -// public static List convertStringToInteger(List list) throws BadRequestException { -// -// -// return groupsIDs; -// } -// -// public static List getDeviceIDsOfGroups(List groupIDs) throws InvalidGroupException, -// GroupDeviceException { -// -// try { -// GroupManagementProviderService groupManagementProviderService = AndroidDeviceManagementDataHolder -// .getInstance().getGroupManagementProviderService(); -// -// List deviceIDs = new ArrayList<>(); -// for (Integer groupID : groupIDs) { -// DeviceGroup deviceGroup = groupManagementProviderService.getGroup(groupID, false); -// if (deviceGroup == null) { -// String errorMessage = "Invalid Group ID provided."; -// log.error(errorMessage); -// throw new InvalidGroupException(errorMessage); -// } -// List devices = groupManagementProviderService.getAllDevicesOfGroup(deviceGroup.getName(), false); -// for (Device device : devices) { -// if (DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID.equals(device.getType()) -// && !AndroidConstants.DEVICE_STATUS_REMOVED.equals(device.getEnrolmentInfo().getStatus().toString()) -// && !deviceIDs.contains(device.getDeviceIdentifier())) { -// deviceIDs.add(device.getDeviceIdentifier()); -// } -// } -// } -// -// return deviceIDs; -// } catch (GroupManagementException e) { -// String errorMessage = "Error occurred getting group or device IDs ."; -// log.error(errorMessage, e); -// throw new GroupDeviceException(errorMessage, e); -// } -// } - }