Refactor event publishing configs

feature/appm-store/pbac
inoshperera 5 years ago
parent 91fbb28de6
commit 90e90b46d6

@ -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);

@ -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);

@ -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;
}
}

Loading…
Cancel
Save