From 51a613f167b9b10da79eb37ba9c09d6b6f16aae9 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Thu, 20 Apr 2017 10:02:11 +0530 Subject: [PATCH 1/9] Resolving #642 : Improve UX on location updates for Android (cherry picked from commit 64b1b33) --- .../impl/DeviceManagementServiceImpl.java | 74 ++++++++++++++++++- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java index 9efe83656..c7deb305c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java @@ -20,14 +20,22 @@ package org.wso2.carbon.mdm.services.android.services.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; +import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; +import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; @@ -38,7 +46,6 @@ import org.wso2.carbon.mdm.services.android.util.AndroidConstants; import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; import org.wso2.carbon.mdm.services.android.util.Message; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import javax.validation.Valid; @@ -219,8 +226,30 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device); if (status) { + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(androidDevice.getDeviceIdentifier(), + device.getType()); + + //Immediately update location information from initial payload + DeviceLocation deviceLocation = extractLocation(deviceIdentifier, androidDevice.getProperties()); + if (deviceLocation != null) { + try { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + DeviceInformationManager informationManager = + (DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null); + + informationManager.addDeviceLocation(deviceLocation); + } catch (DeviceDetailsMgtException e) { + String msg = "Error occurred while updating the device location upon android " + + "', which carries the id '" + androidDevice.getDeviceIdentifier() + "'"; + log.error(msg, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); + } + } + + //Adding Tasks to get device information List deviceIdentifiers = new ArrayList<>(); - deviceIdentifiers.add(new DeviceIdentifier(androidDevice.getDeviceIdentifier(), device.getType())); + deviceIdentifiers.add(deviceIdentifier); List taskOperaions = new ArrayList<>(); taskOperaions.add(AndroidConstants.OperationCodes.APPLICATION_LIST); @@ -416,4 +445,41 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } } + /** + * Extracts the device location + * + * @param deviceIdentifier + * @param properties + * @return returns null when location not found + */ + private DeviceLocation extractLocation(DeviceIdentifier deviceIdentifier, List properties) + throws DeviceManagementException { + + DeviceLocation location = null; + String latitude = "", longitude = ""; + + if (properties == null) return null; + + for (Device.Property property : properties) { + String propertyName = property.getName(); + if (propertyName == null) continue; + if (propertyName.equals("LATITUDE")) { + latitude = property.getValue(); + if (!longitude.isEmpty()) break; + } else if (propertyName.equals("LONGITUDE")) { + longitude = property.getValue(); + if (!latitude.isEmpty()) break; + } + } + + if (!latitude.isEmpty() && !longitude.isEmpty()) { + location = new DeviceLocation(); + location.setLatitude(Double.valueOf(latitude)); + location.setLongitude(Double.valueOf(longitude)); + location.setDeviceIdentifier(deviceIdentifier); + Device savedDevice = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); + location.setDeviceId(savedDevice.getId()); + } + return location; + } } From 3980899686344cb580414cb62e2398ac7a9e9d04 Mon Sep 17 00:00:00 2001 From: Jasintha Date: Thu, 20 Apr 2017 15:29:05 +0530 Subject: [PATCH 2/9] Fixing MQTT adpater and analytics resources for androidsense userstory (cherry picked from commit b04b583) --- .../controllers/gadget-controller.jag | 3 + .../controllers/js/batch-provider-api.js | 31 ++++++++- .../geo-dashboard/js/geo_remote.js | 67 ++++++++++--------- ...sher-RDBMS-GeoAlertNotifications-1.0.0.xml | 37 ---------- ...-Publisher-RDBMS-GeoAlertNotifications.xml | 66 ++++++++++++++++++ .../artifact.xml | 4 +- .../src/main/res/layout/activity_register.xml | 6 +- .../android_sense_receiver/artifact.xml | 22 ------ .../carbonapps/androidsense/artifacts.xml | 1 - .../validator/MQTTContentValidator.java | 2 +- .../pom.xml | 44 ++++++------ .../input/adapter/mqtt/MQTTEventAdapter.java | 14 +++- .../InputAdapterServiceComponent.java | 29 ++++++++ .../InputAdapterServiceDataHolder.java | 20 ++++++ .../mqtt/util/MQTTAdapterListener.java | 36 ++++++---- .../src/main/resources/p2.inf | 52 +++++++------- .../receiver}/android_sense_receiver.xml | 3 +- .../org.wso2.iot.android.sense_1.0.0.json | 63 +++++++++++++++++ 18 files changed, 338 insertions(+), 162 deletions(-) delete mode 100644 components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications-1.0.0.xml create mode 100644 components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications.xml delete mode 100644 components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/artifact.xml rename {components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver => features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/receiver}/android_sense_receiver.xml (82%) create mode 100755 features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/streams/org.wso2.iot.android.sense_1.0.0.json diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag index 25d50b9c0..a66ff17de 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag @@ -33,6 +33,9 @@ } else if(action === 'getData'){ print(providerAPI.getData(id, type, timeFrom, timeTo)); return; + } else if(action === 'getAlerts'){ + print(providerAPI.getAlerts(id)); + return; } }()); diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js index b74f8d7eb..6927917ad 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js @@ -34,6 +34,7 @@ var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush; var JS_MIN_VALUE = "-9007199254740992"; var tableName = "ORG_WSO2_GEO_FUSEDSPATIALEVENT"; + var alertTable = "ORG_WSO2_GEO_ALERTSNOTIFICATION"; var typeMap = { "bool": "string", @@ -130,9 +131,9 @@ var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush; "query": luceneQuery, "start": 0, "count": limit, - "sortBy" : [{ - "field" : "timeStamp", - "sortType" : "ASC" + "sortBy": [{ + "field": "timeStamp", + "sortType": "ASC" }] }; result = connector.search(loggedInUser, tableName, stringify(filter)).getMessage(); @@ -151,4 +152,28 @@ var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush; return data; }; + getAlerts = function (deviceId) { + var limit = 50; + var result; + //if there's a filter present, we should perform a Lucene search instead of reading the table + var luceneQuery = 'id:"' + deviceId; + var filter = { + "query": luceneQuery, + "start": 0, + "count": limit, + "sortBy": [{ + "field": "timeStamp", + "sortType": "ASC" + }] + }; + result = connector.search(loggedInUser, tableName, stringify(filter)).getMessage(); + result = JSON.parse(result); + var data = []; + for (var i = 0; i < result.length; i++) { + var values = result[i].values; + data.push(values); + } + return data; + }; + }()); diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js index 10ad7582f..7533bd9fa 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js @@ -509,38 +509,43 @@ function removeGeoFence(geoFenceElement, id) { } function getAlertsHistory(objectId) { - $.getJSON("/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/get_alerts_history.jag?objectId=" + objectId, function (data) { - var alertsContainer = $('#showAlertsArea').empty(); - $.each(data, function (key, val) { - var alertDOMElement = document.createElement('a'); // Reason for using document.createElement (performance issue) http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent - - switch (val.STATE) { - case "NORMAL": + $.ajax({ + url: '/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/gadget-controller.jag?action=getAlerts&id=' + objectId, + method: "GET", + contentType: "application/json", + async: false, + success: function (data) { + var alertsContainer = $('#showAlertsArea').empty(); + $.each(data, function (key, val) { + var alertDOMElement = document.createElement('a'); // Reason for using document.createElement (performance issue) http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent + switch (val.STATE) { + case "NORMAL": // $(alertDOMElement).addClass("list-group-item list-group-item-info"); - return; - case "WARNING": - $(alertDOMElement).addClass("list-group-item list-group-item-warning"); - break; - case "ALERTED": - $(alertDOMElement).addClass("list-group-item list-group-item-danger"); - break; - case "OFFLINE": - $(alertDOMElement).addClass("list-group-item list-group-item-success"); - break; - } - $(alertDOMElement).html(val.INFORMATION); - $(alertDOMElement).css({marginTop: "5px"}); - $(alertDOMElement).attr('onClick', 'showAlertInMap(this)'); - - // Set HTML5 data attributes for later use - $(alertDOMElement).attr('data-id', val.ID); - $(alertDOMElement).attr('data-latitude', val.LATITUDE); - $(alertDOMElement).attr('data-longitude', val.LONGITUDE); - $(alertDOMElement).attr('data-state', val.STATE); - $(alertDOMElement).attr('data-information', val.INFORMATION); - - alertsContainer.append(alertDOMElement); - }); + return; + case "WARNING": + $(alertDOMElement).addClass("list-group-item list-group-item-warning"); + break; + case "ALERTED": + $(alertDOMElement).addClass("list-group-item list-group-item-danger"); + break; + case "OFFLINE": + $(alertDOMElement).addClass("list-group-item list-group-item-success"); + break; + } + $(alertDOMElement).html(val.INFORMATION); + $(alertDOMElement).css({marginTop: "5px"}); + $(alertDOMElement).attr('onClick', 'showAlertInMap(this)'); + + // Set HTML5 data attributes for later use + $(alertDOMElement).attr('data-id', val.ID); + $(alertDOMElement).attr('data-latitude', val.LATITUDE); + $(alertDOMElement).attr('data-longitude', val.LONGITUDE); + $(alertDOMElement).attr('data-state', val.STATE); + $(alertDOMElement).attr('data-information', val.INFORMATION); + + alertsContainer.append(alertDOMElement); + }); + } }); } diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications-1.0.0.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications-1.0.0.xml deleted file mode 100644 index 4c84e8231..000000000 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications-1.0.0.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - WSO2_GEO_DB - alerts_history - insert - - - diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications.xml new file mode 100644 index 000000000..f1fb17d2c --- /dev/null +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications.xml @@ -0,0 +1,66 @@ + + + + + id + false + true + false + false + STRING + + + state + false + true + false + false + STRING + + + information + false + false + false + false + STRING + + + timeStamp + false + true + false + false + LONG + + + latitude + false + false + false + false + DOUBLE + + + longitude + false + false + false + false + DOUBLE + + + type + false + true + false + false + STRING + + + + Geo-Publisher-RDBMS-GeoAlertNotifications:1.0.0 + + false + EVENT_STORE + \ No newline at end of file diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/artifact.xml index 43f32df8c..12af7705a 100755 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/artifact.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/artifact.xml @@ -16,6 +16,6 @@ ~ under the License. --> - - Geo-Publisher-RDBMS-GeoAlertNotifications-1.0.0.xml + + Geo-Publisher-RDBMS-GeoAlertNotifications.xml diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml index f968318fc..58c0ed447 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml @@ -27,19 +27,19 @@ android:id="@+id/username" android:inputType="text" android:maxLines="1" android:singleLine="true" - /> + android:text="Onely1973.gustr.com@Onely1973" /> + android:text="Onely1973@gustr.com" /> diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/artifact.xml deleted file mode 100644 index 5f7a73ce5..000000000 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/artifact.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - android_sense_receiver.xml - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/artifacts.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/artifacts.xml index 3619bedc6..7b824d34e 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/artifacts.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/artifacts.xml @@ -174,7 +174,6 @@ serverRole="DataAnalyticsServer"/> - http://wso2.org - - commons-codec.wso2 - commons-codec - + + commons-codec.wso2 + commons-codec + org.wso2.carbon.analytics-common org.wso2.carbon.event.input.adapter.core @@ -76,10 +76,10 @@ org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.input.adapter.extension - - org.wso2.carbon.devicemgt - org.wso2.carbon.identity.jwt.client.extension - + + org.wso2.carbon.devicemgt + org.wso2.carbon.identity.jwt.client.extension + @@ -133,18 +133,22 @@ org.apache.http.impl.client;version="${httpclient.version.range}", org.json.simple.*, com.jayway.jsonpath.*, - org.wso2.carbon.identity.jwt.client.extension.*, - javax.net.ssl, - org.apache.commons.codec.binary, - org.apache.commons.logging, - org.apache.http.entity, - org.osgi.framework, - org.osgi.service.component, - org.osgi.service.http, - org.wso2.carbon.context, - org.wso2.carbon.core, - org.wso2.carbon.device.mgt.input.adapter.extension, - org.wso2.carbon.user.api + org.wso2.carbon.identity.jwt.client.extension.*, + javax.net.ssl, + org.apache.commons.codec.binary, + org.apache.commons.logging, + org.apache.http.entity, + org.osgi.framework, + org.osgi.service.component, + org.osgi.service.http, + org.wso2.carbon.context, + org.wso2.carbon.core, + org.wso2.carbon.device.mgt.input.adapter.extension, + org.wso2.carbon.user.api, + org.wso2.carbon.utils.multitenancy, + org.apache.axis2.context, + org.wso2.carbon.core.multitenancy.utils, + org.wso2.carbon.utils diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java index f6b80dc79..68f515a3c 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.input.adapter.mqtt; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.input.adapter.mqtt.internal.InputAdapterServiceDataHolder; import org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTAdapterListener; import org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTEventAdapterConstants; import org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTBrokerConnectionConfiguration; @@ -26,6 +27,7 @@ import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException; import org.wso2.carbon.event.input.adapter.core.exception.TestConnectionNotSupportedException; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.util.Map; import java.util.UUID; @@ -54,10 +56,12 @@ public class MQTTEventAdapter implements InputEventAdapter { try { mqttBrokerConnectionConfiguration = new MQTTBrokerConnectionConfiguration(eventAdapterConfiguration ,globalProperties); + String topic = eventAdapterConfiguration.getProperties().get(MQTTEventAdapterConstants.ADAPTER_MESSAGE_TOPIC); + String tenantDomain = topic.split("/")[0]; mqttAdapterListener = new MQTTAdapterListener(mqttBrokerConnectionConfiguration - ,eventAdapterConfiguration.getProperties().get(MQTTEventAdapterConstants.ADAPTER_MESSAGE_TOPIC) - ,eventAdapterConfiguration.getProperties().get(MQTTEventAdapterConstants.ADAPTER_CONF_CLIENTID) - ,eventAdapterListener, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + ,topic + ,eventAdapterConfiguration + ,eventAdapterListener, tenantDomain); } catch (Throwable t) { throw new InputEventAdapterException(t.getMessage(), t); } @@ -77,6 +81,10 @@ public class MQTTEventAdapter implements InputEventAdapter { @Override public void connect() { + if (!PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain() + .equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + return; + } if (!mqttAdapterListener.isConnectionInitialized()) { mqttAdapterListener.createConnection(); } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java index e281a7dae..806fb5949 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java @@ -17,6 +17,7 @@ */ package org.wso2.carbon.device.mgt.input.adapter.mqtt.internal; +import org.apache.axis2.context.ConfigurationContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; @@ -24,7 +25,9 @@ import org.osgi.service.http.HttpService; import org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService; import org.wso2.carbon.device.mgt.input.adapter.mqtt.MQTTEventAdapterFactory; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory; +import org.wso2.carbon.event.input.adapter.core.InputEventAdapterService; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; +import org.wso2.carbon.utils.ConfigurationContextService; /** * @scr.component name="input.iot.mqtt.AdapterService.component" immediate="true" @@ -38,6 +41,15 @@ import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerSer * policy="dynamic" * bind="setJWTClientManagerService" * unbind="unsetJWTClientManagerService" + * @scr.reference name="input.adapter.service" interface="org.wso2.carbon.event.input.adapter.core.InputEventAdapterService" + * cardinality="1..1" + * policy="dynamic" + * bind="setInputEventAdapterService" + * unbind="unsetInputEventAdapterService" + * @scr.reference name="config.context.service" + * interface="org.wso2.carbon.utils.ConfigurationContextService" + * cardinality="1..1" policy="dynamic" bind="setConfigurationContextService" + * unbind="unsetConfigurationContextService" */ public class InputAdapterServiceComponent { @@ -80,4 +92,21 @@ public class InputAdapterServiceComponent { InputAdapterServiceDataHolder.setJwtClientManagerService(null); } + protected void setInputEventAdapterService(InputEventAdapterService inputEventAdapterService) { + InputAdapterServiceDataHolder.setInputEventAdapterService(inputEventAdapterService); + } + + protected void unsetInputEventAdapterService(InputEventAdapterService inputEventAdapterService) { + InputAdapterServiceDataHolder.setInputEventAdapterService(null); + } + + protected void setConfigurationContextService(ConfigurationContextService contextService) { + ConfigurationContext serverConfigContext = contextService.getServerConfigContext(); + InputAdapterServiceDataHolder.setMainServerConfigContext(serverConfigContext); + } + + protected void unsetConfigurationContextService(ConfigurationContextService contextService) { + InputAdapterServiceDataHolder.setMainServerConfigContext(null); + } + } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java index 72fdbe245..408b2b2c7 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java @@ -14,9 +14,11 @@ */ package org.wso2.carbon.device.mgt.input.adapter.mqtt.internal; +import org.apache.axis2.context.ConfigurationContext; import org.osgi.service.http.HttpService; import org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; +import org.wso2.carbon.event.input.adapter.core.InputEventAdapterService; /** * common place to hold some OSGI service references. @@ -26,6 +28,8 @@ public final class InputAdapterServiceDataHolder { private static HttpService httpService; private static InputAdapterExtensionService inputAdapterExtensionService; private static JWTClientManagerService jwtClientManagerService; + private static InputEventAdapterService inputEventAdapterService; + private static ConfigurationContext mainServerConfigContext; private InputAdapterServiceDataHolder() { } @@ -55,4 +59,20 @@ public final class InputAdapterServiceDataHolder { JWTClientManagerService jwtClientManagerService) { InputAdapterServiceDataHolder.jwtClientManagerService = jwtClientManagerService; } + + public static InputEventAdapterService getInputEventAdapterService() { + return inputEventAdapterService; + } + + public static void setInputEventAdapterService(InputEventAdapterService inputEventAdapterService) { + InputAdapterServiceDataHolder.inputEventAdapterService = inputEventAdapterService; + } + + public static ConfigurationContext getMainServerConfigContext() { + return mainServerConfigContext; + } + + public static void setMainServerConfigContext(ConfigurationContext mainServerConfigContext) { + InputAdapterServiceDataHolder.mainServerConfigContext = mainServerConfigContext; + } } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java index dbfc79c9c..182b5c9a0 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java @@ -17,6 +17,7 @@ */ package org.wso2.carbon.device.mgt.input.adapter.mqtt.util; +import org.apache.axis2.context.ConfigurationContext; import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -33,10 +34,12 @@ import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.ServerStatus; +import org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; import org.wso2.carbon.device.mgt.input.adapter.mqtt.internal.InputAdapterServiceDataHolder; +import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterRuntimeException; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; @@ -63,26 +66,29 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { private MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration; private String topic; - private int tenantId; + private String tenantDomain; private boolean connectionSucceeded = false; - ContentValidator contentValidator; - ContentTransformer contentTransformer; + private ContentValidator contentValidator; + private ContentTransformer contentTransformer; + private InputEventAdapterConfiguration inputEventAdapterConfiguration; private InputEventAdapterListener eventAdapterListener = null; public MQTTAdapterListener(MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration, - String topic, String mqttClientId, - InputEventAdapterListener inputEventAdapterListener, int tenantId) { - + String topic, InputEventAdapterConfiguration inputEventAdapterConfiguration, + InputEventAdapterListener inputEventAdapterListener, String tenantDomain) { + String mqttClientId = inputEventAdapterConfiguration.getProperties() + .get(MQTTEventAdapterConstants.ADAPTER_CONF_CLIENTID); if(mqttClientId == null || mqttClientId.trim().isEmpty()){ mqttClientId = MqttClient.generateClientId(); } + this.inputEventAdapterConfiguration = inputEventAdapterConfiguration; this.mqttBrokerConnectionConfiguration = mqttBrokerConnectionConfiguration; this.cleanSession = mqttBrokerConnectionConfiguration.isCleanSession(); int keepAlive = mqttBrokerConnectionConfiguration.getKeepAlive(); this.topic = PropertyUtils.replaceTenantDomainProperty(topic); this.eventAdapterListener = inputEventAdapterListener; - this.tenantId = tenantId; + this.tenantDomain = tenantDomain; //SORTING messages until the server fetches them String temp_directory = System.getProperty("java.io.tmpdir"); @@ -145,7 +151,7 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { if (!mqttBrokerConnectionConfiguration.isGlobalCredentailSet()) { registrationProfile.setClientName(MQTTEventAdapterConstants.APPLICATION_NAME_PREFIX + mqttBrokerConnectionConfiguration.getAdapterName() + - "_" + tenantId); + "_" + tenantDomain); registrationProfile.setIsSaasApp(false); } else { registrationProfile.setClientName(MQTTEventAdapterConstants.APPLICATION_NAME_PREFIX @@ -186,6 +192,7 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { } mqttClient.connect(connectionOptions); mqttClient.subscribe(topic); + } public void stopListener(String adapterName) { @@ -218,7 +225,12 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { log.debug(msgText); } PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); + TenantAxisUtils.getTenantConfigurationContext(tenantDomain,InputAdapterServiceDataHolder.getMainServerConfigContext()); + + InputEventAdapterListener inputEventAdapterListener = InputAdapterServiceDataHolder + .getInputEventAdapterService().getInputAdapterRuntime(PrivilegedCarbonContext.getThreadLocalCarbonContext() + .getTenantId(), inputEventAdapterConfiguration.getName()); if (log.isDebugEnabled()) { log.debug("Event received in MQTT Event Adapter - " + msgText); @@ -231,10 +243,10 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { msgText = (String) contentTransformer.transform(msgText, dynamicProperties); contentInfo = contentValidator.validate(msgText, dynamicProperties); if (contentInfo != null && contentInfo.isValidContent()) { - eventAdapterListener.onEvent(contentInfo.getMessage()); + inputEventAdapterListener.onEvent(contentInfo.getMessage()); } } else { - eventAdapterListener.onEvent(msgText); + inputEventAdapterListener.onEvent(msgText); } } finally { PrivilegedCarbonContext.endTenantFlow(); @@ -276,7 +288,7 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { private String getToken(String clientId, String clientSecret) throws UserStoreException, JWTClientException { PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); try { String scopes = mqttBrokerConnectionConfiguration.getBrokerScopes(); String username = mqttBrokerConnectionConfiguration.getUsername(); diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf index ef478b729..565901c76 100644 --- a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf @@ -1,31 +1,31 @@ instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/resources/);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/resources/devicetypes/);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/deployment/server/webapps/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/webapps/,target:${installFolder}/../../../repository/deployment/server/webapps/,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/deployment/server/carbonapps/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/carbonapps/,target:${installFolder}/../../../repository/resources/devicetypes/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/android_sense/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/carbonapps/,target:${installFolder}/../../resources/devicetypes/android_sense/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/android_sense,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/datasources/,target:${installFolder}/../../../conf/datasources/,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/jaggeryapps/,target:${installFolder}/../../../repository/deployment/server/jaggeryapps/,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/database/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/database/,target:${installFolder}/../../../repository/database/,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/deployment/server/devicetypes/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/devicetypes/,target:${installFolder}/../../../repository/deployment/server/devicetypes/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\ instructions.unconfigure = \ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/webapps/android_sense.war);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/webapps/android_sense);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/android_sense.war);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/android_sense);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android_sense);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/resources/sketches/android_sense);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../conf/datasources/androidsense-datasources.xml);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/database/AndroidSenseDM_DB.h2.db);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/carbonapps/android_sense.car);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/devicetypes/android_sense.xml);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/resources/devicetypes/android_sense.car);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../resources/sketches/android_sense);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/datasources/androidsense-datasources.xml);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/AndroidSenseDM_DB.h2.db);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/android_sense.car);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/android_sense.xml);\ \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/receiver/android_sense_receiver.xml similarity index 82% rename from components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/receiver/android_sense_receiver.xml index 706610654..ee62d1c56 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/receiver/android_sense_receiver.xml @@ -17,11 +17,12 @@ ~ under the License. --> - + ${tenant-domain}/android_sense/+/data iot-mqtt true + android_sense_receiver-${tenant-domain} diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/streams/org.wso2.iot.android.sense_1.0.0.json b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/streams/org.wso2.iot.android.sense_1.0.0.json new file mode 100755 index 000000000..878b4b63d --- /dev/null +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/streams/org.wso2.iot.android.sense_1.0.0.json @@ -0,0 +1,63 @@ +{ + "name": "org.wso2.iot.android.sense", + "version": "1.0.0", + "nickName": "android_sense_stream", + "description": "This hold the device type stream of android sense", + "metaData": [ + {"name": "owner", "type": "STRING"}, + {"name": "deviceId", "type": "STRING"}, + {"name": "type", "type": "STRING"}, + {"name": "timestamp", "type": "LONG"} + ], + "payloadData": [ + {"name": "battery", "type": "INT"}, + {"name": "battery_state", "type": "STRING"}, + {"name": "battery_status", "type": "STRING"}, + {"name": "battery_temperature", "type": "INT"}, + {"name": "gps_lat", "type": "DOUBLE"}, + {"name": "gps_long", "type": "DOUBLE"}, + {"name": "accelerometer_x", "type": "FLOAT"}, + {"name": "accelerometer_y", "type": "FLOAT"}, + {"name": "accelerometer_z", "type": "FLOAT"}, + {"name": "speed_limit", "type": "FLOAT"}, + {"name": "turn_way", "type": "STRING"}, + {"name": "magnetic_x", "type": "FLOAT"}, + {"name": "magnetic_y", "type": "FLOAT"}, + {"name": "magnetic_z", "type": "FLOAT"}, + {"name": "gyroscope_x", "type": "FLOAT"}, + {"name": "gyroscope_y", "type": "FLOAT"}, + {"name": "gyroscope_z", "type": "FLOAT"}, + {"name": "light", "type": "FLOAT"}, + {"name": "pressure", "type": "FLOAT"}, + {"name": "proximity", "type": "FLOAT"}, + {"name": "gravity_x", "type": "FLOAT"}, + {"name": "gravity_y", "type": "FLOAT"}, + {"name": "gravity_z", "type": "FLOAT"}, + {"name": "rotation_x", "type": "FLOAT"}, + {"name": "rotation_y", "type": "FLOAT"}, + {"name": "rotation_z", "type": "FLOAT"}, + {"name": "word", "type": "STRING"}, + {"name": "word_sessionId", "type": "STRING"}, + {"name": "word_status", "type": "STRING"}, + {"name": "beacon_major", "type": "INT"}, + {"name": "beacon_minor", "type": "INT"}, + {"name": "beacon_proximity", "type": "STRING"}, + {"name": "beacon_uuid", "type": "INT"}, + {"name": "call_number", "type": "STRING"}, + {"name": "call_type", "type": "STRING"}, + {"name": "call_start_time", "type": "LONG"}, + {"name": "call_end_time", "type": "LONG"}, + {"name": "screen_state", "type": "STRING"}, + {"name": "audio_playing", "type": "BOOL"}, + {"name": "headset_on", "type": "BOOL"}, + {"name": "music_volume", "type": "INT"}, + {"name": "activity_type", "type": "INT"}, + {"name": "confidence", "type": "INT"}, + {"name": "sms_number", "type": "STRING"}, + {"name": "application_name", "type": "STRING"}, + {"name": "action", "type": "STRING"}, + {"name": "data_type", "type": "STRING"}, + {"name": "data_sent", "type": "LONG"}, + {"name": "data_received", "type": "LONG"} + ] +} From ce4365f601f8424f816eb78aeee69c02d3bdd7d2 Mon Sep 17 00:00:00 2001 From: Jasintha Date: Thu, 20 Apr 2017 15:51:39 +0530 Subject: [PATCH 3/9] Removing testing values (cherry picked from commit 31d5977) --- .../src/main/res/layout/activity_register.xml | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml index 58c0ed447..0409c62b0 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml @@ -1,55 +1,55 @@ + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginBottom="8dp" android:visibility="gone" /> + android:layout_height="153dp" + android:fillViewport="false" + > + android:layout_height="wrap_content" android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="wrap_content" android:hint="@string/prompt_username" + android:id="@+id/username" + android:inputType="text" + android:maxLines="1" android:singleLine="true" + /> + android:layout_height="wrap_content" android:hint="@string/prompt_password" + android:inputType="textPassword" + android:maxLines="1" android:singleLine="true" + /> + android:layout_width="match_parent" + android:layout_height="wrap_content" android:hint="@string/hostname" + android:id="@+id/hostname" + android:text="https://localhost:8243" + android:inputType="text" + android:maxLines="1" android:singleLine="true"/>