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