mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Default values set for push notification dynamic configuration
This commit is contained in:
parent
f511dc2bce
commit
9995f4293e
@ -85,7 +85,7 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
|
|||||||
} else {
|
} else {
|
||||||
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
|
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
|
||||||
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType()
|
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType()
|
||||||
+ "/" + operation.getCode();
|
.toString().toLowerCase() + "/" + operation.getCode();
|
||||||
dynamicProperties.put("topic", topic);
|
dynamicProperties.put("topic", topic);
|
||||||
if (operation.getPayLoad() == null) {
|
if (operation.getPayLoad() == null) {
|
||||||
operation.setPayLoad("");
|
operation.setPayLoad("");
|
||||||
|
|||||||
@ -143,7 +143,8 @@
|
|||||||
org.wso2.carbon.event.output.adapter.core,
|
org.wso2.carbon.event.output.adapter.core,
|
||||||
org.wso2.carbon.event.output.adapter.core.exception,
|
org.wso2.carbon.event.output.adapter.core.exception,
|
||||||
org.osgi.framework,
|
org.osgi.framework,
|
||||||
org.wso2.carbon.core
|
org.wso2.carbon.core,
|
||||||
|
org.wso2.carbon.device.mgt.common.*
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</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_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());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ public final class XMPPAdapterConstants {
|
|||||||
public static final String SUBJECT_PROPERTY_KEY = "subject";
|
public static final String SUBJECT_PROPERTY_KEY = "subject";
|
||||||
public static final String MESSAGE_TYPE_PROPERTY_KEY = "messageType";
|
public static final String MESSAGE_TYPE_PROPERTY_KEY = "messageType";
|
||||||
public static final String CHAT_PROPERTY_KEY = "chat";
|
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_HOST = "host";
|
||||||
public static final String XMPP_ADAPTER_PROPERTY_PORT = "port";
|
public static final String XMPP_ADAPTER_PROPERTY_PORT = "port";
|
||||||
public static final String XMPP_ADAPTER_PROPERTY_USERNAME = "username";
|
public static final String XMPP_ADAPTER_PROPERTY_USERNAME = "username";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user