From 58b2bf8b3c33e1d74a332650fc56f7da3c3a80e5 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Fri, 16 Jun 2017 15:23:41 +0530 Subject: [PATCH] fixing the agent unable to enroll issue --- .../DeviceManagementProviderServiceImpl.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 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 8969b0e0c3..6543f4bda9 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 @@ -335,23 +335,25 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } return false; } - try { - int tenantId = this.getTenantId(); - Device device = this.getDevice(deviceId, false); - if (device == null) { - if (log.isDebugEnabled()) { - log.debug("Device not found for id '" + deviceId.getId() + "'"); - } - return false; + int tenantId = this.getTenantId(); + + Device device = this.getDevice(deviceId, false); + if (device == null) { + if (log.isDebugEnabled()) { + log.debug("Device not found for id '" + deviceId.getId() + "'"); } + return false; + } - if (device.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.REMOVED)) { - if (log.isDebugEnabled()) { - log.debug("Device has already disenrolled : " + deviceId.getId() + "'"); - } - return false; + if (device.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.REMOVED)) { + if (log.isDebugEnabled()) { + log.debug("Device has already disenrolled : " + deviceId.getId() + "'"); } + return true; + } + + try { device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime()); device.getEnrolmentInfo().setStatus(EnrolmentInfo.Status.REMOVED); DeviceManagementDAOFactory.beginTransaction();