From 65667119f9b97f137fdf2bfa499319b93f9fc2ec Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Tue, 25 Apr 2017 19:01:48 +0530 Subject: [PATCH] Add push notification configurations for push notification stratagies --- .../deployer/template/DeviceTypeManagerService.java | 13 ++++++++++--- .../provider/fcm/FCMNotificationStrategy.java | 7 ++++++- .../provider/mqtt/MQTTNotificationStrategy.java | 7 +++++++ .../provider/xmpp/XMPPNotificationStrategy.java | 6 ++++++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java index 64398d3715..fa1a844211 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java @@ -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.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.configuration.mgt.ConfigurationEntry; 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()) { staticProps.put(property.getName(), property.getValue()); } - pushNotificationConfig = new PushNotificationConfig(pushNotificationProvider.getType(), staticProps); + pushNotificationConfig = new PushNotificationConfig(pushNotificationProvider.getType(), + pushNotificationProvider.isScheduled(), staticProps); } else { try { PlatformConfiguration deviceTypeConfig = deviceManager.getConfiguration(); @@ -121,7 +127,8 @@ public class DeviceTypeManagerService implements DeviceManagementService { if (configuration.size() > 0) { Map properties = this.getConfigProperty(configuration); pushNotificationConfig = new PushNotificationConfig( - pushNotificationProvider.getType(), properties); + pushNotificationProvider.getType(), pushNotificationProvider.isScheduled(), + properties); } } } catch (DeviceManagementException e) { diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java index 6dd66f0836..da488c5435 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java @@ -42,7 +42,7 @@ public class FCMNotificationStrategy implements NotificationStrategy { private static final String FCM_API_KEY = "fcmAPIKey"; private static final int TIME_TO_LIVE = 60; private static final int HTTP_STATUS_CODE_OK = 200; - private PushNotificationConfig config; + private final PushNotificationConfig config; public FCMNotificationStrategy(PushNotificationConfig config) { this.config = config; @@ -133,4 +133,9 @@ public class FCMNotificationStrategy implements NotificationStrategy { return fcmToken; } + @Override + public PushNotificationConfig getConfig() { + return config; + } + } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java index 93be818999..8af53af6b2 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java @@ -45,8 +45,10 @@ public class MQTTNotificationStrategy implements NotificationStrategy { private static final String MQTT_ADAPTER_TOPIC = "mqtt.adapter.topic"; private String mqttAdapterName; private static final Log log = LogFactory.getLog(MQTTNotificationStrategy.class); + private final PushNotificationConfig config; public MQTTNotificationStrategy(PushNotificationConfig config) { + this.config = config; OutputEventAdapterConfiguration adapterConfig = new OutputEventAdapterConfiguration(); adapterConfig.setType(MQTTAdapterConstants.MQTT_ADAPTER_TYPE); mqttAdapterName = config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_NAME); @@ -137,5 +139,10 @@ public class MQTTNotificationStrategy implements NotificationStrategy { MQTTDataHolder.getInstance().getOutputEventAdapterService().destroy(mqttAdapterName); } + @Override + public PushNotificationConfig getConfig() { + return config; + } + } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java index 0d7229a193..af3a1c6c4b 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java @@ -45,10 +45,12 @@ public class XMPPNotificationStrategy implements NotificationStrategy { private String xmppAdapterName; private static final Log log = LogFactory.getLog(XMPPNotificationStrategy.class); private String subDomain; + private final PushNotificationConfig config; public XMPPNotificationStrategy(PushNotificationConfig config) { + this.config = config; OutputEventAdapterConfiguration outputEventAdapterConfiguration = new OutputEventAdapterConfiguration(); xmppAdapterName = config.getProperty(XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_NAME); outputEventAdapterConfiguration.setName(xmppAdapterName); @@ -106,4 +108,8 @@ public class XMPPNotificationStrategy implements NotificationStrategy { XMPPDataHolder.getInstance().getOutputEventAdapterService().destroy(xmppAdapterName); } + @Override + public PushNotificationConfig getConfig() { + return config; + } }