mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Optimize multiple dis-enrollment
This commit is contained in:
parent
2d6e512fdf
commit
46090437f0
@ -1287,7 +1287,8 @@ public interface DeviceManagementService {
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "PUT",
|
||||
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",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ -1319,7 +1320,7 @@ public interface DeviceManagementService {
|
||||
})
|
||||
Response disenrollMultipleDevices(@ApiParam(
|
||||
name = "deviceTypeWithDeviceIds",
|
||||
value = "The properties to advanced search devices.",
|
||||
value = "Device type and corresponding device IDs for disenrollment",
|
||||
required = true)
|
||||
DisenrollRequest deviceTypeWithDeviceIds);
|
||||
@GET
|
||||
|
||||
@ -491,17 +491,22 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
List<DeviceIdentifier> failedToDisenrollDevices = new ArrayList<>();
|
||||
|
||||
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()) {
|
||||
String deviceType = entry.getKey();
|
||||
List<String> deviceIds = entry.getValue();
|
||||
deviceType = entry.getKey();
|
||||
deviceIds = entry.getValue();
|
||||
|
||||
for (String deviceId : deviceIds) {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType);
|
||||
deviceIdentifier = new DeviceIdentifier(deviceId, deviceType);
|
||||
try {
|
||||
Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, true);
|
||||
persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, true);
|
||||
if (persistedDevice != null) {
|
||||
boolean response = deviceManagementProviderService.disenrollDevice(deviceIdentifier);
|
||||
response = deviceManagementProviderService.disenrollDevice(deviceIdentifier);
|
||||
if (response) {
|
||||
successfullyDisenrolledDevices.add(deviceIdentifier);
|
||||
} else {
|
||||
@ -509,6 +514,10 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
String msg = "Error encountered while dis-enrolling device of type: " + deviceType + " with " + deviceId;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user