From 6901747aeb0c5c8cb6d32918c01ffbdb36aa7015 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Thu, 10 Oct 2019 15:55:45 +0530 Subject: [PATCH] Add null and empty check for device location related values --- .../android/services/impl/DeviceManagementServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java index f875b942bd..fb9a3f2bd4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java @@ -34,6 +34,7 @@ */ package org.wso2.carbon.mdm.services.android.services.impl; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Device; @@ -501,7 +502,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } if (propertyName.equals("ALTITUDE")) { altitude = property.getValue(); - } if (propertyName.equals("SPEED")) { speed = property.getValue(); @@ -514,7 +514,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } } - if (!latitude.isEmpty() && !longitude.isEmpty()) { + if (StringUtils.isNotBlank(latitude) && StringUtils.isNotBlank(longitude) && + StringUtils.isNotBlank(altitude) && StringUtils.isNotBlank(speed) && + StringUtils.isNotBlank(bearing) && StringUtils.isNotBlank(distance)) { location = new DeviceLocation(); location.setLatitude(Double.valueOf(latitude)); location.setLongitude(Double.valueOf(longitude));