Merge branch 'reporting2' into 'master'

Refactor event publishing configs

See merge request entgra/carbon-device-mgt!492
feature/appm-store/pbac
Dharmakeerthi Lasantha 5 years ago
commit 89469e8f61

@ -281,7 +281,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
DeviceManagementDAOFactory.commitTransaction(); DeviceManagementDAOFactory.commitTransaction();
String reportingHost = HttpReportingUtil.getReportingHost(); String reportingHost = HttpReportingUtil.getReportingHost();
if (!StringUtils.isBlank(reportingHost)) { if (!StringUtils.isBlank(reportingHost) && HttpReportingUtil.isPublishingEnabledForTenant()) {
DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper(); DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper();
deviceDetailsWrapper.setTenantId(tenantId); deviceDetailsWrapper.setTenantId(tenantId);
deviceDetailsWrapper.setDevice(device); deviceDetailsWrapper.setDevice(device);

@ -69,7 +69,6 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
private static final Log log = LogFactory.getLog(DeviceInformationManagerImpl.class); 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 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 DEVICE_INFO_EVENT_STREAM_DEFINITION = "org.wso2.iot.DeviceInfoStream";
private static final String IS_EVENT_PUBLISHING_ENABED = "isEventPublishingEnabled";
public DeviceInformationManagerImpl() { public DeviceInformationManagerImpl() {
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
@ -183,7 +182,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
private void publishEvents(Device device, DeviceInfo deviceInfo) { private void publishEvents(Device device, DeviceInfo deviceInfo) {
String reportingHost = HttpReportingUtil.getReportingHost(); String reportingHost = HttpReportingUtil.getReportingHost();
if (!StringUtils.isBlank(reportingHost) && isPublishingEnabledForTenant()) { if (!StringUtils.isBlank(reportingHost)
&& HttpReportingUtil.isPublishingEnabledForTenant()) {
try { try {
DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper(); DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper();
deviceDetailsWrapper.setDevice(device); 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 @Override
public DeviceInfo getDeviceInfo(DeviceIdentifier deviceId) throws DeviceDetailsMgtException { public DeviceInfo getDeviceInfo(DeviceIdentifier deviceId) throws DeviceDetailsMgtException {
Device device = getDevice(deviceId); Device device = getDevice(deviceId);

@ -31,6 +31,8 @@ import java.io.IOException;
public class HttpReportingUtil { public class HttpReportingUtil {
private static final String IS_EVENT_PUBLISHING_ENABLED = "isEventPublishingEnabled";
public static String getReportingHost() { public static String getReportingHost() {
return System.getProperty(DeviceManagementConstants.Report.REPORTING_EVENT_HOST); return System.getProperty(DeviceManagementConstants.Report.REPORTING_EVENT_HOST);
} }
@ -49,4 +51,12 @@ public class HttpReportingUtil {
"invoking API. API endpoint: " + endpoint, e); "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;
}
} }

Loading…
Cancel
Save