diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java index 72ed8ecbb7..0eb13dee00 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java @@ -118,10 +118,11 @@ public interface DeviceManager { /** * Method to update device information. * + * @param deviceIdentifier identifier to identify the device * @param device Updated device information related data * @throws DeviceManagementException If some unusual behaviour is observed while updating the device info */ - boolean updateDeviceInfo(Device device) throws DeviceManagementException; + boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException; /** * Method to set the ownership type of a particular device. i.e. BYOD, COPE. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java index 88c35a15b2..80744ec6a8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java @@ -136,7 +136,16 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { DeviceManager dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.disenrollDevice(deviceId); + boolean status = dms.disenrollDevice(deviceId); + try { + org.wso2.carbon.device.mgt.core.dto.Device device = this.getDeviceDAO().getDevice(deviceId); + device.setStatus(Status.INACTIVE); + this.getDeviceDAO().updateDevice(device); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementException("Error occurred while modifying the device " + + "'" + deviceId.getId() + "'", e); + } + return status; } @Override @@ -378,10 +387,10 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ } @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { DeviceManager dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); - return dms.updateDeviceInfo(device); + return dms.updateDeviceInfo(deviceIdentifier, device); } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java index e4eb06186b..8cfd9ad0b5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java @@ -98,21 +98,21 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider(). - updateDeviceInfo(device); + updateDeviceInfo(deviceIdentifier, device); } @Override public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().setOwnership(deviceId, - ownershipType); + ownershipType); } @Override public License getLicense(String deviceType, String languageCode) throws LicenseManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getLicense(deviceType, - languageCode); + languageCode); } @Override