From 9f6eaedbc333294014a26ce665dcbc5849d17b44 Mon Sep 17 00:00:00 2001 From: Rushdi Date: Sun, 13 Mar 2022 00:19:51 +0530 Subject: [PATCH] check if location publishing to traccar enable or disabled --- .../details/mgt/impl/DeviceInformationManagerImpl.java | 6 ++++-- .../carbon/device/mgt/core/util/HttpReportingUtil.java | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) 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; + } }