From 485a0d3721f25f73e3603dbc4fe0ceb87151f645 Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Wed, 11 Oct 2017 16:53:25 +0530 Subject: [PATCH] Check for device info and persist when enrolling a device. --- .../service/DeviceManagementProviderServiceImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 552c10d12e..5d28eb34af 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 @@ -66,8 +66,11 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; import org.wso2.carbon.device.mgt.core.dao.EnrollmentDAO; +import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; +import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO; import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsMgtDAOException; +import org.wso2.carbon.device.mgt.core.device.details.mgt.impl.DeviceInformationManagerImpl; import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; @@ -272,6 +275,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.closeConnection(); } + if (device.getDeviceInfo() != null) { + DeviceInformationManager deviceInformationManager = new DeviceInformationManagerImpl(); + try { + deviceInformationManager.addDeviceInfo(deviceIdentifier, device.getDeviceInfo()); + } catch (DeviceDetailsMgtException e) { + e.printStackTrace(); + } + } + if (log.isDebugEnabled()) { log.debug("An enrolment is successfully created with the id '" + enrolmentId + "' associated with " + "the device identified by key '" + device.getDeviceIdentifier() + "', which belongs to " +