From 7cba43ccbb1b007111a61a6db4bea74208a0a963 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sun, 4 Jun 2017 06:52:29 +0530 Subject: [PATCH] few changes after testing HTTP and MQTT flow --- .../DeviceEventManagementServiceImpl.java | 25 +++++++++---------- .../pom.xml | 3 ++- .../PullNotificationSubscriberConfig.java | 2 +- .../public/js/operation-bar.js | 5 +--- .../type-view.hbs | 8 +++--- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java index dacca0749e..cff753a461 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java @@ -81,8 +81,10 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe private static final String THRIFT_ADAPTER_TYPE = "iot-event"; private static final String DEFAULT_DEVICE_ID_ATTRIBUTE = "deviceId"; private static final String DEFAULT_META_DEVICE_ID_ATTRIBUTE = "meta_deviceId"; - - + private static final String MQTT_CONTENT_TRANSFORMER = "device-meta-transformer"; + private static final String MQTT_CONTENT_TRANSFORMER_TYPE = "contentTransformer"; + private static final String MQTT_CONTENT_VALIDATOR_TYPE = "contentValidator"; + private static final String MQTT_CONTENT_VALIDATOR = "default"; @GET @Path("/{type}") @@ -182,14 +184,9 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { - if (transportType == TransportType.MQTT) { - publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); - publishEventReceivers(eventReceiverName, streamNameWithVersion, transportType, tenantDomain, - deviceType); - } else { - publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); - } - + publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); + publishEventReceivers(eventReceiverName, streamNameWithVersion, transportType, tenantDomain, + deviceType); } DeviceMgtAPIUtils.getDynamicEventCache().remove(deviceType); return Response.ok().build(); @@ -412,9 +409,13 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe String adapterType = OAUTH_MQTT_ADAPTER_TYPE; BasicInputAdapterPropertyDto basicInputAdapterPropertyDtos[]; if (transportType == TransportType.MQTT) { - basicInputAdapterPropertyDtos = new BasicInputAdapterPropertyDto[1]; + basicInputAdapterPropertyDtos = new BasicInputAdapterPropertyDto[3]; basicInputAdapterPropertyDtos[0] = getBasicInputAdapterPropertyDto("topic", requestedTenantDomain + "/" + deviceType + "/+/events"); + basicInputAdapterPropertyDtos[1] = getBasicInputAdapterPropertyDto(MQTT_CONTENT_TRANSFORMER_TYPE + , MQTT_CONTENT_TRANSFORMER); + basicInputAdapterPropertyDtos[2] = getBasicInputAdapterPropertyDto(MQTT_CONTENT_VALIDATOR_TYPE + , MQTT_CONTENT_VALIDATOR); } else { adapterType = THRIFT_ADAPTER_TYPE; basicInputAdapterPropertyDtos = new BasicInputAdapterPropertyDto[1]; @@ -425,8 +426,6 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe receiverAdminServiceStub.deployJsonEventReceiverConfiguration(eventRecieverName, streamNameWithVersion , adapterType, null, basicInputAdapterPropertyDtos, false); } else { - EventMappingPropertyDto eventMappingPropertyDto = new EventMappingPropertyDto(); - receiverAdminServiceStub.deployWso2EventReceiverConfiguration(eventRecieverName, streamNameWithVersion , adapterType, null, null, null, basicInputAdapterPropertyDtos, false, null); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 3395c82597..8e549d89d9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -111,7 +111,8 @@ org.wso2.carbon.utils.dbcreator, org.wso2.carbon.utils.multitenancy, - org.wso2.carbon.device.mgt.extensions.pull.notification.* + org.wso2.carbon.device.mgt.extensions.pull.notification, + org.wso2.carbon.device.mgt.extensions.pull.notification.* diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PullNotificationSubscriberConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PullNotificationSubscriberConfig.java index b559637d4c..e18896f4e4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PullNotificationSubscriberConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PullNotificationSubscriberConfig.java @@ -100,7 +100,7 @@ public class PullNotificationSubscriberConfig { * */ public void setClassName(String value) { - this.className = className; + this.className = value; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.operation-bar/public/js/operation-bar.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.operation-bar/public/js/operation-bar.js index 79b0b31f0d..5707f092d1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.operation-bar/public/js/operation-bar.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.operation-bar/public/js/operation-bar.js @@ -32,9 +32,6 @@ function submitForm(formId) { var operationDetails = $("#operation-details"); var deviceId = operationDetails.data("deviceid"); var operationEndpoint = operationDetails.data("endpoint"); - console.log(deviceId); - console.log(operationEndpoint); - var contentType = "application/json"; var payload = {}; @@ -44,7 +41,7 @@ function submitForm(formId) { var operation = {}; operation["code"] = form.find("#operation-code").val(); operation["type"]= form.find("#operation-type").val(); - operation["status"] = "IN_PROGRESS"; + operation["status"] = "PENDING"; operation["control"] = "REPEAT"; operation["payLoad"] = form.find("#operation-payload").val(); operation["enabled"] = true; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.hbs index 26af50aff7..f100540ebf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.hbs @@ -245,18 +245,18 @@ Operation Response: {{tenantDomain}}/{{deviceType}}/<device_id>/update/operation
- Payload : {operationId:1, payload:"example"} + Payload : {"id": 1,"status": "COMPLETED", "operationResponse": "this is my response"}
Topic Structure: