diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java index 57e672bd622..cde5bb1ff1a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java @@ -389,8 +389,10 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { //Traccar update GPS Location try { - DeviceManagementDataHolder.getInstance().getDeviceAPIClientService() - .updateLocation(device, deviceLocation); + if (HttpReportingUtil.isLocationPublishing()) { + DeviceManagementDataHolder.getInstance().getDeviceAPIClientService() + .updateLocation(device, deviceLocation); + } } catch (TraccarConfigurationException e) { log.error("Error on Traccar while adding GEO Location" + e); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/HttpReportingUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/HttpReportingUtil.java index 54877fdaa13..b3ee9523c27 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/HttpReportingUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/HttpReportingUtil.java @@ -34,6 +34,7 @@ public class HttpReportingUtil { private static final Log log = LogFactory.getLog(HttpReportingUtil.class); private static final String IS_EVENT_PUBLISHING_ENABLED = "isEventPublishingEnabled"; + private static final String IS_LOCATION_PUBLISHING_ENABLED = "isLocationPublishingEnabled"; public static String getReportingHost() { return System.getProperty(DeviceManagementConstants.Report.REPORTING_EVENT_HOST); @@ -62,4 +63,12 @@ public class HttpReportingUtil { } return false; } + + public static boolean isLocationPublishing() { + Object configuration = DeviceManagerUtil.getConfiguration(IS_LOCATION_PUBLISHING_ENABLED); + if (configuration != null) { + return Boolean.valueOf(configuration.toString()); + } + return false; + } }