Optimize multiple dis-enrollment

scope_role_map
Pramila Niroshan 1 year ago
parent 2d6e512fdf
commit 46090437f0

@ -1287,7 +1287,8 @@ public interface DeviceManagementService {
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT", httpMethod = "PUT",
value = "Remove Multiple Devices Specified by Device IDs and Device Type", value = "Remove Multiple Devices Specified by Device IDs and Device Type",
notes = "Deletes multiple devices of the specified device type specified by their device IDs and returns the status of the deletion operation.", notes = "Deletes multiple devices of the specified device type specified by their device IDs" +
" and returns the status of the dis-enrollment operation.",
tags = "Device Management", tags = "Device Management",
extensions = { extensions = {
@Extension(properties = { @Extension(properties = {
@ -1319,7 +1320,7 @@ public interface DeviceManagementService {
}) })
Response disenrollMultipleDevices(@ApiParam( Response disenrollMultipleDevices(@ApiParam(
name = "deviceTypeWithDeviceIds", name = "deviceTypeWithDeviceIds",
value = "The properties to advanced search devices.", value = "Device type and corresponding device IDs for disenrollment",
required = true) required = true)
DisenrollRequest deviceTypeWithDeviceIds); DisenrollRequest deviceTypeWithDeviceIds);
@GET @GET

@ -491,17 +491,22 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
List<DeviceIdentifier> failedToDisenrollDevices = new ArrayList<>(); List<DeviceIdentifier> failedToDisenrollDevices = new ArrayList<>();
Map<String, List<String>> list = deviceTypeWithDeviceIds.getDeviceTypeWithDeviceIds(); Map<String, List<String>> list = deviceTypeWithDeviceIds.getDeviceTypeWithDeviceIds();
String deviceType;
List<String> deviceIds;
DeviceIdentifier deviceIdentifier;
Device persistedDevice;
boolean response;
for (Map.Entry<String, List<String>> entry : list.entrySet()) { for (Map.Entry<String, List<String>> entry : list.entrySet()) {
String deviceType = entry.getKey(); deviceType = entry.getKey();
List<String> deviceIds = entry.getValue(); deviceIds = entry.getValue();
for (String deviceId : deviceIds) { for (String deviceId : deviceIds) {
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); deviceIdentifier = new DeviceIdentifier(deviceId, deviceType);
try { try {
Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, true); persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, true);
if (persistedDevice != null) { if (persistedDevice != null) {
boolean response = deviceManagementProviderService.disenrollDevice(deviceIdentifier); response = deviceManagementProviderService.disenrollDevice(deviceIdentifier);
if (response) { if (response) {
successfullyDisenrolledDevices.add(deviceIdentifier); successfullyDisenrolledDevices.add(deviceIdentifier);
} else { } else {
@ -509,6 +514,10 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
} }
} else { } else {
failedToDisenrollDevices.add(deviceIdentifier); failedToDisenrollDevices.add(deviceIdentifier);
if(log.isDebugEnabled()){
String msg = "Error encountered while dis-enrolling device of type: " + deviceType + " with " + deviceId;
log.error(msg);
}
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error encountered while dis-enrolling device of type: " + deviceType + " with " + deviceId; String msg = "Error encountered while dis-enrolling device of type: " + deviceType + " with " + deviceId;

Loading…
Cancel
Save