From 893c535fb3d27778494bdd6b053dc0cf80b3d714 Mon Sep 17 00:00:00 2001 From: gayank Date: Fri, 29 Apr 2016 20:01:19 +0530 Subject: [PATCH 1/2] Android feature for Updating an application --- .../mgt/mobile/impl/android/AndroidFeatureManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java index 122b3c70fd..a408360b9c 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java @@ -230,6 +230,12 @@ public class AndroidFeatureManager implements FeatureManager { feature.setDescription("Install Enterprise or Market application"); supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("UPDATE_APPLICATION"); + feature.setName("Update App"); + feature.setDescription("Update Enterprise or Market application"); + supportedFeatures.add(feature); + feature = new Feature(); feature.setCode("UNINSTALL_APPLICATION"); feature.setName("Uninstall App"); @@ -272,7 +278,7 @@ public class AndroidFeatureManager implements FeatureManager { feature.setDescription("Reboot the device"); supportedFeatures.add(feature); - feature = new Feature(); + feature = new Feature(); feature.setCode("UPGRADE_FIRMWARE"); feature.setName("Upgrade Firmware"); feature.setDescription("Upgrade Firmware"); From dbf82a3aa0ce336efac94f6838531873b877e3ce Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 3 May 2016 13:37:09 +0530 Subject: [PATCH 2/2] added recivers for temperature and few code changes after testing --- .../AndroidSenseControllerServiceImpl.java | 6 ++-- .../service/impl/util/APIUtil.java | 9 ------ .../public/js/device-stats.js | 2 +- .../EventReceiver_http_temperature.xml | 32 +++++++++++++++++++ .../artifact.xml | 22 +++++++++++++ .../EventReceiver_mqtt_temperature.xml | 32 +++++++++++++++++++ .../artifact.xml | 22 +++++++++++++ .../carbonapps/Temperature/artifacts.xml | 2 ++ .../impl/RaspberryPiControllerService.java | 2 +- .../plugin/impl/RaspberrypiManager.java | 6 ++-- .../service/impl/util/APIUtil.java | 3 -- 11 files changed, 118 insertions(+), 20 deletions(-) create mode 100644 components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_http_temperature_1.0.0/EventReceiver_http_temperature.xml create mode 100644 components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_http_temperature_1.0.0/artifact.xml create mode 100644 components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_mqtt_temperature_1.0.0/EventReceiver_mqtt_temperature.xml create mode 100644 components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_mqtt_temperature_1.0.0/artifact.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerServiceImpl.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerServiceImpl.java index 134e87a15a..369dc93694 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerServiceImpl.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerServiceImpl.java @@ -36,7 +36,6 @@ import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; -import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -119,11 +118,10 @@ public class AndroidSenseControllerServiceImpl implements AndroidSenseController @QueryParam("from") long from, @QueryParam("to") long to) { String fromDate = String.valueOf(from); String toDate = String.valueOf(to); - String user = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - String query = "owner:" + user + " AND deviceId:" + deviceId + " AND deviceType:" + + String query = "deviceId:" + deviceId + " AND deviceType:" + AndroidSenseConstants.DEVICE_TYPE + " AND time : [" + fromDate + " TO " + toDate + "]"; if (sensor.equals(AndroidSenseConstants.SENSOR_WORDCOUNT)) { - query = "owner:" + user + " AND deviceId:" + deviceId; + query = "deviceId:" + deviceId; } String sensorTableName = getSensorEventTableName(sensor); diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java index 44df212413..c102b099f5 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java @@ -4,7 +4,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.analytics.api.AnalyticsDataAPI; import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; -import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDrillDownRequest; import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; import org.wso2.carbon.analytics.dataservice.commons.SortByField; import org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceUtils; @@ -14,16 +13,8 @@ import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; -import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagementException; -import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionUtils; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; -import org.wso2.carbon.registry.api.Resource; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.api.UserStoreManager; -import org.wso2.carbon.user.core.service.RealmService; import java.util.ArrayList; import java.util.Arrays; diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js index d24b1918cc..a67ff50db5 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js @@ -90,7 +90,7 @@ function connect(target) { ws.onmessage = function (event) { var dataPoint = JSON.parse(event.data); chartData.push({ - x: parseInt(dataPoint[4]) / 1000, + x: parseInt(dataPoint[0]) / 1000, y: parseFloat(dataPoint[5]) }); chartData.shift(); diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_http_temperature_1.0.0/EventReceiver_http_temperature.xml b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_http_temperature_1.0.0/EventReceiver_http_temperature.xml new file mode 100644 index 0000000000..f88e6cd22f --- /dev/null +++ b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_http_temperature_1.0.0/EventReceiver_http_temperature.xml @@ -0,0 +1,32 @@ + + + + + 2 + admin + device_id_json_path:event.metaData.deviceId + default + all + 100 + https://localhost:9443/services/OAuth2TokenValidationService + admin + + + + diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_http_temperature_1.0.0/artifact.xml b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_http_temperature_1.0.0/artifact.xml new file mode 100644 index 0000000000..dc87db05e3 --- /dev/null +++ b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_http_temperature_1.0.0/artifact.xml @@ -0,0 +1,22 @@ + + + + + EventReceiver_http_temperature.xml + diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_mqtt_temperature_1.0.0/EventReceiver_mqtt_temperature.xml b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_mqtt_temperature_1.0.0/EventReceiver_mqtt_temperature.xml new file mode 100644 index 0000000000..1166733c4d --- /dev/null +++ b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_mqtt_temperature_1.0.0/EventReceiver_mqtt_temperature.xml @@ -0,0 +1,32 @@ + + + + + + wso2/carbon.super/+/temperature + admin + device_id_json_path:event.metaData.deviceId,device_id_topic_hierarchy_index:3 + default + https://localhost:9443/dynamic-client-web/register + tcp://localhost:1883 + true + + + + \ No newline at end of file diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_mqtt_temperature_1.0.0/artifact.xml b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_mqtt_temperature_1.0.0/artifact.xml new file mode 100644 index 0000000000..c9d574bdc6 --- /dev/null +++ b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/Eventreceiver_mqtt_temperature_1.0.0/artifact.xml @@ -0,0 +1,22 @@ + + + + + EventReceiver_mqtt_temperature.xml + diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/artifacts.xml b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/artifacts.xml index f48c5b5410..2bb4c9840d 100644 --- a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/artifacts.xml +++ b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/Temperature/artifacts.xml @@ -22,6 +22,8 @@ + + diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerService.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerService.java index c7c1e5eba7..e184902b0d 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerService.java +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerService.java @@ -39,7 +39,7 @@ public interface RaspberryPiControllerService { @POST @Feature(code = "bulb", name = "Bulb On / Off", type = "operation", description = "Switch on/off Raspberry Pi agent's bulb. (On / Off)") - Response switchBulb(@PathParam("deviceId") String deviceId, @FormParam("state") String state); + Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); /** * Retreive Sensor data for the device type diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java index 98d3959f05..eec07bf7cf 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java @@ -31,6 +31,8 @@ import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.exception.RaspberrypiDeviceMgtPluginException; import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.dao.RaspberrypiDAOUtil; +import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.feature.RaspberrypiFeatureManager; + import java.util.List; /** @@ -40,10 +42,10 @@ public class RaspberrypiManager implements DeviceManager { private static final RaspberrypiDAOUtil raspberrypiDAO = new RaspberrypiDAOUtil(); private static final Log log = LogFactory.getLog(RaspberrypiManager.class); - + private RaspberrypiFeatureManager raspberrypiFeatureManager = new RaspberrypiFeatureManager(); @Override public FeatureManager getFeatureManager() { - return null; + return raspberrypiFeatureManager; } @Override diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java index 8f2612ac43..e7b182ef46 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java @@ -17,9 +17,6 @@ import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorization import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.dto.SensorRecord; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.api.UserStoreManager; -import org.wso2.carbon.user.core.service.RealmService; import java.util.ArrayList; import java.util.Arrays;