Update pending operations status of device to be disenrolled

revert-dabc3590
Saad Sahibjan 5 years ago
parent bd8d89b53a
commit 281e0a636e

@ -455,6 +455,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
if (permanentDelete) { if (permanentDelete) {
result = AndroidAPIUtils.getDeviceManagementService().deleteDevice(deviceIdentifier); result = AndroidAPIUtils.getDeviceManagementService().deleteDevice(deviceIdentifier);
} else { } else {
AndroidDeviceUtils.updateDisEnrollOperationStatus(deviceIdentifier);
result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
} }
if (result) { if (result) {

@ -572,4 +572,25 @@ public class AndroidDeviceUtils {
} }
} }
/**
* Update status of pending operations to error when a dis-enroll operation is triggered.
*
* @param deviceIdentifier Identifier of the device
* @throws DeviceManagementException
*/
public static void updateDisEnrollOperationStatus(DeviceIdentifier deviceIdentifier)
throws DeviceManagementException {
try {
List<? extends Operation> pendingOperations = getPendingOperations(deviceIdentifier);
for (Operation operation : pendingOperations) {
operation.setStatus(Operation.Status.ERROR);
AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation);
}
} catch (OperationManagementException e) {
String msg = "Error occurred while retrieving pending operations to update operation statuses of " +
"device to be dis-enrolled";
log.error(msg);
throw new DeviceManagementException(msg, e);
}
}
} }

Loading…
Cancel
Save