diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml new file mode 100644 index 0000000000..08e244b9af --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml @@ -0,0 +1,198 @@ + + + + device-mgt-iot-androidsense + org.wso2.carbon.devicemgt-plugins + 1.9.2-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.iot.androidsense.api + 1.9.2-SNAPSHOT + war + WSO2 Carbon - Android Sense API + WSO2 Carbon - Android Sense Service API Implementation + http://wso2.org + + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + provided + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + provided + + + org.apache.axis2.wso2 + axis2-client + + + + + + + org.apache.cxf + cxf-rt-frontend-jaxws + provided + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + org.apache.cxf + cxf-rt-transports-http + provided + + + + org.eclipse.paho + mqtt-client + + + + + org.apache.httpcomponents + httpasyncclient + 4.1 + provided + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot + provided + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense + provided + + + + org.codehaus.jackson + jackson-core-asl + provided + + + org.codehaus.jackson + jackson-jaxrs + provided + + + javax + javaee-web-api + provided + + + javax.ws.rs + jsr311-api + provided + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.analytics + provided + + + + commons-httpclient.wso2 + commons-httpclient + provided + + + + org.wso2.carbon + org.wso2.carbon.utils + provided + + + org.bouncycastle.wso2 + bcprov-jdk15on + + + org.wso2.carbon + org.wso2.carbon.user.api + + + org.wso2.carbon + org.wso2.carbon.queuing + + + org.wso2.carbon + org.wso2.carbon.base + + + org.apache.axis2.wso2 + axis2 + + + org.igniterealtime.smack.wso2 + smack + + + org.igniterealtime.smack.wso2 + smackx + + + jaxen + jaxen + + + commons-fileupload.wso2 + commons-fileupload + + + org.apache.ant.wso2 + ant + + + org.apache.ant.wso2 + ant + + + commons-httpclient.wso2 + commons-httpclient + + + org.eclipse.equinox + javax.servlet + + + org.wso2.carbon + org.wso2.carbon.registry.api + + + + + + + + + + maven-compiler-plugin + + UTF-8 + ${wso2.maven.compiler.source} + ${wso2.maven.compiler.target} + + + + maven-war-plugin + + android_sense + + + + + + diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java new file mode 100644 index 0000000000..e5045e69ea --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java @@ -0,0 +1,396 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.iot.androidsense.service.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.analytics.exception.DataPublisherConfigurationException; +import org.wso2.carbon.device.mgt.analytics.service.DeviceAnalyticsService; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.DeviceJSON; +import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.SensorJSON; +import org.wso2.carbon.device.mgt.iot.DeviceManagement; +import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException; +import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager; +import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord; +import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants; + +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.Date; + +public class AndroidSenseService { + + private static final String BATTERY_STREAM_DEFINITION = "org.wso2.iot.devices.battery"; + private static final String LIGHT_STREAM_DEFINITION = "org.wso2.iot.devices.light"; + private static final String GPS_STREAM_DEFINITION = "org.wso2.iot.devices.gps"; + private static final String MAGNETIC_STREAM_DEFINITION = "org.wso2.iot.devices.magnetic"; + + /*Definetions for other sensor types. + * Accelerometer + * Gyroscope + * Pressure + * Proximity + * Gravity + * Rotation Vector + * */ + + private static final String ACCELEROMETER_STREAM_DEFINITION = "org.wso2.iot.devices.accelerometer"; + private static final String GYROSCOPE_STREAM_DEFINITION = "org.wso2.iot.devices.gyroscope"; + private static final String PRESSURE_STREAM_DEFINITION = "org.wso2.iot.devices.pressure"; + private static final String GRAVITY_STREAM_DEFINITION = "org.wso2.iot.devices.gravity"; + private static final String ROTATION_STREAM_DEFINITION = "org.wso2.iot.devices.rotation"; + + private static final String SENSOR_ACCELEROMETER = "accelerometer"; + private static final String SENSOR_GYROSCOPE = "gyroscope"; + private static final String SENSOR_PRESSURE = "pressure"; + private static final String SENSOR_GRVITY = "gravity"; + private static final String SENSOR_ROTATION = "rotation"; + private static final String SENSOR_LIGHT = "light"; + private static final String SENSOR_GPS = "gps"; + + ///////////////////////////////////////////////////////////////////////////////////////////// + private static final String SENSOR_BATTERY = "battery"; + private static final String SENSOR_MAGNETIC = "magnetic"; + private static Log log = LogFactory.getLog(AndroidSenseService.class); + + //TODO; replace this tenant domain + private final String SUPER_TENANT = "carbon.super"; + + @Context //injected response proxy supporting multiple thread + private HttpServletResponse response; + + @Path("manager/device") @PUT public boolean register(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner) { + + DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT); + + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(deviceId); + deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE); + try { + if (deviceManagement.getDeviceManagementService().isEnrolled(deviceIdentifier)) { + response.setStatus(Response.Status.CONFLICT.getStatusCode()); + return true; + } + Device device = new Device(); + device.setDeviceIdentifier(deviceId); + EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); + + enrolmentInfo.setDateOfEnrolment(new Date().getTime()); + enrolmentInfo.setDateOfLastUpdate(new Date().getTime()); + enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE); + enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD); + String name = owner + " android " + deviceId; + device.setName(name); + device.setType(AndroidSenseConstants.DEVICE_TYPE); + enrolmentInfo.setOwner(owner); + device.setEnrolmentInfo(enrolmentInfo); + boolean added = deviceManagement.getDeviceManagementService().enrollDevice(device); + + if (added) { + response.setStatus(Response.Status.OK.getStatusCode()); + } else { + response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode()); + } + + return added; + } catch (DeviceManagementException e) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + return false; + } finally { + deviceManagement.endTenantFlow(); + } + } + + @Path("manager/device/remove/{device_id}") @DELETE public void removeDevice(@PathParam("device_id") String deviceId, + @Context HttpServletResponse response) { + + DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(deviceId); + deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE); + try { + boolean removed = deviceManagement.getDeviceManagementService().disenrollDevice(deviceIdentifier); + if (removed) { + response.setStatus(Response.Status.OK.getStatusCode()); + + } else { + response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode()); + + } + } catch (DeviceManagementException e) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + } finally { + deviceManagement.endTenantFlow(); + } + + } + + @Path("manager/device/update/{device_id}") @POST + public boolean updateDevice(@PathParam("device_id") String deviceId, + @QueryParam("name") String name, + @Context HttpServletResponse response) { + + DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT); + + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(deviceId); + deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE); + try { + Device device = deviceManagement.getDeviceManagementService().getDevice(deviceIdentifier); + device.setDeviceIdentifier(deviceId); + + // device.setDeviceTypeId(deviceTypeId); + device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime()); + + device.setName(name); + device.setType(AndroidSenseConstants.DEVICE_TYPE); + + boolean updated = deviceManagement.getDeviceManagementService().modifyEnrollment(device); + + if (updated) { + response.setStatus(Response.Status.OK.getStatusCode()); + + } else { + response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode()); + + } + return updated; + } catch (DeviceManagementException e) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + return false; + } finally { + deviceManagement.endTenantFlow(); + } + + } + + @Path("manager/device/{device_id}") @GET @Consumes("application/json") @Produces("application/json") public Device getDevice( + @PathParam("device_id") String deviceId) { + + DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(deviceId); + deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE); + + try { + return deviceManagement.getDeviceManagementService().getDevice(deviceIdentifier); + + } catch (DeviceManagementException e) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + return null; + } finally { + deviceManagement.endTenantFlow(); + } + + } + + /* Service to push all the sensor data collected by the Android + Called by the Android device */ + @Path("controller/sensordata") @POST @Consumes(MediaType.APPLICATION_JSON) + public void pushSensorData(final DeviceJSON dataMsg, @Context HttpServletResponse response) { + + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + ctx.setTenantDomain("carbon.super", true); + DeviceAnalyticsService deviceAnalyticsService = (DeviceAnalyticsService) ctx + .getOSGiService(DeviceAnalyticsService.class, null); + + SensorJSON[] sensorData = dataMsg.values; + String streamDef = null; + Object payloadData[] = null; + String sensorName = null; + + for (SensorJSON sensor : sensorData) { + switch (sensor.key) { + case "battery": + streamDef = BATTERY_STREAM_DEFINITION; + payloadData = new Object[] { Float.parseFloat(sensor.value) }; + sensorName = SENSOR_BATTERY; + break; + case "GPS": + streamDef = GPS_STREAM_DEFINITION; + String gpsValue = sensor.value; + String gpsValues[] = gpsValue.split(","); + Float gpsValuesF[] = new Float[2]; + gpsValuesF[0] = Float.parseFloat(gpsValues[0]); + gpsValuesF[1] = Float.parseFloat(gpsValues[0]); + payloadData = gpsValuesF; + sensorName = SENSOR_GPS; + break; + default: + try { + int androidSensorId = Integer.parseInt(sensor.key); + + if (androidSensorId == 2) { + streamDef = MAGNETIC_STREAM_DEFINITION; + String value = sensor.value; + String valuesM[] = value.split(","); + Float gValuesF[] = new Float[1]; + gValuesF[0] = Float.parseFloat(valuesM[0]) * Float.parseFloat(valuesM[0]) * Float + .parseFloat(valuesM[0]); + payloadData = gValuesF; + sensorName = SENSOR_MAGNETIC; + } else if (androidSensorId == 5) { + streamDef = LIGHT_STREAM_DEFINITION; + sensorName = SENSOR_LIGHT; + payloadData = new Object[] { Float.parseFloat(sensor.value) }; + }else if(androidSensorId == 1){ + streamDef = ACCELEROMETER_STREAM_DEFINITION; + String value = sensor.value; + String valuesM[] = value.split(","); + Float gValuesF[] = new Float[1]; + gValuesF[0] = Float.parseFloat(valuesM[0]) * Float.parseFloat(valuesM[0]) * Float + .parseFloat(valuesM[0]); + payloadData = gValuesF; + sensorName = SENSOR_ACCELEROMETER; + } + //Add the remaining sensor types. + + } catch (NumberFormatException e) { + continue; + } + + } + Object metdaData[] = { dataMsg.owner, AndroidSenseConstants.DEVICE_TYPE, dataMsg.deviceId, sensor.time }; + + if (streamDef != null && payloadData != null && payloadData.length > 0) { + try { + SensorDataManager.getInstance() + .setSensorRecord(dataMsg.deviceId, sensorName, sensor.value, sensor.time); + deviceAnalyticsService.publishEvent(streamDef, "1.0.0", metdaData, new Object[0], payloadData); + } catch (DataPublisherConfigurationException e) { + response.setStatus(Response.Status.UNSUPPORTED_MEDIA_TYPE.getStatusCode()); + } + } + + } + + } + + //TODO below endpoints needs to be removed and cep websocket have to be added + @Path("controller/readlight") + @GET + @Consumes("application/json") + @Produces("application/json") + public SensorRecord readLight( + @HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId, + @Context HttpServletResponse response) { + SensorRecord sensorRecord = null; + + try { + sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId, SENSOR_LIGHT); + } catch (DeviceControllerException e) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + } + + response.setStatus(Response.Status.OK.getStatusCode()); + return sensorRecord; + } + + @Path("controller/readbattery") + @GET + @Consumes("application/json") + @Produces("application/json") + public SensorRecord readBattery( + @HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId, + @Context HttpServletResponse response) { + SensorRecord sensorRecord = null; + + try { + sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId, SENSOR_BATTERY); + } catch (DeviceControllerException e) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + } + + response.setStatus(Response.Status.OK.getStatusCode()); + return sensorRecord; + } + + @Path("controller/readgps") + @GET + @Consumes("application/json") + @Produces("application/json") + public SensorRecord readGPS( + @HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId, + @Context HttpServletResponse response) { + SensorRecord sensorRecord = null; + + try { + sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId, SENSOR_GPS); + } catch (DeviceControllerException e) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + } + + response.setStatus(Response.Status.OK.getStatusCode()); + return sensorRecord; + } + + + @Path("controller/readmagnetic") + @GET + @Consumes("application/json") + @Produces("application/json") + public SensorRecord readMagnetic(@HeaderParam("owner") String owner, + @HeaderParam("deviceId") String deviceId, + @Context HttpServletResponse response) { + SensorRecord sensorRecord = null; + + try { + sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId, SENSOR_MAGNETIC); + } catch (DeviceControllerException e) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + } + + response.setStatus(Response.Status.OK.getStatusCode()); + return sensorRecord; + } + + /** + * Created by Menaka + * Adding Accelerometer + * */ + + @Path("controller/readaccelerometer") + @GET + @Consumes("application/json") + @Produces("application/json") + public SensorRecord readAccelerometer(@HeaderParam("owner") String owner, + @HeaderParam("deviceId") String deviceId, + @Context HttpServletResponse response) { + SensorRecord sensorRecord = null; + + try { + sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId, SENSOR_ACCELEROMETER); + } catch (DeviceControllerException e) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + } + + response.setStatus(Response.Status.OK.getStatusCode()); + return sensorRecord; + } + + +} diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/DeviceJSON.java b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/DeviceJSON.java new file mode 100644 index 0000000000..0c7c13d821 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/DeviceJSON.java @@ -0,0 +1,15 @@ +package org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceJSON { + @XmlElement(required = true) public String owner; + @XmlElement(required = true) public String deviceId; + @XmlElement public SensorJSON[] values; +} diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorJSON.java b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorJSON.java new file mode 100644 index 0000000000..70c7f7cf3b --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorJSON.java @@ -0,0 +1,16 @@ +package org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement + +@JsonIgnoreProperties(ignoreUnknown = true) +public class SensorJSON { + + @XmlElement public Long time; + @XmlElement public String key; + @XmlElement public String value; +} diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/resources.xml b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/resources.xml new file mode 100644 index 0000000000..fda8f3253c --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/resources.xml @@ -0,0 +1,93 @@ + + + + + + + + + Any + PUT + http://localhost:9763/android_sense/manager/device/register + /manager/device/register/* + + + Any + DELETE + http://localhost:9763/android_sense/manager/device/remove + /manager/device/remove/* + + + Any + POST + http://localhost:9763/android_sense/manager/device/update + /manager/device/update/* + + + Any + GET + http://localhost:9763/android_sense/manager/device/{device_id} + /manager/device/{device_id} + + + Any + GET + http://localhost:9763/android_sense/controller/sensordata + /controller/sensordata + + + Any + GET + http://localhost:9763/android_sense/controller/readbattery + /controller/readbattery + + + Any + GET + http://localhost:9763/android_sense/controller/readlight + /controller/readlight + + + Any + GET + http://localhost:9763/android_sense/controller/readgps + /controller/readgps + + + Any + GET + http://localhost:9763/android_sense/controller/readmagnetic + /controller/readmagnetic + + + Any + GET + http://localhost:9763/android_sense/controller/readaccelerometer + /controller/readaccelerometer + + diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/webapp-classloading.xml new file mode 100644 index 0000000000..fa44619195 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -0,0 +1,33 @@ + + + + + + + + + false + + + CXF,Carbon + diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/cxf-servlet.xml new file mode 100644 index 0000000000..8b00045b87 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..5227008858 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,73 @@ + + + Android Sense + Android Sense + + + CXFServlet + org.apache.cxf.transport.servlet.CXFServlet + 1 + + + + + CXFServlet + /* + + + + isAdminService + false + + + doAuthentication + false + + + + + managed-api-enabled + true + + + managed-api-owner + admin + + + managed-api-name + android_sense + + + managed-api-endpoint + http://localhost:9763/android_sense + + + managed-api-version + 1.0.0 + + + managed-api-context + /android_sense + + + managed-api-isSecured + true + + + + + + + + + + + + + + + diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/pom.xml b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/pom.xml new file mode 100644 index 0000000000..a0d9ebaa48 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/pom.xml @@ -0,0 +1,117 @@ + + + + + + + device-mgt-iot-androidsense + org.wso2.carbon.devicemgt-plugins + 1.9.2-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.iot.androidsense + ${carbon.iot.device.mgt.version} + bundle + WSO2 Carbon - Android Sense Management Impl + WSO2 Carbon - Android Sense Management and Control Implementation + http://wso2.org + + + + + org.apache.felix + maven-scr-plugin + + + maven-compiler-plugin + + 1.7 + 1.7 + + 2.3.2 + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.iot.device.mgt.version} + IoT Server Impl Bundle + org.wso2.carbon.device.mgt.iot.androidsense.plugin.internal + + org.osgi.framework, + org.osgi.service.component, + org.apache.commons.logging, + javax.xml.bind.*, + javax.naming, + javax.sql, + javax.xml.bind.annotation.*, + javax.xml.parsers, + javax.net, + javax.net.ssl, + org.w3c.dom, + org.wso2.carbon.device.mgt.common.*, + org.wso2.carbon.device.mgt.common, + org.wso2.carbon.context.*, + org.wso2.carbon.ndatasource.core, + org.wso2.carbon.device.mgt.iot.*, + + + + !org.wso2.carbon.device.mgt.iot.androidsense.plugin.internal, + org.wso2.carbon.device.mgt.iot.androidsense.plugin.* + + + + + + + + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + + org.wso2.carbon + org.wso2.carbon.logging + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + + + org.wso2.carbon + org.wso2.carbon.ndatasource.core + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot + + + + + + \ No newline at end of file diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/constants/AndroidSenseConstants.java b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/constants/AndroidSenseConstants.java new file mode 100644 index 0000000000..1c69899756 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/constants/AndroidSenseConstants.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants; + +public class AndroidSenseConstants { + + public final static String DEVICE_TYPE = "android_sense"; + public final static String DEVICE_PLUGIN_DEVICE_NAME = "DEVICE_NAME"; + public final static String DEVICE_PLUGIN_DEVICE_ID = "ANDROID_DEVICE_ID"; + +} diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/AndroidSenseManager.java b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/AndroidSenseManager.java new file mode 100644 index 0000000000..01a7ddde35 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/AndroidSenseManager.java @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.DeviceManager; +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.common.FeatureManager; +import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +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.util.iotdevice.dao.IotDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.dto.IotDevice; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.util.IotDeviceManagementUtil; +import org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.dao.AndroidSenseDAO; + + +import java.util.ArrayList; +import java.util.List; + + +/** + * This represents the Android implementation of DeviceManagerService. + */ +public class AndroidSenseManager implements DeviceManager { + + private static final IotDeviceManagementDAOFactory iotDeviceManagementDAOFactory = new AndroidSenseDAO(); + private static final Log log = LogFactory.getLog(AndroidSenseManager.class); + + + @Override + public FeatureManager getFeatureManager() { + return null; + } + + @Override + public boolean saveConfiguration(TenantConfiguration tenantConfiguration) + throws DeviceManagementException { + //TODO implement this + return false; + } + + @Override + public TenantConfiguration getConfiguration() throws DeviceManagementException { + //TODO implement this + return null; + } + + @Override + public boolean enrollDevice(Device device) throws DeviceManagementException { + boolean status; + IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device); + try { + if (log.isDebugEnabled()) { + log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier()); + } + AndroidSenseDAO.beginTransaction(); + status = iotDeviceManagementDAOFactory.getIotDeviceDAO().addIotDevice( + iotDevice); + AndroidSenseDAO.commitTransaction(); + } catch (IotDeviceManagementDAOException e) { + try { + AndroidSenseDAO.rollbackTransaction(); + } catch (IotDeviceManagementDAOException iotDAOEx) { + String msg = "Error occurred while roll back the device enrol transaction :" + device.toString(); + log.warn(msg, iotDAOEx); + } + String msg = "Error while enrolling the Android device : " + device.getDeviceIdentifier(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + return status; + } + + @Override + public boolean modifyEnrollment(Device device) throws DeviceManagementException { + boolean status; + IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device); + try { + if (log.isDebugEnabled()) { + log.debug("Modifying the Android device enrollment data"); + } + AndroidSenseDAO.beginTransaction(); + status = iotDeviceManagementDAOFactory.getIotDeviceDAO() + .updateIotDevice(iotDevice); + AndroidSenseDAO.commitTransaction(); + } catch (IotDeviceManagementDAOException e) { + try { + AndroidSenseDAO.rollbackTransaction(); + } catch (IotDeviceManagementDAOException iotDAOEx) { + String msg = "Error occurred while roll back the update device transaction :" + device.toString(); + log.warn(msg, iotDAOEx); + } + String msg = "Error while updating the enrollment of the Android device : " + + device.getDeviceIdentifier(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + return status; + } + + @Override + public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + boolean status; + try { + if (log.isDebugEnabled()) { + log.debug("Dis-enrolling Android device : " + deviceId); + } + AndroidSenseDAO.beginTransaction(); + status = iotDeviceManagementDAOFactory.getIotDeviceDAO() + .deleteIotDevice(deviceId.getId()); + AndroidSenseDAO.commitTransaction(); + } catch (IotDeviceManagementDAOException e) { + try { + AndroidSenseDAO.rollbackTransaction(); + } catch (IotDeviceManagementDAOException iotDAOEx) { + String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString(); + log.warn(msg, iotDAOEx); + } + String msg = "Error while removing the Android device : " + deviceId.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + return status; + } + + @Override + public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { + boolean isEnrolled = false; + try { + if (log.isDebugEnabled()) { + log.debug("Checking the enrollment of Android device : " + deviceId.getId()); + } + IotDevice iotDevice = + iotDeviceManagementDAOFactory.getIotDeviceDAO().getIotDevice( + deviceId.getId()); + if (iotDevice != null) { + isEnrolled = true; + } + } catch (IotDeviceManagementDAOException e) { + String msg = "Error while checking the enrollment status of Android device : " + + deviceId.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + return isEnrolled; + } + + @Override + public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { + return true; + } + + @Override + public boolean setActive(DeviceIdentifier deviceId, boolean status) + throws DeviceManagementException { + return true; + } + + @Override + public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + Device device; + try { + if (log.isDebugEnabled()) { + log.debug("Getting the details of Android device : " + deviceId.getId()); + } + IotDevice iotDevice = iotDeviceManagementDAOFactory.getIotDeviceDAO(). + getIotDevice(deviceId.getId()); + device = IotDeviceManagementUtil.convertToDevice(iotDevice); + } catch (IotDeviceManagementDAOException e) { + String msg = "Error while fetching the Android device : " + deviceId.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + return device; + } + + @Override + public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) + throws DeviceManagementException { + return true; + } + + public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { + return false; + } + + @Override + public boolean setStatus(DeviceIdentifier deviceId, String currentOwner, + EnrolmentInfo.Status status) throws DeviceManagementException { + return false; + } + + @Override + public License getLicense(String s) throws LicenseManagementException { + return null; + } + + @Override + public void addLicense(License license) throws LicenseManagementException { + + } + + @Override public boolean requireDeviceAuthorization() { + return false; + } + + @Override + public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { + boolean status; + IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device); + try { + if (log.isDebugEnabled()) { + log.debug( + "updating the details of Android device : " + deviceIdentifier); + } + AndroidSenseDAO.beginTransaction(); + status = iotDeviceManagementDAOFactory.getIotDeviceDAO() + .updateIotDevice(iotDevice); + AndroidSenseDAO.commitTransaction(); + } catch (IotDeviceManagementDAOException e) { + try { + AndroidSenseDAO.rollbackTransaction(); + } catch (IotDeviceManagementDAOException iotDAOEx) { + String msg = "Error occurred while roll back the update device info transaction :" + device.toString(); + log.warn(msg, iotDAOEx); + } + String msg = + "Error while updating the Android device : " + deviceIdentifier; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + return status; + } + + @Override + public List getAllDevices() throws DeviceManagementException { + List devices = null; + try { + if (log.isDebugEnabled()) { + log.debug("Fetching the details of all Android devices"); + } + List iotDevices = + iotDeviceManagementDAOFactory.getIotDeviceDAO().getAllIotDevices(); + if (iotDevices != null) { + devices = new ArrayList(); + for (IotDevice iotDevice : iotDevices) { + devices.add(IotDeviceManagementUtil.convertToDevice(iotDevice)); + } + } + } catch (IotDeviceManagementDAOException e) { + String msg = "Error while fetching all Android devices."; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + return devices; + } + +} \ No newline at end of file diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/AndroidSenseManagerService.java b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/AndroidSenseManagerService.java new file mode 100644 index 0000000000..765ddd2ee2 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/AndroidSenseManagerService.java @@ -0,0 +1,90 @@ +package org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl; + +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.DeviceManager; +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.app.mgt.ApplicationManager; +import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants; + +import java.util.List; + +public class AndroidSenseManagerService implements DeviceManagementService { + private DeviceManager deviceManager; + @Override + public String getType() { + return AndroidSenseConstants.DEVICE_TYPE; + } + + @Override + public String getProviderTenantDomain() { + return "carbon.super"; + } + + @Override + public boolean isSharedWithAllTenants() { + return true; + } + + @Override + public String[] getSharedTenantsDomain() { + return new String[0]; + } + + @Override + public void init() throws DeviceManagementException { + this.deviceManager=new AndroidSenseManager(); + } + + @Override + public DeviceManager getDeviceManager() { + return deviceManager; + } + + @Override + public ApplicationManager getApplicationManager() { + return null; + } + + @Override public void notifyOperationToDevices(Operation operation, List list) + throws DeviceManagementException { + + } + + @Override + public Application[] getApplications(String domain, int pageNumber, int size) + throws ApplicationManagementException { + return new Application[0]; + } + + @Override + public void updateApplicationStatus(DeviceIdentifier deviceId, Application application, + String status) throws ApplicationManagementException { + + } + + @Override + public String getApplicationStatus(DeviceIdentifier deviceId, Application application) + throws ApplicationManagementException { + return null; + } + + @Override public void installApplicationForDevices(Operation operation, List list) + throws ApplicationManagementException { + + } + + @Override public void installApplicationForUsers(Operation operation, List list) + throws ApplicationManagementException { + + } + + @Override public void installApplicationForUserRoles(Operation operation, List list) + throws ApplicationManagementException { + + } + +} diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/dao/AndroidSenseDAO.java b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/dao/AndroidSenseDAO.java new file mode 100644 index 0000000000..0d4324b156 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/dao/AndroidSenseDAO.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.dao; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactoryInterface; +import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants; +import org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.dao.impl.AndroidSenseDAOImpl; + + + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.SQLException; + +public class AndroidSenseDAO extends IotDeviceManagementDAOFactory implements IotDeviceManagementDAOFactoryInterface { + + private static final Log log = LogFactory.getLog(AndroidSenseDAO.class); + static DataSource dataSource; + private static ThreadLocal currentConnection = new ThreadLocal(); + + public AndroidSenseDAO() { + initAndroidDAO(); + } + + public static void initAndroidDAO() { + dataSource = getDataSourceMap().get(AndroidSenseConstants.DEVICE_TYPE); + } + + @Override public IotDeviceDAO getIotDeviceDAO() { + return new AndroidSenseDAOImpl(); + } + + public static void beginTransaction() throws IotDeviceManagementDAOException { + try { + Connection conn = dataSource.getConnection(); + conn.setAutoCommit(false); + currentConnection.set(conn); + } catch (SQLException e) { + throw new IotDeviceManagementDAOException("Error occurred while retrieving datasource connection", e); + } + } + + public static Connection getConnection() throws IotDeviceManagementDAOException { + if (currentConnection.get() == null) { + try { + currentConnection.set(dataSource.getConnection()); + } catch (SQLException e) { + throw new IotDeviceManagementDAOException("Error occurred while retrieving data source connection", e); + } + } + return currentConnection.get(); + } + + public static void commitTransaction() throws IotDeviceManagementDAOException { + try { + Connection conn = currentConnection.get(); + if (conn != null) { + conn.commit(); + } else { + if (log.isDebugEnabled()) { + log.debug("Datasource connection associated with the current thread is null, hence commit " + + "has not been attempted"); + } + } + } catch (SQLException e) { + throw new IotDeviceManagementDAOException("Error occurred while committing the transaction", e); + } finally { + closeConnection(); + } + } + + public static void closeConnection() throws IotDeviceManagementDAOException { + + Connection con = currentConnection.get(); + if (con != null) { + try { + con.close(); + } catch (SQLException e) { + log.error("Error occurred while close the connection"); + } + } + currentConnection.remove(); + } + + public static void rollbackTransaction() throws IotDeviceManagementDAOException { + try { + Connection conn = currentConnection.get(); + if (conn != null) { + conn.rollback(); + } else { + if (log.isDebugEnabled()) { + log.debug("Datasource connection associated with the current thread is null, hence rollback " + + "has not been attempted"); + } + } + } catch (SQLException e) { + throw new IotDeviceManagementDAOException("Error occurred while rollback the transaction", e); + } finally { + closeConnection(); + } + } +} \ No newline at end of file diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/dao/impl/AndroidSenseDAOImpl.java b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/dao/impl/AndroidSenseDAOImpl.java new file mode 100644 index 0000000000..7440dfd854 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/dao/impl/AndroidSenseDAOImpl.java @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.dao.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants; +import org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.dao.AndroidSenseDAO; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.util.IotDeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.iot.util.iotdevice.dto.IotDevice; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Implements IotDeviceDAO for android Devices. + */ +public class AndroidSenseDAOImpl implements IotDeviceDAO{ + + + private static final Log log = LogFactory.getLog(AndroidSenseDAOImpl.class); + + @Override + public IotDevice getIotDevice(String iotDeviceId) + throws IotDeviceManagementDAOException { + Connection conn = null; + PreparedStatement stmt = null; + IotDevice iotDevice = null; + ResultSet resultSet = null; + try { + conn = AndroidSenseDAO.getConnection(); + String selectDBQuery = + "SELECT ANDROID_DEVICE_ID, DEVICE_NAME" + + " FROM ANDROID_SENSE_DEVICE WHERE ANDROID_DEVICE_ID = ?"; + stmt = conn.prepareStatement(selectDBQuery); + stmt.setString(1, iotDeviceId); + resultSet = stmt.executeQuery(); + + if (resultSet.next()) { + iotDevice = new IotDevice(); + iotDevice.setIotDeviceName(resultSet.getString( + AndroidSenseConstants.DEVICE_PLUGIN_DEVICE_NAME)); + Map propertyMap = new HashMap(); + + + + iotDevice.setDeviceProperties(propertyMap); + + if (log.isDebugEnabled()) { + log.debug("Android device " + iotDeviceId + " data has been fetched from " + + "Android database."); + } + } + } catch (SQLException e) { + String msg = "Error occurred while fetching Android device : '" + iotDeviceId + "'"; + log.error(msg, e); + throw new IotDeviceManagementDAOException(msg, e); + } finally { + IotDeviceManagementDAOUtil.cleanupResources(stmt, resultSet); + AndroidSenseDAO.closeConnection(); + } + + return iotDevice; + } + + @Override + public boolean addIotDevice(IotDevice iotDevice) + throws IotDeviceManagementDAOException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = AndroidSenseDAO.getConnection(); + String createDBQuery = + "INSERT INTO ANDROID_SENSE_DEVICE(ANDROID_DEVICE_ID, DEVICE_NAME) VALUES (?, ?)"; + + stmt = conn.prepareStatement(createDBQuery); + stmt.setString(1, iotDevice.getIotDeviceId()); + stmt.setString(2,iotDevice.getIotDeviceName()); + if (iotDevice.getDeviceProperties() == null) { + iotDevice.setDeviceProperties(new HashMap()); + } + + + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + if (log.isDebugEnabled()) { + log.debug("Android device " + iotDevice.getIotDeviceId() + " data has been" + + " added to the Android database."); + } + } + } catch (SQLException e) { + String msg = "Error occurred while adding the Android device '" + + iotDevice.getIotDeviceId() + "' to the Android db."; + log.error(msg, e); + throw new IotDeviceManagementDAOException(msg, e); + } finally { + IotDeviceManagementDAOUtil.cleanupResources(stmt, null); + } + return status; + } + + @Override + public boolean updateIotDevice(IotDevice iotDevice) + throws IotDeviceManagementDAOException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = AndroidSenseDAO.getConnection(); + String updateDBQuery = + "UPDATE ANDROID_SENSE_DEVICE SET DEVICE_NAME = ? WHERE ANDROID_DEVICE_ID = ?"; + + stmt = conn.prepareStatement(updateDBQuery); + + if (iotDevice.getDeviceProperties() == null) { + iotDevice.setDeviceProperties(new HashMap()); + } + stmt.setString(1, iotDevice.getIotDeviceName()); + + stmt.setString(2, iotDevice.getIotDeviceId()); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + if (log.isDebugEnabled()) { + log.debug("Android device " + iotDevice.getIotDeviceId() + " data has been" + + " modified."); + } + } + } catch (SQLException e) { + String msg = "Error occurred while modifying the Android device '" + + iotDevice.getIotDeviceId() + "' data."; + log.error(msg, e); + throw new IotDeviceManagementDAOException(msg, e); + } finally { + IotDeviceManagementDAOUtil.cleanupResources(stmt, null); + } + return status; + } + + @Override + public boolean deleteIotDevice(String iotDeviceId) + throws IotDeviceManagementDAOException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = AndroidSenseDAO.getConnection(); + String deleteDBQuery = + "DELETE FROM ANDROID_SENSE_DEVICE WHERE ANDROID_DEVICE_ID = ?"; + stmt = conn.prepareStatement(deleteDBQuery); + stmt.setString(1, iotDeviceId); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + if (log.isDebugEnabled()) { + log.debug("Android device " + iotDeviceId + " data has deleted" + + " from the Android database."); + } + } + } catch (SQLException e) { + String msg = "Error occurred while deleting Android device " + iotDeviceId; + log.error(msg, e); + throw new IotDeviceManagementDAOException(msg, e); + } finally { + IotDeviceManagementDAOUtil.cleanupResources(stmt, null); + } + return status; + } + + @Override + public List getAllIotDevices() + throws IotDeviceManagementDAOException { + + Connection conn = null; + PreparedStatement stmt = null; + ResultSet resultSet = null; + IotDevice iotDevice; + List iotDevices = new ArrayList(); + + try { + conn = AndroidSenseDAO.getConnection(); + String selectDBQuery = + "SELECT ANDROID_DEVICE_ID, DEVICE_NAME " + + "FROM ANDROID_SENSE_DEVICE"; + stmt = conn.prepareStatement(selectDBQuery); + resultSet = stmt.executeQuery(); + while (resultSet.next()) { + iotDevice = new IotDevice(); + iotDevice.setIotDeviceId(resultSet.getString(AndroidSenseConstants.DEVICE_PLUGIN_DEVICE_ID)); + iotDevice.setIotDeviceName(resultSet.getString(AndroidSenseConstants.DEVICE_PLUGIN_DEVICE_NAME)); + + Map propertyMap = new HashMap(); + + iotDevice.setDeviceProperties(propertyMap); + iotDevices.add(iotDevice); + } + if (log.isDebugEnabled()) { + log.debug("All Android device details have fetched from Android database."); + } + return iotDevices; + } catch (SQLException e) { + String msg = "Error occurred while fetching all Android device data'"; + log.error(msg, e); + throw new IotDeviceManagementDAOException(msg, e); + } finally { + IotDeviceManagementDAOUtil.cleanupResources(stmt, resultSet); + AndroidSenseDAO.closeConnection(); + } + + } + + } \ No newline at end of file diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/util/AndroidSenseUtils.java b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/util/AndroidSenseUtils.java new file mode 100644 index 0000000000..3745691b53 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/util/AndroidSenseUtils.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.Map; + +/** + * Contains utility methods used by Android plugin. + */ +public class AndroidSenseUtils { + + private static Log log = LogFactory.getLog(AndroidSenseUtils.class); + + public static String getDeviceProperty(Map deviceProperties, String property) { + + String deviceProperty = deviceProperties.get(property); + + if (deviceProperty == null) { + return ""; + } + + return deviceProperty; + } + + +} diff --git a/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/internal/AndroidSenseManagementServiceComponent.java b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/internal/AndroidSenseManagementServiceComponent.java new file mode 100644 index 0000000000..fc7f3df064 --- /dev/null +++ b/components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/internal/AndroidSenseManagementServiceComponent.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.iot.androidsense.plugin.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.AndroidSenseManagerService; +import org.wso2.carbon.device.mgt.iot.service.DeviceTypeService; + + + +/** + * @scr.component name="org.wso2.carbon.device.mgt.iot.android.internal.AndroidSenseManagementServiceComponent" + * immediate="true" + * @scr.reference name="wso2.carbon.device.mgt.iot.service.DeviceTypeServiceImpl" + * interface="org.wso2.carbon.device.mgt.iot.service.DeviceTypeService" + * cardinality="1..1" + * policy="dynamic" + * bind="setDeviceTypeService" + * unbind="unsetDeviceTypeService" + */ +public class AndroidSenseManagementServiceComponent { + + + private ServiceRegistration androidServiceRegRef; + + + + private static final Log log = LogFactory.getLog(AndroidSenseManagementServiceComponent.class); + protected void activate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("Activating Android Device Management Service Component"); + } + try { + BundleContext bundleContext = ctx.getBundleContext(); + + + androidServiceRegRef = + bundleContext.registerService(DeviceManagementService.class.getName(), new AndroidSenseManagerService(), null); + + + + if (log.isDebugEnabled()) { + log.debug("Android Device Management Service Component has been successfully activated"); + } + } catch (Throwable e) { + log.error("Error occurred while activating Android Device Management Service Component", e); + } + } + + protected void deactivate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("De-activating Android Device Management Service Component"); + } + try { + if (androidServiceRegRef != null) { + androidServiceRegRef.unregister(); + } + + if (log.isDebugEnabled()) { + log.debug( + "Android Device Management Service Component has been successfully de-activated"); + } + } catch (Throwable e) { + log.error("Error occurred while de-activating Android Device Management bundle", e); + } + } + + protected void setDeviceTypeService(DeviceTypeService deviceTypeService) { + /* This is to avoid this component getting initialized before the + common registered */ + if (log.isDebugEnabled()) { + log.debug("Data source service set to mobile service component"); + } + } + + protected void unsetDeviceTypeService(DeviceTypeService deviceTypeService) { + //do nothing + } + + + +} diff --git a/components/device-mgt-iot-androidsense/pom.xml b/components/device-mgt-iot-androidsense/pom.xml new file mode 100644 index 0000000000..95e0c843d0 --- /dev/null +++ b/components/device-mgt-iot-androidsense/pom.xml @@ -0,0 +1,62 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + carbon-device-mgt-plugins-parent + 1.9.2-SNAPSHOT + ../../pom.xml + + + 4.0.0 + device-mgt-iot-androidsense + 1.9.2-SNAPSHOT + pom + WSO2 Carbon - IoT Device Android Sense Management Component + http://wso2.org + + + org.wso2.carbon.device.mgt.iot.androidsense + org.wso2.carbon.device.mgt.iot.androidsense.api + + + + + + + org.apache.felix + maven-scr-plugin + 1.7.2 + + + generate-scr-scrdescriptor + + scr + + + + + + + + \ No newline at end of file diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml new file mode 100644 index 0000000000..f4007e4b5a --- /dev/null +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml @@ -0,0 +1,139 @@ + + + + + + + + org.wso2.carbon.devicemgt-plugins + device-mgt-iot-androidsense-feature + 1.9.2-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.iot.androidsense.feature + pom + 1.9.2-SNAPSHOT + WSO2 Carbon - IoT Server Android Sense Feature + http://wso2.org + This feature contains the Android Sense Device type specific implementations for the IoT Server + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense.api + war + + + + + + + maven-resources-plugin + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-jaxrs-war + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense.api + war + true + ${basedir}/src/main/resources/webapps/ + android_sense.war + + + + + + + + + org.wso2.maven + carbon-p2-plugin + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.iot.androidsense + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.androidsense:${carbon.iot.device.mgt.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version} + + + + + + + + diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/androidsense.apk b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/androidsense.apk new file mode 100644 index 0000000000..0c86f8395d Binary files /dev/null and b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/androidsense.apk differ diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/sketch.properties b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/sketch.properties new file mode 100644 index 0000000000..aefe1a60bf --- /dev/null +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/sketch.properties @@ -0,0 +1,2 @@ +templates=androidsense.apk +zipfilename=androidsense.zip \ No newline at end of file diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/build.properties b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/build.properties new file mode 100644 index 0000000000..93c4b10701 --- /dev/null +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/build.properties @@ -0,0 +1 @@ +custom = true \ No newline at end of file diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/h2_android_sense.sql b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/h2_android_sense.sql new file mode 100644 index 0000000000..218cdbf05c --- /dev/null +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/h2_android_sense.sql @@ -0,0 +1,11 @@ + +-- ----------------------------------------------------- +-- Table `ANDROID_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `ANDROID_SENSE_DEVICE` ( + `ANDROID_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`ANDROID_DEVICE_ID`) ); + + + diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mysql_android_sense.sql b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mysql_android_sense.sql new file mode 100644 index 0000000000..4637b4daf2 --- /dev/null +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mysql_android_sense.sql @@ -0,0 +1,12 @@ +-- ----------------------------------------------------- +-- Table `ANDROID_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `ANDROID_SENSE_DEVICE` ( + `ANDROID_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`ANDROID_DEVICE_ID`) ) +ENGINE = InnoDB; + + + + diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.androidsense-overview/androidsense-overview.hbs b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.androidsense-overview/androidsense-overview.hbs new file mode 100644 index 0000000000..737550d14d --- /dev/null +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.androidsense-overview/androidsense-overview.hbs @@ -0,0 +1,36 @@ +
+
+ {{unit "cdmf.unit.device.overview.androidsense-display-image"}} +
+
+
Device Overview - Android Sense
+ {{#defineZone "device-detail-properties"}} + + + + + + {{#if device.viewModel.udid}} + + {{/if}} + {{#if device.viewModel.phoneNumber}} + + {{/if}} + + + + + +
Device{{device.viewModel.vendor}} {{device.properties.model}}
Model{{device.viewModel.model}}
IMEI{{device.viewModel.imei}}
UDID{{device.viewModel.udid}}
Phone Number{{device.viewModel.phoneNumber}}
Status + {{#equal device.status "ACTIVE"}} Active{{/equal}} + {{#equal device.status "INACTIVE"}} Inactive{{/equal}} + {{#equal device.status "BLOCKED"}} Blocked{{/equal}} + {{#equal device.status "REMOVED"}} Removed{{/equal}} +
+ {{/defineZone}} +
Operations
+
+ {{unit "cdmf.unit.device.iot-operation" deviceType=device.type}} +
+
+
\ No newline at end of file diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.androidsense-overview/androidsense-overview.js b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.androidsense-overview/androidsense-overview.js new file mode 100644 index 0000000000..bd9503d3f6 --- /dev/null +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.androidsense-overview/androidsense-overview.js @@ -0,0 +1,25 @@ +function onRequest (context) { + var log = new Log("detail.js"); + var deviceType = request.getParameter("type"); + var deviceId = request.getParameter("id"); + + if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { + var deviceModule = require("/modules/device.js").deviceModule; + var device = deviceModule.viewDevice(deviceType, deviceId); + + if (device) { + var viewModel = {}; + var deviceInfo = device.properties.DEVICE_INFO; + if (deviceInfo != undefined && String(deviceInfo.toString()).length > 0) { + deviceInfo = parse(stringify(deviceInfo)); + viewModel.system = device.properties.IMEI; + viewModel.machine = "Android Sense"; + viewModel.vendor = device.properties.VENDOR; + } + device.viewModel = viewModel; + } + context.device = device; + + return context; + } +} \ No newline at end of file diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.androidsense-overview/androidsense-overview.json b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.androidsense-overview/androidsense-overview.json new file mode 100644 index 0000000000..688e939808 --- /dev/null +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.androidsense-overview/androidsense-overview.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ No newline at end of file diff --git a/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf new file mode 100644 index 0000000000..41a72428c5 --- /dev/null +++ b/features/device-mgt-iot-androidsense-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf @@ -0,0 +1,6 @@ +instructions.configure = \ +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.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/androidsense,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);\ diff --git a/features/device-mgt-iot-androidsense-feature/pom.xml b/features/device-mgt-iot-androidsense-feature/pom.xml new file mode 100644 index 0000000000..c608ddc4bf --- /dev/null +++ b/features/device-mgt-iot-androidsense-feature/pom.xml @@ -0,0 +1,41 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + carbon-device-mgt-plugins-parent + 1.9.2-SNAPSHOT + ../../pom.xml + + + 4.0.0 + device-mgt-iot-androidsense-feature + 1.9.2-SNAPSHOT + pom + WSO2 Carbon - IoT Server Android Sense Device Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.iot.androidsense.feature + + + diff --git a/pom.xml b/pom.xml index 7160bbba66..d65066782b 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,7 @@ components/device-mgt-iot-virtualfirealarm + components/device-mgt-iot-androidsense features/device-mgt-iot-feature @@ -59,6 +60,7 @@ features/device-mgt-iot-virtualfirealarm-feature + features/device-mgt-iot-androidsense-feature @@ -383,6 +385,23 @@ + + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense + ${carbon.iot.device.mgt.version} + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense.api + ${carbon.iot.device.mgt.version} + war + + + org.json.wso2 json