Add push notification configurations for push notification stratagies

4.x.x
warunalakshitha 8 years ago
parent 3c1e4ba205
commit 65667119f9

@ -20,7 +20,12 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@ -112,7 +117,8 @@ public class DeviceTypeManagerService implements DeviceManagementService {
for (Property property : pushNotificationProvider.getConfigProperties().getProperty()) { for (Property property : pushNotificationProvider.getConfigProperties().getProperty()) {
staticProps.put(property.getName(), property.getValue()); staticProps.put(property.getName(), property.getValue());
} }
pushNotificationConfig = new PushNotificationConfig(pushNotificationProvider.getType(), staticProps); pushNotificationConfig = new PushNotificationConfig(pushNotificationProvider.getType(),
pushNotificationProvider.isScheduled(), staticProps);
} else { } else {
try { try {
PlatformConfiguration deviceTypeConfig = deviceManager.getConfiguration(); PlatformConfiguration deviceTypeConfig = deviceManager.getConfiguration();
@ -121,7 +127,8 @@ public class DeviceTypeManagerService implements DeviceManagementService {
if (configuration.size() > 0) { if (configuration.size() > 0) {
Map<String, String> properties = this.getConfigProperty(configuration); Map<String, String> properties = this.getConfigProperty(configuration);
pushNotificationConfig = new PushNotificationConfig( pushNotificationConfig = new PushNotificationConfig(
pushNotificationProvider.getType(), properties); pushNotificationProvider.getType(), pushNotificationProvider.isScheduled(),
properties);
} }
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {

@ -42,7 +42,7 @@ public class FCMNotificationStrategy implements NotificationStrategy {
private static final String FCM_API_KEY = "fcmAPIKey"; private static final String FCM_API_KEY = "fcmAPIKey";
private static final int TIME_TO_LIVE = 60; private static final int TIME_TO_LIVE = 60;
private static final int HTTP_STATUS_CODE_OK = 200; private static final int HTTP_STATUS_CODE_OK = 200;
private PushNotificationConfig config; private final PushNotificationConfig config;
public FCMNotificationStrategy(PushNotificationConfig config) { public FCMNotificationStrategy(PushNotificationConfig config) {
this.config = config; this.config = config;
@ -133,4 +133,9 @@ public class FCMNotificationStrategy implements NotificationStrategy {
return fcmToken; return fcmToken;
} }
@Override
public PushNotificationConfig getConfig() {
return config;
}
} }

@ -45,8 +45,10 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
private static final String MQTT_ADAPTER_TOPIC = "mqtt.adapter.topic"; private static final String MQTT_ADAPTER_TOPIC = "mqtt.adapter.topic";
private String mqttAdapterName; private String mqttAdapterName;
private static final Log log = LogFactory.getLog(MQTTNotificationStrategy.class); private static final Log log = LogFactory.getLog(MQTTNotificationStrategy.class);
private final PushNotificationConfig config;
public MQTTNotificationStrategy(PushNotificationConfig config) { public MQTTNotificationStrategy(PushNotificationConfig 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); mqttAdapterName = config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_NAME);
@ -137,5 +139,10 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
MQTTDataHolder.getInstance().getOutputEventAdapterService().destroy(mqttAdapterName); MQTTDataHolder.getInstance().getOutputEventAdapterService().destroy(mqttAdapterName);
} }
@Override
public PushNotificationConfig getConfig() {
return config;
}
} }

@ -45,10 +45,12 @@ public class XMPPNotificationStrategy implements NotificationStrategy {
private String xmppAdapterName; private String xmppAdapterName;
private static final Log log = LogFactory.getLog(XMPPNotificationStrategy.class); private static final Log log = LogFactory.getLog(XMPPNotificationStrategy.class);
private String subDomain; private String subDomain;
private final PushNotificationConfig config;
public XMPPNotificationStrategy(PushNotificationConfig config) { public XMPPNotificationStrategy(PushNotificationConfig config) {
this.config = config;
OutputEventAdapterConfiguration outputEventAdapterConfiguration = new OutputEventAdapterConfiguration(); OutputEventAdapterConfiguration outputEventAdapterConfiguration = new OutputEventAdapterConfiguration();
xmppAdapterName = config.getProperty(XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_NAME); xmppAdapterName = config.getProperty(XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_NAME);
outputEventAdapterConfiguration.setName(xmppAdapterName); outputEventAdapterConfiguration.setName(xmppAdapterName);
@ -106,4 +108,8 @@ public class XMPPNotificationStrategy implements NotificationStrategy {
XMPPDataHolder.getInstance().getOutputEventAdapterService().destroy(xmppAdapterName); XMPPDataHolder.getInstance().getOutputEventAdapterService().destroy(xmppAdapterName);
} }
@Override
public PushNotificationConfig getConfig() {
return config;
}
} }

Loading…
Cancel
Save