From 20a9a98eb1addcecfee554fe7d761cf18278f0d7 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Tue, 18 Feb 2020 09:46:51 +0530 Subject: [PATCH] add reporting config --- .../mgt/core/DeviceManagementConstants.java | 1 + .../mgt/impl/DeviceInformationManagerImpl.java | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java index 2c57b78427..def109fd04 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java @@ -146,5 +146,6 @@ public final class DeviceManagementConstants { } public static final String REPORTING_CONTEXT = "/event"; public static final String DEVICE_INFO_ENDPOINT = REPORTING_CONTEXT + "/device-info"; + public static final String REPORTING_EVENT_HOST = "iot.reporting.event.host"; } } 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 191b16c946..4d479b5207 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 @@ -94,12 +94,17 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { device.getEnrolmentInfo().getId()); DeviceManagementDAOFactory.commitTransaction(); - DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper(); - deviceDetailsWrapper.setDevice(device); - deviceDetailsWrapper.setDeviceInfo(deviceInfo); - deviceDetailsWrapper.getJSONString(); - HttpReportingUtil.invokeApi(deviceDetailsWrapper.getJSONString(), - "http://localhost:8081" + DeviceManagementConstants.Report.DEVICE_INFO_ENDPOINT); + String reportingHost = System.getProperty(DeviceManagementConstants.Report + .REPORTING_EVENT_HOST); + if (reportingHost != null && !reportingHost.isEmpty()) { + DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper(); + deviceDetailsWrapper.setDevice(device); + deviceDetailsWrapper.setDeviceInfo(deviceInfo); + deviceDetailsWrapper.getJSONString(); + + HttpReportingUtil.invokeApi(deviceDetailsWrapper.getJSONString(), + reportingHost + DeviceManagementConstants.Report.DEVICE_INFO_ENDPOINT); + } //TODO :: This has to be fixed by adding the enrollment ID. if (DeviceManagerUtil.isPublishDeviceInfoResponseEnabled()) {