Default values set for push notification dynamic configuration

4.x.x
ayyoob 8 years ago
parent f511dc2bce
commit 9995f4293e

@ -85,7 +85,7 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
} else {
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType()
+ "/" + operation.getCode();
.toString().toLowerCase() + "/" + operation.getCode();
dynamicProperties.put("topic", topic);
if (operation.getPayLoad() == null) {
operation.setPayLoad("");

@ -143,7 +143,8 @@
org.wso2.carbon.event.output.adapter.core,
org.wso2.carbon.event.output.adapter.core.exception,
org.osgi.framework,
org.wso2.carbon.core
org.wso2.carbon.core,
org.wso2.carbon.device.mgt.common.*
</Import-Package>
</instructions>
</configuration>

@ -39,8 +39,13 @@ public class XMPPNotificationStrategy implements NotificationStrategy {
private static final String XMPP_CLIENT_JID = "xmpp.client.jid";
private static final String XMPP_CLIENT_SUBJECT = "xmpp.client.subject";
public static final String XMPP_CLIENT_MESSAGE_TYPE = "xmpp.client.messageType";
private static final String DYNAMIC_PROPERTY_JID = "jid";
private static final String DYNAMIC_PROPERTY_SUBJECT = "subject";
private static final String DYNAMIC_PROPERTY_MSGTYPE = "messageType";
private String xmppAdapterName;
private static final Log log = LogFactory.getLog(XMPPNotificationStrategy.class);
private String subDomain;
public XMPPNotificationStrategy(PushNotificationConfig config) {
@ -61,6 +66,7 @@ public class XMPPNotificationStrategy implements NotificationStrategy {
xmppAdapterProperties.put(XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_JID, config.getProperty(
XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_JID));
outputEventAdapterConfiguration.setStaticProperties(xmppAdapterProperties);
subDomain = config.getProperty(XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_SUBDOMAIN);
try {
XMPPDataHolder.getInstance().getOutputEventAdapterService().create(outputEventAdapterConfiguration);
} catch (OutputEventAdapterException e) {
@ -77,9 +83,15 @@ public class XMPPNotificationStrategy implements NotificationStrategy {
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
Map<String, String> dynamicProperties = new HashMap<>();
Properties properties = ctx.getOperation().getProperties();
dynamicProperties.put("jid", properties.getProperty(XMPP_CLIENT_JID));
dynamicProperties.put("subject", properties.getProperty(XMPP_CLIENT_SUBJECT));
dynamicProperties.put("messageType", properties.getProperty(XMPP_CLIENT_MESSAGE_TYPE));
if (properties != null & properties.size() > 0) {
dynamicProperties.put(DYNAMIC_PROPERTY_JID, properties.getProperty(XMPP_CLIENT_JID));
dynamicProperties.put(DYNAMIC_PROPERTY_SUBJECT, properties.getProperty(XMPP_CLIENT_SUBJECT));
dynamicProperties.put(DYNAMIC_PROPERTY_MSGTYPE, properties.getProperty(XMPP_CLIENT_MESSAGE_TYPE));
} else {
dynamicProperties.put(DYNAMIC_PROPERTY_JID, ctx.getDeviceId().getId() + subDomain);
dynamicProperties.put(DYNAMIC_PROPERTY_SUBJECT, ctx.getOperation().getType().toString());
dynamicProperties.put(DYNAMIC_PROPERTY_MSGTYPE, XMPPAdapterConstants.CHAT_PROPERTY_KEY);
}
XMPPDataHolder.getInstance().getOutputEventAdapterService().publish(xmppAdapterName, dynamicProperties,
ctx.getOperation().getPayLoad());
}

@ -30,6 +30,7 @@ public final class XMPPAdapterConstants {
public static final String SUBJECT_PROPERTY_KEY = "subject";
public static final String MESSAGE_TYPE_PROPERTY_KEY = "messageType";
public static final String CHAT_PROPERTY_KEY = "chat";
public static final String XMPP_ADAPTER_PROPERTY_SUBDOMAIN = "subDomain";
public static final String XMPP_ADAPTER_PROPERTY_HOST = "host";
public static final String XMPP_ADAPTER_PROPERTY_PORT = "port";
public static final String XMPP_ADAPTER_PROPERTY_USERNAME = "username";

Loading…
Cancel
Save