From 44b5b4f44daafe94b05a0bd51eae9b94f44079ca Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Sat, 18 Mar 2023 12:20:44 +0530 Subject: [PATCH] fixing invalid attribute --- .../service/impl/DeviceManagementServiceImpl.java | 10 +++++----- .../mgt/common/type/mgt/DeviceTypeMetaDefinition.java | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index ac3098caf70..e37472bb694 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -872,14 +872,14 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { DeviceManagementProviderService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceManagementService(); int validityTime = 3600; - List mqttTopicStructure = new ArrayList<>(); + List mqttEventTopicStructure = new ArrayList<>(); try { DeviceType deviceType = deviceManagementProviderService.getDeviceType(type); if (deviceType != null) { if (deviceType.getDeviceTypeMetaDefinition().isLongLivedToken()) { validityTime = Integer.MAX_VALUE; } - mqttTopicStructure = deviceType.getDeviceTypeMetaDefinition().getMqttTopicStructures(); + mqttEventTopicStructure = deviceType.getDeviceTypeMetaDefinition().getMqttEventTopicStructures(); } else { String msg = "Device not found, device id : " + id + ", device type : " + type; log.error(msg); @@ -907,9 +907,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { StringBuilder scopes = new StringBuilder("device_" + type.replace(" ", "") .replace("_", "") + "_" + id); - for (String topic : mqttTopicStructure) { - if (topic.contains("")) { - topic = topic.replace("", id); + for (String topic : mqttEventTopicStructure) { + if (topic.contains("${deviceId}")) { + topic = topic.replace("${deviceId}", id); } topic = topic.replace("/",":"); scopes.append(" perm:topic:sub:".concat(topic)); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java index 5fe90596f61..835f450bb78 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java @@ -20,7 +20,7 @@ public class DeviceTypeMetaDefinition { private String description; private boolean isSharedWithAllTenants; - private List mqttTopicStructures; + private List mqttEventTopicStructures; private boolean longLivedToken = false; @@ -89,12 +89,12 @@ public class DeviceTypeMetaDefinition { isSharedWithAllTenants = sharedWithAllTenants; } - public List getMqttTopicStructures() { - return mqttTopicStructures; + public List getMqttEventTopicStructures() { + return mqttEventTopicStructures; } - public void setMqttTopicStructures(List mqttTopicStructures) { - this.mqttTopicStructures = mqttTopicStructures; + public void setMqttEventTopicStructures(List mqttEventTopicStructures) { + this.mqttEventTopicStructures = mqttEventTopicStructures; } public boolean isLongLivedToken() {