From 9998ec3669aa2d904e0158dfe5eab2bd0ae117c4 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Wed, 30 Sep 2020 18:14:57 +0530 Subject: [PATCH] Allow other statuses to update the device status --- .../DeviceManagementProviderServiceImpl.java | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 7413d3f6e4..b5333d9677 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -2744,24 +2744,16 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return false; //New status is similar to current } int tenantId = this.getTenantId(); - switch (newStatus) { - case ACTIVE: + if (EnrolmentInfo.Status.REMOVED == newStatus) { + isDeviceUpdated = disenrollDevice(deviceIdentifier); + } else { + enrolmentInfo = device.getEnrolmentInfo(); + if (enrolmentInfo.getStatus() != newStatus) { + enrolmentInfo.setStatus(newStatus); isDeviceUpdated = updateEnrollment(deviceId, enrolmentInfo, tenantId); - break; - case INACTIVE: - enrolmentInfo = device.getEnrolmentInfo(); - if (enrolmentInfo.getStatus() != newStatus) { - enrolmentInfo.setStatus(newStatus); - isDeviceUpdated = updateEnrollment(deviceId, enrolmentInfo, tenantId); - } else { - isDeviceUpdated = false; - } - break; - case REMOVED: - isDeviceUpdated = disenrollDevice(deviceIdentifier); - break; - default: - throw new DeviceManagementException("Invalid status retrieved. Status : " + newStatus); + } else { + isDeviceUpdated = false; + } } return isDeviceUpdated; }