diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java index c22a8ff44d7..cc82921cbc4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java @@ -281,7 +281,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem DeviceManagementDAOFactory.commitTransaction(); String reportingHost = HttpReportingUtil.getReportingHost(); - if (!StringUtils.isBlank(reportingHost)) { + if (!StringUtils.isBlank(reportingHost) && HttpReportingUtil.isPublishingEnabledForTenant()) { DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper(); deviceDetailsWrapper.setTenantId(tenantId); deviceDetailsWrapper.setDevice(device); 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 56d91b2d9f5..67e3ad4c9b4 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 @@ -69,7 +69,6 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { private static final Log log = LogFactory.getLog(DeviceInformationManagerImpl.class); private static final String LOCATION_EVENT_STREAM_DEFINITION = "org.wso2.iot.LocationStream"; private static final String DEVICE_INFO_EVENT_STREAM_DEFINITION = "org.wso2.iot.DeviceInfoStream"; - private static final String IS_EVENT_PUBLISHING_ENABED = "isEventPublishingEnabled"; public DeviceInformationManagerImpl() { this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); @@ -183,7 +182,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { private void publishEvents(Device device, DeviceInfo deviceInfo) { String reportingHost = HttpReportingUtil.getReportingHost(); - if (!StringUtils.isBlank(reportingHost) && isPublishingEnabledForTenant()) { + if (!StringUtils.isBlank(reportingHost) + && HttpReportingUtil.isPublishingEnabledForTenant()) { try { DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper(); deviceDetailsWrapper.setDevice(device); @@ -220,14 +220,6 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { } } - private boolean isPublishingEnabledForTenant() { - Object configuration = DeviceManagerUtil.getConfiguration(IS_EVENT_PUBLISHING_ENABED); - if (configuration != null) { - return Boolean.valueOf(configuration.toString()); - } - return false; - } - @Override public DeviceInfo getDeviceInfo(DeviceIdentifier deviceId) throws DeviceDetailsMgtException { Device device = getDevice(deviceId); 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 2d034d74f9a..920b4e4972e 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 @@ -31,6 +31,8 @@ import java.io.IOException; public class HttpReportingUtil { + private static final String IS_EVENT_PUBLISHING_ENABLED = "isEventPublishingEnabled"; + public static String getReportingHost() { return System.getProperty(DeviceManagementConstants.Report.REPORTING_EVENT_HOST); } @@ -49,4 +51,12 @@ public class HttpReportingUtil { "invoking API. API endpoint: " + endpoint, e); } } + + public static boolean isPublishingEnabledForTenant() { + Object configuration = DeviceManagerUtil.getConfiguration(IS_EVENT_PUBLISHING_ENABLED); + if (configuration != null) { + return Boolean.valueOf(configuration.toString()); + } + return false; + } }