mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fixes to mqtt notification strategy when message body is null
This commit is contained in:
parent
a61be7a7ec
commit
86a45fec2e
@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt;
|
|||||||
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.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
||||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
@ -77,17 +78,22 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
|
|||||||
@Override
|
@Override
|
||||||
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();
|
Operation operation = ctx.getOperation();
|
||||||
|
Properties properties = operation.getProperties();
|
||||||
if (properties != null && properties.get(MQTT_ADAPTER_TOPIC) != null) {
|
if (properties != null && properties.get(MQTT_ADAPTER_TOPIC) != null) {
|
||||||
dynamicProperties.put("topic", (String) properties.get(MQTT_ADAPTER_TOPIC));
|
dynamicProperties.put("topic", (String) properties.get(MQTT_ADAPTER_TOPIC));
|
||||||
} else {
|
} else {
|
||||||
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
|
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
|
||||||
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + ctx.getOperation().getType();
|
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType()
|
||||||
|
+ "/" + operation.getCode();
|
||||||
dynamicProperties.put("topic", topic);
|
dynamicProperties.put("topic", topic);
|
||||||
|
if (operation.getPayLoad() == null) {
|
||||||
|
operation.setPayLoad("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
|
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
|
||||||
ctx.getOperation().getPayLoad());
|
operation.getPayLoad());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user