From 1a29a9f58ff9b4718dac90f2357d728eb2e5a884 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 2 Jun 2016 23:44:46 +0530 Subject: [PATCH] Further fixing retrieving application list with device info --- .../org/wso2/carbon/device/mgt/common/Device.java | 4 +++- .../DeviceManagementProviderServiceImpl.java | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java index c3e1d8a90db..04df8c7dcdc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java @@ -62,9 +62,11 @@ public class Device implements Serializable { private List properties; @ApiModelProperty(name = "advanceInfo", value = "This defines the device registration related information. " + - "It is mandatory to define this information.", required = true) + "It is mandatory to define this information.", required = false) private DeviceInfo deviceInfo; + @ApiModelProperty(name = "applications", value = "This represents the application list installed into the device", + required = false) private List applications; public Device() { 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 916865509df..4917af2a440 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 @@ -539,6 +539,20 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.closeConnection(); } device.setDeviceInfo(info); + + try { + DeviceManagementDAOFactory.openConnection(); + List applications = applicationDAO.getInstalledApplications(device.getId()); + device.setApplications(applications); + } catch (DeviceManagementDAOException e) { + log.error("Error occurred while retrieving the application list of '" + device.getType() + "', " + + "which carries the id '" + device.getId() + "'", e); + } catch (SQLException e) { + log.error("Error occurred while opening a connection to the data source", e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + DeviceManager deviceManager = this.getDeviceManager(device.getType()); if (deviceManager == null) { if (log.isDebugEnabled()) {