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/AndroidSenseService.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/AndroidSenseService.java index 348a9008d..ebafb0139 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/AndroidSenseService.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/AndroidSenseService.java @@ -79,5 +79,13 @@ public interface AndroidSenseService { @Scope(key = "device:android-sense:enroll", name = "", description = "") Response register(@PathParam("device_id") String deviceId, @QueryParam("deviceName") String deviceName); + /** + * Get All Devices. + */ + @Path("devices") + @GET + @Scope(key = "device:android-sense:enroll", name = "", description = "") + Response getAllDevices(); + } 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/AndroidSenseServiceImpl.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/AndroidSenseServiceImpl.java index b98fb0bdd..5d4921297 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/AndroidSenseServiceImpl.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/AndroidSenseServiceImpl.java @@ -300,4 +300,27 @@ public class AndroidSenseServiceImpl implements AndroidSenseService { } } + @Path("/devices") + @GET + @Consumes("application/json") + @Produces("application/json") + public Response getAllDevices() { + try { + List userDevices = + APIUtil.getDeviceManagementService().getDevicesOfUser(APIUtil.getAuthenticatedUser()); + ArrayList deviceList = new ArrayList<>(); + for (Device device : userDevices) { + if (device.getType().equals(AndroidSenseConstants.DEVICE_TYPE) && + device.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.ACTIVE)) { + deviceList.add(device); + } + } + Device[] devices = deviceList.toArray(new Device[]{}); + return Response.ok().entity(devices).build(); + } catch (DeviceManagementException e) { + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); + } + } + } 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 2dbe9d7e0..43b2ce2c5 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 @@ -3,10 +3,10 @@ package org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.analytics.api.AnalyticsDataAPI; +import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; import org.wso2.carbon.analytics.dataservice.commons.SortByField; -import org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceUtils; import org.wso2.carbon.analytics.datasource.commons.Record; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; @@ -87,7 +87,7 @@ public class APIUtil { sortByFields); List recordIds = getRecordIds(resultEntries); AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); - Map sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords( + Map sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords( analyticsDataAPI, response)); List sortedSensorData = getSortedSensorData(sensorDatas, resultEntries); return sortedSensorData; diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/permissions.xml b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/permissions.xml index d4d5b3b7e..5e9294828 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/permissions.xml +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/permissions.xml @@ -63,5 +63,11 @@ POST android_sense_user - + + Get all devices + /device-mgt/user/devices + /devices + GET + android_sense_device + diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java index 5e48e57c9..5fe3aae32 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java @@ -7,7 +7,7 @@ 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; +import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; import org.wso2.carbon.analytics.datasource.commons.Record; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; @@ -81,7 +81,7 @@ public class APIUtil { sortByFields); List recordIds = getRecordIds(resultEntries); AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); - Map sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords( + Map sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords( analyticsDataAPI, response)); List sortedSensorData = getSortedSensorData(sensorDatas, resultEntries); return sortedSensorData; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml index cc7620641..8389317b9 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml @@ -166,10 +166,6 @@ org.wso2.carbon.analytics-common org.wso2.carbon.databridge.agent - - org.wso2.carbon.analytics-common - org.wso2.carbon.databridge.core - org.wso2.carbon.commons org.wso2.carbon.databridge.commons 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/util/APIUtil.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/util/APIUtil.java index 34a65dc26..fee581528 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/util/APIUtil.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/util/APIUtil.java @@ -7,7 +7,7 @@ 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; +import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; import org.wso2.carbon.analytics.datasource.commons.Record; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; @@ -78,7 +78,7 @@ public class APIUtil { sortByFields); List recordIds = getRecordIds(resultEntries); AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); - Map sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords( + Map sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords( analyticsDataAPI, response)); List sortedSensorData = getSortedSensorData(sensorDatas, resultEntries); return sortedSensorData; 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 0509eb80b..d302e7281 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 @@ -3,11 +3,10 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.analytics.api.AnalyticsDataAPI; +import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; 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; import org.wso2.carbon.analytics.datasource.commons.Record; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; @@ -21,7 +20,6 @@ import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -79,7 +77,7 @@ public class APIUtil { sortByFields); List recordIds = getRecordIds(resultEntries); AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); - Map sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords( + Map sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords( analyticsDataAPI, response)); List sortedSensorData = getSortedSensorData(sensorDatas, resultEntries); return sortedSensorData; 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/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java index f068b8884..9e8d1306b 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java @@ -24,7 +24,7 @@ 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.SearchResultEntry; -import org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceUtils; +import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; import org.wso2.carbon.analytics.datasource.commons.Record; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.context.CarbonContext; @@ -218,7 +218,7 @@ public class AndroidAPIUtils { List resultEntries = analyticsDataAPI.search(tenantId, tableName, query, 0, eventCount); List recordIds = getRecordIds(resultEntries); AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); - Map deviceStateses = createDeviceStatusData(AnalyticsDataServiceUtils.listRecords( + Map deviceStateses = createDeviceStatusData(AnalyticsDataAPIUtil.listRecords( analyticsDataAPI, response)); return getSortedDeviceStateData(deviceStateses, resultEntries); } diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml index 5ae74a97c..716e744d9 100644 --- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml +++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml @@ -64,6 +64,10 @@ org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.iot.input.adapter.xmpp + + com.jayway.jsonpath + json-path + @@ -174,6 +178,9 @@ org.wso2.carbon.identity:org.wso2.carbon.identity.oauth.stub:${identity.inbound.auth.oauth.version} + + com.jayway.jsonpath:json-path:${jsonpath.version} + diff --git a/pom.xml b/pom.xml index ec4c16cb7..8ff78b1b2 100644 --- a/pom.xml +++ b/pom.xml @@ -322,11 +322,6 @@ org.wso2.carbon.databridge.commons ${carbon.commons.version} - - org.wso2.carbon.analytics-common - org.wso2.carbon.databridge.core - ${carbon.analytics.common.version} - org.wso2.carbon.analytics-common org.wso2.carbon.databridge.agent @@ -400,6 +395,11 @@ org.wso2.carbon.device.mgt.iot.input.adapter.xmpp ${carbon.devicemgt.plugins.version} + + com.jayway.jsonpath + json-path + ${jsonpath.version} + org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.iot.api @@ -481,13 +481,6 @@ ${carbon.devicemgt.plugins.version} - - - org.wso2.carbon.analytics - org.wso2.carbon.analytics.datasource.commons - ${carbon.analytics.version} - - org.wso2.carbon.devicemgt-plugins @@ -1250,8 +1243,8 @@ 5.1.3 [5.1.3,6.0.0) - 1.2.8 - [1.2.8,2.0.0] + 1.2.9-SNAPSHOT + [1.2.9-SNAPSHOT,2.0.0] 1.51.0.0 @@ -1264,6 +1257,7 @@ 2.4 1.0.8 1.8 + 0.9.1 3.1.0.wso2v2