From 289987db8ebaa22ba6042c750d6aca374e323c4c Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Wed, 7 Dec 2016 12:05:48 +0530 Subject: [PATCH 1/2] Throwing exception on getDevice when device is not found --- .../core/service/DeviceManagementProviderServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 aa6a9ba080..fff5607ecf 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 @@ -823,11 +823,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.openConnection(); device = deviceDAO.getDevice(deviceId, this.getTenantId()); if (device == null) { + String msg = "No device is found upon the type '" + deviceId.getType() + "' and id '" + + deviceId.getId() + "'"; if (log.isDebugEnabled()) { - log.debug("No device is found upon the type '" + deviceId.getType() + "' and id '" + - deviceId.getId() + "'"); + log.debug(msg); } - return null; + throw new DeviceManagementException(msg); } DeviceInfo info = deviceInfoDAO.getDeviceInformation(device.getId()); DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId()); From 4e0730f50c8165b58e9e2361cabb5d1c784b09d2 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Wed, 7 Dec 2016 12:06:22 +0530 Subject: [PATCH 2/2] Fixing device identifier is null issue --- .../device/type/deployer/template/dao/DeviceTypePluginDAO.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java index ee4f6071b7..163ac64711 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java @@ -67,6 +67,7 @@ public class DeviceTypePluginDAO { if (resultSet.next()) { device = new Device(); + device.setDeviceIdentifier(deviceId); if (log.isDebugEnabled()) { log.debug(deviceId + " data has been fetched from " + deviceDAODefinition.getDeviceTableName() + " database.");