mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
added default configuration for tenant specific push notification provider
This commit is contained in:
parent
b36ff4b874
commit
ea48ee425c
@ -113,8 +113,12 @@ public class DeviceTypeManagerService implements DeviceManagementService {
|
|||||||
if (pushNotificationProvider != null) {
|
if (pushNotificationProvider != null) {
|
||||||
if (pushNotificationProvider.isFileBasedProperties()) {
|
if (pushNotificationProvider.isFileBasedProperties()) {
|
||||||
Map<String, String> staticProps = new HashMap<>();
|
Map<String, String> staticProps = new HashMap<>();
|
||||||
for (Property property : pushNotificationProvider.getConfigProperties().getProperty()) {
|
if (pushNotificationProvider.getConfigProperties() != null &&
|
||||||
staticProps.put(property.getName(), property.getValue());
|
pushNotificationProvider.getConfigProperties().getProperty() != null &&
|
||||||
|
pushNotificationProvider.getConfigProperties().getProperty().size() > 0) {
|
||||||
|
for (Property property : pushNotificationProvider.getConfigProperties().getProperty()) {
|
||||||
|
staticProps.put(property.getName(), property.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pushNotificationConfig = new PushNotificationConfig(pushNotificationProvider.getType(),
|
pushNotificationConfig = new PushNotificationConfig(pushNotificationProvider.getType(),
|
||||||
pushNotificationProvider.isScheduled(), staticProps);
|
pushNotificationProvider.isScheduled(), staticProps);
|
||||||
|
|||||||
@ -51,16 +51,14 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
OutputEventAdapterConfiguration adapterConfig = new OutputEventAdapterConfiguration();
|
OutputEventAdapterConfiguration adapterConfig = new OutputEventAdapterConfiguration();
|
||||||
adapterConfig.setType(MQTTAdapterConstants.MQTT_ADAPTER_TYPE);
|
adapterConfig.setType(MQTTAdapterConstants.MQTT_ADAPTER_TYPE);
|
||||||
mqttAdapterName = config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_NAME);
|
|
||||||
|
|
||||||
adapterConfig.setMessageFormat(MessageType.TEXT);
|
adapterConfig.setMessageFormat(MessageType.TEXT);
|
||||||
|
|
||||||
Map<String, String> configProperties = new HashMap<String, String>();
|
Map<String, String> configProperties = new HashMap<String, String>();
|
||||||
String brokerUrl = config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_BROKER_URL);
|
if (config.getProperties() != null && config.getProperties().size() > 0) {
|
||||||
if (brokerUrl != null && !brokerUrl.isEmpty()) {
|
String brokerUrl = config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_BROKER_URL);
|
||||||
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_BROKER_URL, brokerUrl);
|
if (brokerUrl != null && !brokerUrl.isEmpty()) {
|
||||||
}
|
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_BROKER_URL, brokerUrl);
|
||||||
if (config.getProperties() != null) {
|
}
|
||||||
mqttAdapterName = config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_NAME);
|
mqttAdapterName = config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_NAME);
|
||||||
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME,
|
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME,
|
||||||
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME));
|
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME));
|
||||||
@ -79,7 +77,14 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
|
|||||||
adapterConfig.setName(mqttAdapterName);
|
adapterConfig.setName(mqttAdapterName);
|
||||||
adapterConfig.setStaticProperties(configProperties);
|
adapterConfig.setStaticProperties(configProperties);
|
||||||
try {
|
try {
|
||||||
MQTTDataHolder.getInstance().getOutputEventAdapterService().create(adapterConfig);
|
synchronized (MQTTNotificationStrategy.class) {
|
||||||
|
try {
|
||||||
|
MQTTDataHolder.getInstance().getOutputEventAdapterService().isPolled(mqttAdapterName);
|
||||||
|
} catch (OutputEventAdapterException e) {
|
||||||
|
//event adapter not created
|
||||||
|
MQTTDataHolder.getInstance().getOutputEventAdapterService().create(adapterConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (OutputEventAdapterException e) {
|
} catch (OutputEventAdapterException e) {
|
||||||
throw new InvalidConfigurationException("Error occurred while initializing MQTT output event adapter", e);
|
throw new InvalidConfigurationException("Error occurred while initializing MQTT output event adapter", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user