forked from community/device-mgt-plugins
Merge pull request #23 from charithag/master
Add Android Sense Feature, mdm appmgt and mdmmgt to plugins
commit
bca86e63e0
@ -0,0 +1,198 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>device-mgt-iot-androidsense</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.api</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>WSO2 Carbon - Android Sense API</name>
|
||||
<description>WSO2 Carbon - Android Sense Service API Implementation</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!-- CDM -->
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!--CXF -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--MQTT -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>mqtt-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--IOT -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpasyncclient</artifactId>
|
||||
<version>4.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--JAX-RS -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-jaxrs</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle.wso2</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.user.api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.queuing</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.base</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>jaxen</groupId>
|
||||
<artifactId>jaxen</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-fileupload.wso2</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.ant.wso2</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.ant.wso2</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.equinox</groupId>
|
||||
<artifactId>javax.servlet</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<source>${wso2.maven.compiler.source}</source>
|
||||
<target>${wso2.maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<warName>android_sense</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you 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.
|
||||
-->
|
||||
|
||||
<!-- This file contains the list of permissions that are associated with URL end points
|
||||
of the web app. Each permission should contain the name, permission path ,API path
|
||||
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||
For ex:
|
||||
Actual API endpoint: mdm-admin/1.0.0/devices/{device-id}
|
||||
URL to be represented here: /devices/*
|
||||
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||
it will result 403 error at the runtime.
|
||||
-->
|
||||
|
||||
<ResourceConfiguration>
|
||||
<!-- Device related APIs -->
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>PUT</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/manager/device/register</Uri>
|
||||
<UriTemplate>/manager/device/register/*</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>DELETE</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/manager/device/remove</Uri>
|
||||
<UriTemplate>/manager/device/remove/*</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>POST</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/manager/device/update</Uri>
|
||||
<UriTemplate>/manager/device/update/*</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/manager/device/{device_id}</Uri>
|
||||
<UriTemplate>/manager/device/{device_id}</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/sensordata</Uri>
|
||||
<UriTemplate>/controller/sensordata</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readbattery</Uri>
|
||||
<UriTemplate>/controller/readbattery</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readlight</Uri>
|
||||
<UriTemplate>/controller/readlight</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readgps</Uri>
|
||||
<UriTemplate>/controller/readgps</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readmagnetic</Uri>
|
||||
<UriTemplate>/controller/readmagnetic</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readaccelerometer</Uri>
|
||||
<UriTemplate>/controller/readaccelerometer</UriTemplate>
|
||||
</Resource>
|
||||
</ResourceConfiguration>
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<!--
|
||||
~ Copyright 2005-2013 WSO2, Inc. (http://wso2.com)
|
||||
~
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<!--
|
||||
This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
|
||||
-->
|
||||
<Classloading xmlns="http://wso2.org/projects/as/classloading">
|
||||
|
||||
<!-- Parent-first or child-first. Default behaviour is child-first.-->
|
||||
<ParentFirst>false</ParentFirst>
|
||||
|
||||
<!--
|
||||
Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
|
||||
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
|
||||
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
</Classloading>
|
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
||||
|
||||
|
||||
|
||||
<jaxrs:server id="AndroidSense" address="/">
|
||||
<jaxrs:serviceBeans>
|
||||
<bean id="AndroidSenseService"
|
||||
class="org.wso2.carbon.device.mgt.iot.androidsense.service.impl.AndroidSenseService"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
|
||||
</jaxrs:providers>
|
||||
</jaxrs:server>
|
||||
|
||||
</beans>
|
||||
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<web-app version="2.5"
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
metadata-complete="true">
|
||||
<display-name>Android Sense</display-name>
|
||||
<description>Android Sense</description>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<context-param>
|
||||
<param-name>isAdminService</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>doAuthentication</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
|
||||
<!--publish to apim-->
|
||||
<context-param>
|
||||
<param-name>managed-api-enabled</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-owner</param-name>
|
||||
<param-value>admin</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-name</param-name>
|
||||
<param-value>android_sense</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-endpoint</param-name>
|
||||
<param-value>http://localhost:9763/android_sense</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-version</param-name>
|
||||
<param-value>1.0.0</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-context</param-name>
|
||||
<param-value>/android_sense</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-isSecured</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
|
||||
<!-- Below configuration is used to redirect http requests to https -->
|
||||
<!--<security-constraint>-->
|
||||
<!--<web-resource-collection>-->
|
||||
<!--<web-resource-name>IoT</web-resource-name>-->
|
||||
<!--<url-pattern>/*</url-pattern>-->
|
||||
<!--</web-resource-collection>-->
|
||||
<!--<user-data-constraint>-->
|
||||
<!--<transport-guarantee>CONFIDENTIAL</transport-guarantee>-->
|
||||
<!--</user-data-constraint>-->
|
||||
<!--</security-constraint>-->
|
||||
|
||||
|
||||
</web-app>
|
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- ~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~ ~ WSO2 Inc. licenses this file to you 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. -->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>device-mgt-iot-androidsense</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense</artifactId>
|
||||
<version>${carbon.iot.device.mgt.version}</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - Android Sense Management Impl</name>
|
||||
<description>WSO2 Carbon - Android Sense Management and Control Implementation</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
<version>2.3.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.iot.device.mgt.version}</Bundle-Version>
|
||||
<Bundle-Description>IoT Server Impl Bundle</Bundle-Description>
|
||||
<Private-Package>org.wso2.carbon.device.mgt.iot.androidsense.plugin.internal</Private-Package>
|
||||
<Import-Package>
|
||||
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.*,
|
||||
</Import-Package>
|
||||
|
||||
<Export-Package>
|
||||
!org.wso2.carbon.device.mgt.iot.androidsense.plugin.internal,
|
||||
org.wso2.carbon.device.mgt.iot.androidsense.plugin.*
|
||||
</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
@ -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";
|
||||
|
||||
}
|
@ -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<Device> getAllDevices() throws DeviceManagementException {
|
||||
List<Device> devices = null;
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Fetching the details of all Android devices");
|
||||
}
|
||||
List<IotDevice> iotDevices =
|
||||
iotDeviceManagementDAOFactory.getIotDeviceDAO().getAllIotDevices();
|
||||
if (iotDevices != null) {
|
||||
devices = new ArrayList<Device>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -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<DeviceIdentifier> 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<DeviceIdentifier> list)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override public void installApplicationForUsers(Operation operation, List<String> list)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override public void installApplicationForUserRoles(Operation operation, List<String> list)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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<Connection> currentConnection = new ThreadLocal<Connection>();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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<String, String> propertyMap = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
||||
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<String, String>());
|
||||
}
|
||||
|
||||
|
||||
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<String, String>());
|
||||
}
|
||||
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<IotDevice> getAllIotDevices()
|
||||
throws IotDeviceManagementDAOException {
|
||||
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet resultSet = null;
|
||||
IotDevice iotDevice;
|
||||
List<IotDevice> iotDevices = new ArrayList<IotDevice>();
|
||||
|
||||
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<String, String> propertyMap = new HashMap<String, String>();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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<String, String> deviceProperties, String property) {
|
||||
|
||||
String deviceProperty = deviceProperties.get(property);
|
||||
|
||||
if (deviceProperty == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return deviceProperty;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>carbon-device-mgt-plugins-parent</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>device-mgt-iot-androidsense</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 Carbon - IoT Device Android Sense Management Component</name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<modules>
|
||||
<module>org.wso2.carbon.device.mgt.iot.androidsense</module>
|
||||
<module>org.wso2.carbon.device.mgt.iot.androidsense.api</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-scr-scrdescriptor</id>
|
||||
<goals>
|
||||
<goal>scr</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>device-mgt-mdm</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>WSO2 Carbon - Mobile Device app Management Core</name>
|
||||
<description>WSO2 Carbon - Device Management Core</description>
|
||||
<url>http://wso2.org</url>
|
||||
<artifactId>org.wso2.mdm.appmgt</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${project.version}</Bundle-Version>
|
||||
<Bundle-Description>MDM Management Core Bundle</Bundle-Description>
|
||||
<Private-Package>org.wso2.mdm.appmgt.internal</Private-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.apache.commons.logging,
|
||||
org.wso2.carbon.appmgt.mobile.*,
|
||||
org.wso2.carbon.device.mgt.common,
|
||||
org.wso2.carbon.device.mgt.common.operation.mgt,
|
||||
org.wso2.carbon.device.mgt.core.operation.mgt,
|
||||
org.wso2.mdm.mdmmgt.*,
|
||||
org.wso2.carbon.device.mgt.common.app.mgt,
|
||||
org.wso2.carbon.device.mgt.core.service,
|
||||
org.wso2.carbon.device.mgt.core.app.mgt
|
||||
</Import-Package>
|
||||
<Export-Package>
|
||||
!org.wso2.mdm.appmgt.internal,
|
||||
org.wso2.mdm.appmgt.*
|
||||
</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<log4j.configuration>file:src/test/resources/log4j.properties</log4j.configuration>
|
||||
</systemPropertyVariables>
|
||||
<suiteXmlFiles>
|
||||
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
||||
</suiteXmlFiles>
|
||||
</configuration>
|
||||
</plugin>
|
||||
-->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.mdm.mdmmgt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.appmgt</groupId>
|
||||
<artifactId>org.wso2.carbon.appmgt.mobile</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,24 @@
|
||||
package org.wso2.mdm.appmgt.internal;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.appmgt.mobile.interfaces.MDMOperations;
|
||||
import org.wso2.mdm.appmgt.service.MDMOperationsImpl;
|
||||
|
||||
/**
|
||||
* @scr.component name="org.wso2.mdm.appmgt.manager" immediate="true"
|
||||
*/
|
||||
public class AppMgtMDMService {
|
||||
private static Log log = LogFactory.getLog(AppMgtMDMService.class);
|
||||
|
||||
protected void activate(ComponentContext componentContext) {
|
||||
|
||||
BundleContext bundleContext = componentContext.getBundleContext();
|
||||
bundleContext.registerService(MDMOperations.class.getName(),
|
||||
new MDMOperationsImpl(), null);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
package org.wso2.mdm.appmgt.service;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.appmgt.mobile.interfaces.MDMOperations;
|
||||
import org.wso2.carbon.appmgt.mobile.mdm.App;
|
||||
import org.wso2.carbon.appmgt.mobile.mdm.Device;
|
||||
import org.wso2.carbon.appmgt.mobile.utils.User;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.Platform;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
|
||||
import org.wso2.mdm.mdmmgt.beans.MobileApp;
|
||||
import org.wso2.mdm.mdmmgt.beans.MobileAppTypes;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
import org.wso2.mdm.mdmmgt.util.MDMAndroidOperationUtil;
|
||||
import org.wso2.mdm.mdmmgt.util.MDMIOSOperationUtil;
|
||||
import org.wso2.mdm.mdmmgt.util.MDMServiceAPIUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MDMOperationsImpl implements MDMOperations {
|
||||
|
||||
private static Log log = LogFactory.getLog(MDMOperationsImpl.class);
|
||||
|
||||
@Override
|
||||
public void performAction(User currentUser, String action, App app, int tenantId, String type,
|
||||
String[] params,
|
||||
HashMap<String, String> configProperties) {
|
||||
|
||||
ApplicationManager appManagerConnector;
|
||||
org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation = null;
|
||||
|
||||
List<String> userNameList;
|
||||
List<String> roleNameList;
|
||||
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
|
||||
List<org.wso2.carbon.device.mgt.common.Device> deviceList = null;
|
||||
|
||||
if ("user".equals(type)) {
|
||||
String userName = null;
|
||||
for (String param : params) {
|
||||
userName = param;
|
||||
|
||||
try {
|
||||
deviceList = MDMServiceAPIUtils.getDeviceManagementService(tenantId).getDevicesOfUser(userName);
|
||||
} catch (DeviceManagementException devEx) {
|
||||
String errorMsg =
|
||||
"Error occurred fetch device for user " + userName + devEx.getErrorMessage() + " " +
|
||||
"at app installation";
|
||||
log.error(errorMsg, devEx);
|
||||
}
|
||||
|
||||
for (org.wso2.carbon.device.mgt.common.Device device : deviceList) {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(device.getDeviceIdentifier());
|
||||
deviceIdentifier.setType(device.getType());
|
||||
|
||||
deviceIdentifiers.add(deviceIdentifier);
|
||||
}
|
||||
}
|
||||
} else if ("role".equals(type)) {
|
||||
String userRole;
|
||||
for (String param : params) {
|
||||
userRole = param;
|
||||
try {
|
||||
deviceList = MDMServiceAPIUtils.getDeviceManagementService(tenantId).getAllDevices();
|
||||
} catch (DeviceManagementException devMgtEx) {
|
||||
String errorMsg = "Error occurred fetch device for user role " + userRole + devMgtEx
|
||||
.getErrorMessage() + " " +
|
||||
"at app installation";
|
||||
log.error(errorMsg, devMgtEx);
|
||||
}
|
||||
for (org.wso2.carbon.device.mgt.common.Device device : deviceList) {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(device.getDeviceIdentifier());
|
||||
deviceIdentifier.setType(device.getType());
|
||||
deviceIdentifiers.add(deviceIdentifier);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
deviceIdentifiers = new ArrayList<>();
|
||||
DeviceIdentifier deviceIdentifier = null;
|
||||
for (String param : params) {
|
||||
deviceIdentifier = new DeviceIdentifier();
|
||||
String[] paramDevices = param.split("---");
|
||||
deviceIdentifier.setId(paramDevices[0]);
|
||||
deviceIdentifier.setType(paramDevices[1]);
|
||||
deviceIdentifiers.add(deviceIdentifier);
|
||||
}
|
||||
|
||||
}
|
||||
MobileApp mobileApp = new MobileApp();
|
||||
mobileApp.setId(app.getId());
|
||||
mobileApp.setType(MobileAppTypes.valueOf(app.getType().toUpperCase()));
|
||||
mobileApp.setAppIdentifier(app.getAppIdentifier());
|
||||
mobileApp.setIconImage(app.getIconImage());
|
||||
mobileApp.setIdentifier(app.getIdentifier());
|
||||
mobileApp.setLocation(app.getLocation());
|
||||
mobileApp.setName(app.getName());
|
||||
mobileApp.setPackageName(app.getPackageName());
|
||||
mobileApp.setPlatform(app.getPlatform());
|
||||
mobileApp.setVersion(app.getVersion());
|
||||
|
||||
Properties properties = new Properties();
|
||||
|
||||
if ("ios".equals(app.getPlatform())) {
|
||||
if ("enterprise".equals(app.getType())) {
|
||||
properties.put("isRemoveApp", true);
|
||||
properties.put("isPreventBackup", true);
|
||||
} else if ("public".equals(app.getType())) {
|
||||
properties.put("iTunesId", Integer.parseInt(app.getIdentifier().toString()));
|
||||
properties.put("isRemoveApp", true);
|
||||
properties.put("isPreventBackup", true);
|
||||
} else if ("webapp".equals(app.getType())) {
|
||||
properties.put("label", app.getName());
|
||||
properties.put("isRemoveApp", true);
|
||||
}
|
||||
} else if ("webapp".equals(app.getPlatform())) {
|
||||
properties.put("label", app.getName());
|
||||
properties.put("isRemoveApp", true);
|
||||
}
|
||||
mobileApp.setProperties(properties);
|
||||
|
||||
try {
|
||||
if (deviceIdentifiers != null) {
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
||||
if (deviceIdentifier.getType().equals(Platform.android.toString())) {
|
||||
if ("install".equals(action)) {
|
||||
operation = MDMAndroidOperationUtil.createInstallAppOperation(mobileApp);
|
||||
} else {
|
||||
operation = MDMAndroidOperationUtil.createAppUninstallOperation(mobileApp);
|
||||
}
|
||||
} else if (deviceIdentifier.getType().equals(Platform.ios.toString())) {
|
||||
if ("install".equals(action)) {
|
||||
operation = MDMIOSOperationUtil.createInstallAppOperation(mobileApp);
|
||||
} else {
|
||||
operation = MDMIOSOperationUtil.createAppUninstallOperation(mobileApp);
|
||||
}
|
||||
}
|
||||
MDMServiceAPIUtils.getAppManagementService(tenantId).installApplicationForDevices(operation,
|
||||
deviceIdentifiers);
|
||||
}
|
||||
}
|
||||
} catch (MDMException mdmExce) {
|
||||
log.error("Error in creating operation object using app", mdmExce);
|
||||
} catch (ApplicationManagementException appMgtExce) {
|
||||
log.error("Error in app installation", appMgtExce);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public List<Device> getDevices(User currentUser, int tenantId, String type, String[] params,
|
||||
String platform,
|
||||
String platformVersion, boolean isSampleDevicesEnabled,
|
||||
HashMap<String, String> configProperties) {
|
||||
|
||||
List<Device> devices = new ArrayList<>();
|
||||
Device device = null;
|
||||
try {
|
||||
List<org.wso2.carbon.device.mgt.common.Device> deviceList =
|
||||
MDMServiceAPIUtils.getDeviceManagementService(tenantId).getAllDevices();
|
||||
|
||||
for (org.wso2.carbon.device.mgt.common.Device commondevice : deviceList) {
|
||||
device = new Device();
|
||||
device.setId(commondevice.getDeviceIdentifier() + "---" + commondevice.getType());
|
||||
device.setName(commondevice.getName());
|
||||
device.setModel(commondevice.getName());
|
||||
device.setType("mobileDevice");
|
||||
device.setImage("/store/extensions/assets/mobileapp/resources/models/none.png");
|
||||
device.setPlatform(commondevice.getType());
|
||||
devices.add(device);
|
||||
|
||||
}
|
||||
|
||||
} catch (DeviceManagementException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>device-mgt-mdm</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>bundle</packaging>
|
||||
<artifactId>org.wso2.mdm.mdmmgt</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.identity</groupId>
|
||||
<artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${project.version}</Bundle-Version>
|
||||
<Bundle-Description>MDM Management Components Bundle</Bundle-Description>
|
||||
<Export-Package>
|
||||
org.wso2.mdm.mdmmgt.*
|
||||
</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ApplicationWrapper {
|
||||
|
||||
private List<String> userNameList;
|
||||
private List<String> roleNameList;
|
||||
private List<DeviceIdentifier> deviceIdentifiers;
|
||||
private MobileApp application;
|
||||
|
||||
public MobileApp getApplication() {
|
||||
return application;
|
||||
}
|
||||
|
||||
public void setApplication(MobileApp application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public List<String> getUserNameList() {
|
||||
return userNameList;
|
||||
}
|
||||
|
||||
public void setUserNameList(List<String> userNameList) {
|
||||
this.userNameList = userNameList;
|
||||
}
|
||||
|
||||
public List<String> getRoleNameList() {
|
||||
return roleNameList;
|
||||
}
|
||||
|
||||
public void setRoleNameList(List<String> roleNameList) {
|
||||
this.roleNameList = roleNameList;
|
||||
}
|
||||
|
||||
public List<DeviceIdentifier> getDeviceIdentifiers() {
|
||||
return deviceIdentifiers;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifiers(List<DeviceIdentifier> deviceIdentifiers) {
|
||||
this.deviceIdentifiers = deviceIdentifiers;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This class represents the generic mobile Application information
|
||||
* which is used by AppM.
|
||||
*/
|
||||
public class MobileApp {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private MobileAppTypes type;
|
||||
private String platform;
|
||||
private String version;
|
||||
private String identifier;
|
||||
private String iconImage;
|
||||
private String packageName;
|
||||
private String appIdentifier;
|
||||
private String location;
|
||||
private Properties properties;
|
||||
|
||||
public MobileAppTypes getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(MobileAppTypes type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public String getIconImage() {
|
||||
return iconImage;
|
||||
}
|
||||
|
||||
public void setIconImage(String iconImage) {
|
||||
this.iconImage = iconImage;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public Properties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans;
|
||||
|
||||
public enum MobileAppTypes {
|
||||
ENTERPRISE, WEBAPP, PUBLIC
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PolicyWrapper {
|
||||
|
||||
private int id;
|
||||
private Profile profile;
|
||||
private String policyName;
|
||||
private String description;
|
||||
private String compliance;
|
||||
private List<String> roles;
|
||||
private String ownershipType;
|
||||
private List<Device> devices;
|
||||
private List<String> users;
|
||||
private int tenantId;
|
||||
private int profileId;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Profile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(Profile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public String getCompliance() {
|
||||
return compliance;
|
||||
}
|
||||
|
||||
public void setCompliance(String compliance) {
|
||||
this.compliance = compliance;
|
||||
}
|
||||
|
||||
public String getPolicyName() {
|
||||
return policyName;
|
||||
}
|
||||
|
||||
public void setPolicyName(String policyName) {
|
||||
this.policyName = policyName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public String getOwnershipType() {
|
||||
return ownershipType;
|
||||
}
|
||||
|
||||
public void setOwnershipType(String ownershipType) {
|
||||
this.ownershipType = ownershipType;
|
||||
}
|
||||
|
||||
public List<Device> getDevices() {
|
||||
return devices;
|
||||
}
|
||||
|
||||
public void setDevices(List<Device> devices) {
|
||||
this.devices = devices;
|
||||
}
|
||||
|
||||
public List<String> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(List<String> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public int getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(int tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public int getProfileId() {
|
||||
return profileId;
|
||||
}
|
||||
|
||||
public void setProfileId(int profileId) {
|
||||
this.profileId = profileId;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans;
|
||||
|
||||
public class PriorityUpdatedPolicyWrapper {
|
||||
|
||||
private int id;
|
||||
private int priority;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans;
|
||||
|
||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement
|
||||
public class Profile {
|
||||
|
||||
private int profileId;
|
||||
private String profileName;
|
||||
private int tenantId;
|
||||
private DeviceType deviceType;
|
||||
private Timestamp createdDate;
|
||||
private Timestamp updatedDate;
|
||||
private List<ProfileFeature> profileFeaturesList; // Features included in the policies.
|
||||
|
||||
public DeviceType getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceType(DeviceType deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public int getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(int tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
/* public List<Feature> getFeaturesList() {
|
||||
return featuresList;
|
||||
}
|
||||
|
||||
public void setFeaturesList(List<Feature> featuresList) {
|
||||
this.featuresList = featuresList;
|
||||
}*/
|
||||
@XmlElement
|
||||
public int getProfileId() {
|
||||
return profileId;
|
||||
}
|
||||
|
||||
public void setProfileId(int profileId) {
|
||||
this.profileId = profileId;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getProfileName() {
|
||||
return profileName;
|
||||
}
|
||||
|
||||
public void setProfileName(String profileName) {
|
||||
this.profileName = profileName;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Timestamp getCreatedDate() {
|
||||
return createdDate;
|
||||
}
|
||||
|
||||
public void setCreatedDate(Timestamp createdDate) {
|
||||
this.createdDate = createdDate;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Timestamp getUpdatedDate() {
|
||||
return updatedDate;
|
||||
}
|
||||
|
||||
public void setUpdatedDate(Timestamp updatedDate) {
|
||||
this.updatedDate = updatedDate;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public List<ProfileFeature> getProfileFeaturesList() {
|
||||
return profileFeaturesList;
|
||||
}
|
||||
|
||||
public void setProfileFeaturesList(List<ProfileFeature> profileFeaturesList) {
|
||||
this.profileFeaturesList = profileFeaturesList;
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ProfileFeature implements Serializable {
|
||||
|
||||
private int id;
|
||||
private String featureCode;
|
||||
private int profileId;
|
||||
private int deviceTypeId;
|
||||
private Object content;
|
||||
private String payLoad;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFeatureCode() {
|
||||
return featureCode;
|
||||
}
|
||||
|
||||
public void setFeatureCode(String featureCode) {
|
||||
this.featureCode = featureCode;
|
||||
}
|
||||
|
||||
public int getProfileId() {
|
||||
return profileId;
|
||||
}
|
||||
|
||||
public void setProfileId(int profileId) {
|
||||
this.profileId = profileId;
|
||||
}
|
||||
|
||||
public int getDeviceTypeId() {
|
||||
return deviceTypeId;
|
||||
}
|
||||
|
||||
public void setDeviceTypeId(int deviceTypeId) {
|
||||
this.deviceTypeId = deviceTypeId;
|
||||
}
|
||||
|
||||
|
||||
public String getPayLoad() {
|
||||
Gson gson = new Gson();
|
||||
this.payLoad = gson.toJson(content);
|
||||
return payLoad;
|
||||
}
|
||||
|
||||
public void setPayLoad(String payLoad) {
|
||||
this.payLoad = payLoad;
|
||||
}
|
||||
|
||||
|
||||
public Object getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(Object content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package org.wso2.mdm.mdmmgt.beans;
|
||||
|
||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.
|
||||
*/
|
||||
public class RoleWrapper {
|
||||
private String roleName;
|
||||
private String[] permissions;
|
||||
private String[] users;
|
||||
private UIPermissionNode permissionList;
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public String[] getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(String[] permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public String[] getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(String[] users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public UIPermissionNode getPermissionList() {
|
||||
return permissionList;
|
||||
}
|
||||
|
||||
public void setPermissionList(UIPermissionNode permissionList) {
|
||||
this.permissionList = permissionList;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans;
|
||||
|
||||
public class UserCredentialWrapper {
|
||||
|
||||
private String username;
|
||||
/*
|
||||
Base64 encoded password
|
||||
*/
|
||||
private String oldPassword;
|
||||
private String newPassword;
|
||||
|
||||
public String getNewPassword() {
|
||||
return newPassword;
|
||||
}
|
||||
|
||||
public void setNewPassword(String newPassword) {
|
||||
this.newPassword = newPassword;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getOldPassword() {
|
||||
return oldPassword;
|
||||
}
|
||||
|
||||
public void setOldPassword(String oldPassword) {
|
||||
this.oldPassword = oldPassword;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans;
|
||||
|
||||
public class UserWrapper {
|
||||
|
||||
private String username;
|
||||
/*
|
||||
Base64 encoded password
|
||||
*/
|
||||
private String password;
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String emailAddress;
|
||||
private String[] roles;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public String getEmailAddress() {
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
public void setEmailAddress(String emailAddress) {
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
/*
|
||||
Giving a clone of the array since arrays are mutable
|
||||
*/
|
||||
public String[] getRoles() {
|
||||
String[] copiedRoles = roles;
|
||||
if (roles != null) {
|
||||
copiedRoles = roles.clone();
|
||||
}
|
||||
return copiedRoles;
|
||||
}
|
||||
|
||||
public void setRoles(String[] roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
*
|
||||
* 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.mdm.mdmmgt.beans.android;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the Appstore Application information.
|
||||
*/
|
||||
public class AppStoreApplication implements Serializable {
|
||||
|
||||
private String type;
|
||||
private String appIdentifier;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
*
|
||||
* 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.mdm.mdmmgt.beans.android;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the Enterprise Application information.
|
||||
*/
|
||||
public class EnterpriseApplication implements Serializable {
|
||||
|
||||
private String type;
|
||||
private String url;
|
||||
private String appIdentifier;
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
*
|
||||
* 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.mdm.mdmmgt.beans.android;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the Web Application information.
|
||||
*/
|
||||
public class WebApplication implements Serializable {
|
||||
|
||||
private String name;
|
||||
private String url;
|
||||
private String type;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans.ios;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AppStoreApplication implements Serializable {
|
||||
|
||||
private String identifier;
|
||||
private int iTunesStoreID;
|
||||
private boolean removeAppUponMDMProfileRemoval;
|
||||
private boolean preventBackupOfAppData;
|
||||
private String bundleId;
|
||||
private String UUID;
|
||||
|
||||
public String getUUID() {
|
||||
return UUID;
|
||||
}
|
||||
|
||||
public void setUUID(String UUID) {
|
||||
this.UUID = UUID;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public int getiTunesStoreID() {
|
||||
return iTunesStoreID;
|
||||
}
|
||||
|
||||
public void setiTunesStoreID(int iTunesStoreID) {
|
||||
this.iTunesStoreID = iTunesStoreID;
|
||||
}
|
||||
|
||||
public boolean isRemoveAppUponMDMProfileRemoval() {
|
||||
return removeAppUponMDMProfileRemoval;
|
||||
}
|
||||
|
||||
public void setRemoveAppUponMDMProfileRemoval(boolean removeAppUponMDMProfileRemoval) {
|
||||
this.removeAppUponMDMProfileRemoval = removeAppUponMDMProfileRemoval;
|
||||
}
|
||||
|
||||
public boolean isPreventBackupOfAppData() {
|
||||
return preventBackupOfAppData;
|
||||
}
|
||||
|
||||
public void setPreventBackupOfAppData(boolean preventBackupOfAppData) {
|
||||
this.preventBackupOfAppData = preventBackupOfAppData;
|
||||
}
|
||||
|
||||
public String getBundleId() {
|
||||
return bundleId;
|
||||
}
|
||||
|
||||
public void setBundleId(String bundleId) {
|
||||
this.bundleId = bundleId;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.beans.ios;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class EnterpriseApplication implements Serializable {
|
||||
|
||||
private String identifier;
|
||||
private String manifestURL;
|
||||
private boolean removeAppUponMDMProfileRemoval;
|
||||
private boolean preventBackupOfAppData;
|
||||
private String bundleId;
|
||||
private String UUID;
|
||||
|
||||
public void setUUID(String UUID) {
|
||||
this.UUID = UUID;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public String getManifestURL() {
|
||||
return manifestURL;
|
||||
}
|
||||
|
||||
public void setManifestURL(String manifestURL) {
|
||||
this.manifestURL = manifestURL;
|
||||
}
|
||||
|
||||
public boolean isRemoveAppUponMDMProfileRemoval() {
|
||||
return removeAppUponMDMProfileRemoval;
|
||||
}
|
||||
|
||||
public void setRemoveAppUponMDMProfileRemoval(boolean removeAppUponMDMProfileRemoval) {
|
||||
this.removeAppUponMDMProfileRemoval = removeAppUponMDMProfileRemoval;
|
||||
}
|
||||
|
||||
public boolean isPreventBackupOfAppData() {
|
||||
return preventBackupOfAppData;
|
||||
}
|
||||
|
||||
public void setPreventBackupOfAppData(boolean preventBackupOfAppData) {
|
||||
this.preventBackupOfAppData = preventBackupOfAppData;
|
||||
}
|
||||
|
||||
public String getBundleId() {
|
||||
return bundleId;
|
||||
}
|
||||
|
||||
public void setBundleId(String bundleId) {
|
||||
this.bundleId = bundleId;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package org.wso2.mdm.mdmmgt.beans.ios;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class RemoveApplication implements Serializable {
|
||||
|
||||
private String bundleId;
|
||||
|
||||
public String getBundleId() {
|
||||
return bundleId;
|
||||
}
|
||||
|
||||
public void setBundleId(String bundleId) {
|
||||
this.bundleId = bundleId;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package org.wso2.mdm.mdmmgt.beans.ios;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
|
||||
public class WebClip {
|
||||
|
||||
private String URL;
|
||||
private String label;
|
||||
private String icon;
|
||||
private String isRemovable;
|
||||
private String UUID;
|
||||
|
||||
public String getUUID() {
|
||||
return UUID;
|
||||
}
|
||||
|
||||
public void setUUID(String UUID) {
|
||||
this.UUID = UUID;
|
||||
}
|
||||
|
||||
public String getURL() {
|
||||
return URL;
|
||||
}
|
||||
|
||||
public void setURL(String URL) {
|
||||
this.URL = URL;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getIsRemovable() {
|
||||
return isRemovable;
|
||||
}
|
||||
|
||||
public void setIsRemovable(String isRemovable) {
|
||||
this.isRemovable = isRemovable;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package org.wso2.mdm.mdmmgt.common;
|
||||
|
||||
|
||||
public class MDMException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 5136875495185597926L;
|
||||
private String errorMessage;
|
||||
|
||||
|
||||
public MDMException(String msg, Exception e) {
|
||||
super(msg, e);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public MDMException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public MDMException(String msg) {
|
||||
super(msg);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public MDMException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MDMException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.util;
|
||||
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
||||
import org.wso2.mdm.mdmmgt.beans.MobileApp;
|
||||
import org.wso2.mdm.mdmmgt.beans.android.AppStoreApplication;
|
||||
import org.wso2.mdm.mdmmgt.beans.android.EnterpriseApplication;
|
||||
import org.wso2.mdm.mdmmgt.beans.android.WebApplication;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
|
||||
/**
|
||||
* This class contains the all the operations related to Android.
|
||||
*/
|
||||
public class MDMAndroidOperationUtil {
|
||||
|
||||
/**
|
||||
* This method is used to create Install Application operation.
|
||||
*
|
||||
* @param application MobileApp application
|
||||
* @return operation
|
||||
* @throws MDMException
|
||||
*/
|
||||
public static Operation createInstallAppOperation(MobileApp application) throws MDMException {
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_INSTALL_APPLICATION);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
|
||||
switch (application.getType()) {
|
||||
case ENTERPRISE:
|
||||
EnterpriseApplication enterpriseApplication = new EnterpriseApplication();
|
||||
enterpriseApplication.setType(application.getType().toString());
|
||||
enterpriseApplication.setUrl(application.getLocation());
|
||||
operation.setPayLoad(enterpriseApplication.toJSON());
|
||||
break;
|
||||
case PUBLIC:
|
||||
AppStoreApplication appStoreApplication = new AppStoreApplication();
|
||||
appStoreApplication.setType(application.getType().toString());
|
||||
appStoreApplication.setAppIdentifier(application.getIdentifier());
|
||||
operation.setPayLoad(appStoreApplication.toJSON());
|
||||
break;
|
||||
case WEBAPP:
|
||||
WebApplication webApplication = new WebApplication();
|
||||
webApplication.setUrl(application.getLocation());
|
||||
webApplication.setName(application.getName());
|
||||
webApplication.setType(application.getType().toString());
|
||||
operation.setPayLoad(webApplication.toJSON());
|
||||
break;
|
||||
default:
|
||||
String errorMessage = "Invalid application type.";
|
||||
throw new MDMException(errorMessage);
|
||||
}
|
||||
return operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to create Uninstall Application operation.
|
||||
*
|
||||
* @param application MobileApp application
|
||||
* @return operation
|
||||
* @throws MDMException
|
||||
*/
|
||||
public static Operation createAppUninstallOperation(MobileApp application) throws MDMException {
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_UNINSTALL_APPLICATION);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
|
||||
switch (application.getType()) {
|
||||
case ENTERPRISE:
|
||||
EnterpriseApplication enterpriseApplication = new EnterpriseApplication();
|
||||
enterpriseApplication.setType(application.getType().toString());
|
||||
enterpriseApplication.setAppIdentifier(application.getIdentifier());
|
||||
operation.setPayLoad(enterpriseApplication.toJSON());
|
||||
break;
|
||||
case PUBLIC:
|
||||
AppStoreApplication appStoreApplication = new AppStoreApplication();
|
||||
appStoreApplication.setType(application.getType().toString());
|
||||
appStoreApplication.setAppIdentifier(application.getIdentifier());
|
||||
operation.setPayLoad(appStoreApplication.toJSON());
|
||||
break;
|
||||
case WEBAPP:
|
||||
WebApplication webApplication = new WebApplication();
|
||||
webApplication.setUrl(application.getLocation());
|
||||
webApplication.setName(application.getName());
|
||||
webApplication.setType(application.getType().toString());
|
||||
operation.setPayLoad(webApplication.toJSON());
|
||||
break;
|
||||
default:
|
||||
String errorMessage = "Invalid application type.";
|
||||
throw new MDMException(errorMessage);
|
||||
}
|
||||
return operation;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
*
|
||||
* 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.mdm.mdmmgt.util;
|
||||
|
||||
/**
|
||||
* This class holds all the constants used for IOS and Android.
|
||||
*/
|
||||
public class MDMAppConstants {
|
||||
|
||||
public class IOSConstants {
|
||||
|
||||
public static final String IS_REMOVE_APP = "isRemoveApp";
|
||||
public static final String IS_PREVENT_BACKUP = "isPreventBackup";
|
||||
public static final String I_TUNES_ID = "iTunesId";
|
||||
public static final String LABEL = "label";
|
||||
public static final String OPCODE_INSTALL_ENTERPRISE_APPLICATION = "INSTALL_ENTERPRISE_APPLICATION";
|
||||
public static final String OPCODE_INSTALL_STORE_APPLICATION = "INSTALL_STORE_APPLICATION";
|
||||
public static final String OPCODE_INSTALL_WEB_APPLICATION = "WEB_CLIP";
|
||||
public static final String OPCODE_REMOVE_APPLICATION = "REMOVE_APPLICATION";
|
||||
|
||||
private IOSConstants() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
public class AndroidConstants {
|
||||
|
||||
public static final String OPCODE_INSTALL_APPLICATION = "INSTALL_APPLICATION";
|
||||
public static final String OPCODE_UNINSTALL_APPLICATION = "UNINSTALL_APPLICATION";
|
||||
|
||||
private AndroidConstants() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
public class RegistryConstants {
|
||||
|
||||
public static final String GENERAL_CONFIG_RESOURCE_PATH = "general";
|
||||
|
||||
private RegistryConstants() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
public class APPManagerConstants {
|
||||
|
||||
private static final String APP_MANAGER_MDM_SERVICE_NAME = "org.wso2.carbon.appmgt.mobile.interfaces.MDMOperations";
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
*
|
||||
* 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.mdm.mdmmgt.util;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
||||
import org.wso2.mdm.mdmmgt.beans.MobileApp;
|
||||
import org.wso2.mdm.mdmmgt.beans.ios.AppStoreApplication;
|
||||
import org.wso2.mdm.mdmmgt.beans.ios.EnterpriseApplication;
|
||||
import org.wso2.mdm.mdmmgt.beans.ios.RemoveApplication;
|
||||
import org.wso2.mdm.mdmmgt.beans.ios.WebClip;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This class contains the all the operations related to IOS.
|
||||
*/
|
||||
public class MDMIOSOperationUtil {
|
||||
|
||||
/**
|
||||
* This method is used to create Install Application operation.
|
||||
*
|
||||
* @param application MobileApp application
|
||||
* @return operation
|
||||
* @throws MDMException
|
||||
*/
|
||||
public static Operation createInstallAppOperation(MobileApp application) throws MDMException {
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
|
||||
switch (application.getType()) {
|
||||
case ENTERPRISE:
|
||||
EnterpriseApplication enterpriseApplication = new EnterpriseApplication();
|
||||
enterpriseApplication.setBundleId(application.getId());
|
||||
enterpriseApplication.setIdentifier(application.getIdentifier());
|
||||
enterpriseApplication.setManifestURL(application.getLocation());
|
||||
|
||||
Properties properties = application.getProperties();
|
||||
enterpriseApplication.setPreventBackupOfAppData((Boolean) properties.
|
||||
get(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP));
|
||||
enterpriseApplication.setRemoveAppUponMDMProfileRemoval((Boolean) properties.
|
||||
get(MDMAppConstants.IOSConstants.IS_REMOVE_APP));
|
||||
operation.setCode(MDMAppConstants.IOSConstants.OPCODE_INSTALL_ENTERPRISE_APPLICATION);
|
||||
operation.setPayLoad(enterpriseApplication.toJSON());
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
break;
|
||||
case PUBLIC:
|
||||
AppStoreApplication appStoreApplication = new AppStoreApplication();
|
||||
appStoreApplication.setRemoveAppUponMDMProfileRemoval((Boolean) application.getProperties().
|
||||
get(MDMAppConstants.IOSConstants.IS_REMOVE_APP));
|
||||
appStoreApplication.setIdentifier(application.getIdentifier());
|
||||
appStoreApplication.setPreventBackupOfAppData((Boolean) application.getProperties().
|
||||
get(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP));
|
||||
appStoreApplication.setBundleId(application.getId());
|
||||
appStoreApplication.setiTunesStoreID((Integer) application.getProperties().
|
||||
get(MDMAppConstants.IOSConstants.I_TUNES_ID));
|
||||
operation.setCode(MDMAppConstants.IOSConstants.OPCODE_INSTALL_STORE_APPLICATION);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
operation.setPayLoad(appStoreApplication.toJSON());
|
||||
break;
|
||||
case WEBAPP:
|
||||
WebClip webClip = new WebClip();
|
||||
webClip.setIcon(application.getIconImage());
|
||||
webClip.setIsRemovable(application.getProperties().
|
||||
getProperty(MDMAppConstants.IOSConstants.IS_REMOVE_APP));
|
||||
webClip.setLabel(application.getProperties().
|
||||
getProperty(MDMAppConstants.IOSConstants.LABEL));
|
||||
webClip.setURL(application.getLocation());
|
||||
|
||||
operation.setCode(MDMAppConstants.IOSConstants.OPCODE_INSTALL_WEB_APPLICATION);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
operation.setPayLoad(webClip.toJSON());
|
||||
break;
|
||||
}
|
||||
return operation;
|
||||
}
|
||||
|
||||
public static Operation createAppUninstallOperation(MobileApp application) throws MDMException {
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(MDMAppConstants.IOSConstants.OPCODE_REMOVE_APPLICATION);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
|
||||
RemoveApplication removeApplication = new RemoveApplication();
|
||||
removeApplication.setBundleId(application.getIdentifier());
|
||||
operation.setPayLoad(removeApplication.toJSON());
|
||||
|
||||
return operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.mdm.mdmmgt.util;
|
||||
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfigurationManagementService;
|
||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
||||
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||
import org.wso2.carbon.user.api.AuthorizationManager;
|
||||
import org.wso2.carbon.user.api.UserRealm;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
import org.wso2.carbon.user.api.UserStoreManager;
|
||||
import org.wso2.carbon.user.core.service.RealmService;
|
||||
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
||||
import org.wso2.mdm.mdmmgt.common.MDMException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MDMServiceAPIUtils class provides utility function.
|
||||
*/
|
||||
public class MDMServiceAPIUtils {
|
||||
|
||||
private static Log log = LogFactory.getLog(MDMServiceAPIUtils.class);
|
||||
|
||||
public static DeviceManagementProviderService getDeviceManagementService(int tenantId) {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
ctx.setTenantId(tenantId, true);
|
||||
DeviceManagementProviderService deviceManagementProviderService =
|
||||
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||
if (deviceManagementProviderService == null) {
|
||||
String msg = "Device Management provider service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return deviceManagementProviderService;
|
||||
}
|
||||
|
||||
public static int getTenantId(String tenantDomain) throws MDMException {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
|
||||
try {
|
||||
return realmService.getTenantManager().getTenantId(tenantDomain);
|
||||
} catch (UserStoreException e) {
|
||||
throw new MDMException(
|
||||
"Error obtaining tenant id from tenant domain " + tenantDomain);
|
||||
}
|
||||
}
|
||||
|
||||
public static UserStoreManager getUserStoreManager(int tenantId) throws MDMException {
|
||||
RealmService realmService;
|
||||
UserStoreManager userStoreManager;
|
||||
try {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
ctx.setTenantId(tenantId, true);
|
||||
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
|
||||
if (realmService == null) {
|
||||
String msg = "Realm service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager();
|
||||
} catch (UserStoreException e) {
|
||||
String msg = "Error occurred while retrieving current user store manager";
|
||||
log.error(msg, e);
|
||||
throw new MDMException(msg, e);
|
||||
}
|
||||
return userStoreManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting the current tenant's user realm
|
||||
*
|
||||
* @return
|
||||
* @throws org.wso2.mdm.mdmmgt.common.MDMException
|
||||
*/
|
||||
public static UserRealm getUserRealm(int tenantId) throws MDMException {
|
||||
RealmService realmService;
|
||||
UserRealm realm;
|
||||
try {
|
||||
PrivilegedCarbonContext.startTenantFlow();
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
ctx.setTenantId(tenantId, true);
|
||||
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
|
||||
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
|
||||
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
|
||||
|
||||
if (realmService == null) {
|
||||
String msg = "Realm service not initialized";
|
||||
log.error(msg);
|
||||
throw new MDMException(msg);
|
||||
}
|
||||
realm = realmService.getTenantUserRealm(tenantId);
|
||||
} catch (UserStoreException e) {
|
||||
String msg = "Error occurred while retrieving current user realm";
|
||||
log.error(msg, e);
|
||||
throw new MDMException(msg, e);
|
||||
} finally {
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
}
|
||||
return realm;
|
||||
}
|
||||
|
||||
public static AuthorizationManager getAuthorizationManager(int tenantId) throws MDMException {
|
||||
RealmService realmService;
|
||||
AuthorizationManager authorizationManager;
|
||||
try {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
ctx.setTenantId(tenantId, true);
|
||||
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
|
||||
if (realmService == null) {
|
||||
String msg = "Realm service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager();
|
||||
} catch (UserStoreException e) {
|
||||
String msg = "Error occurred while retrieving current Authorization manager.";
|
||||
log.error(msg, e);
|
||||
throw new MDMException(msg, e);
|
||||
}
|
||||
return authorizationManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the current tenant id.
|
||||
*
|
||||
* @return returns the tenant id.
|
||||
*/
|
||||
public static int getTenantId() {
|
||||
return CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
}
|
||||
|
||||
public static DeviceIdentifier instantiateDeviceIdentifier(String deviceType, String deviceId) {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setType(deviceType);
|
||||
deviceIdentifier.setId(deviceId);
|
||||
return deviceIdentifier;
|
||||
}
|
||||
|
||||
public static ApplicationManagementProviderService getAppManagementService(int tenantId) {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
ctx.setTenantId(tenantId, true);
|
||||
ApplicationManagementProviderService applicationManagementProviderService =
|
||||
(ApplicationManagementProviderService) ctx.getOSGiService(ApplicationManagementProviderService.class, null);
|
||||
if (applicationManagementProviderService == null) {
|
||||
String msg = "Application management service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return applicationManagementProviderService;
|
||||
}
|
||||
|
||||
public static PolicyManagerService getPolicyManagementService(int tenantId) {
|
||||
PolicyManagerService policyManagementService;
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
ctx.setTenantId(tenantId, true);
|
||||
policyManagementService =
|
||||
(PolicyManagerService) ctx.getOSGiService(PolicyManagerService.class, null);
|
||||
if (policyManagementService == null) {
|
||||
String msg = "Policy Management service not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return policyManagementService;
|
||||
}
|
||||
|
||||
public static TenantConfigurationManagementService getTenantConfigurationManagementService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
TenantConfigurationManagementService tenantConfigurationManagementService =
|
||||
(TenantConfigurationManagementService) ctx.getOSGiService(TenantConfigurationManagementService.class, null);
|
||||
if (tenantConfigurationManagementService == null) {
|
||||
String msg = "Tenant configuration Management service not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return tenantConfigurationManagementService;
|
||||
}
|
||||
|
||||
public static NotificationManagementService getNotificationManagementService() {
|
||||
NotificationManagementService notificationManagementService;
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
notificationManagementService = (NotificationManagementService) ctx.getOSGiService(
|
||||
NotificationManagementService.class, null);
|
||||
if (notificationManagementService == null) {
|
||||
String msg = "Notification Management service not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return notificationManagementService;
|
||||
}
|
||||
|
||||
public static PaginationResult getPagingResponse(int recordsTotal, int recordsFiltered,
|
||||
int draw, List<?> data) {
|
||||
PaginationResult pagingResponse = new PaginationResult();
|
||||
pagingResponse.setRecordsTotal(recordsTotal);
|
||||
pagingResponse.setRecordsFiltered(recordsFiltered);
|
||||
pagingResponse.setDraw(draw);
|
||||
pagingResponse.setData(data);
|
||||
return pagingResponse;
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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 main.java.org.wso2.mdm.mdmmgt.util;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class ResponsePayload {
|
||||
|
||||
private int statusCode;
|
||||
private String messageFromServer;
|
||||
private Object responseContent;
|
||||
|
||||
public static ResponsePayloadBuilder statusCode(int statusCode) {
|
||||
ResponsePayload message = new ResponsePayload();
|
||||
return message.getBuilder().statusCode(statusCode);
|
||||
}
|
||||
|
||||
public static ResponsePayloadBuilder messageFromServer(String messageFromServer) {
|
||||
ResponsePayload message = new ResponsePayload();
|
||||
return message.getBuilder().messageFromServer(messageFromServer);
|
||||
}
|
||||
|
||||
public static ResponsePayloadBuilder responseContent(String responseContent) {
|
||||
ResponsePayload message = new ResponsePayload();
|
||||
return message.getBuilder().responseContent(responseContent);
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public void setStatusCode(int statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getMessageFromServer() {
|
||||
return messageFromServer;
|
||||
}
|
||||
|
||||
public void setMessageFromServer(String messageFromServer) {
|
||||
this.messageFromServer = messageFromServer;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Object getResponseContent() {
|
||||
return responseContent;
|
||||
}
|
||||
|
||||
public void setResponseContent(Object responseContent) {
|
||||
this.responseContent = responseContent;
|
||||
}
|
||||
|
||||
private ResponsePayloadBuilder getBuilder() {
|
||||
return new ResponsePayloadBuilder();
|
||||
}
|
||||
|
||||
public class ResponsePayloadBuilder {
|
||||
|
||||
private int statusCode;
|
||||
private String messageFromServer;
|
||||
private Object responseContent;
|
||||
|
||||
public ResponsePayloadBuilder statusCode(int statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponsePayloadBuilder messageFromServer(String messageFromServer) {
|
||||
this.messageFromServer = messageFromServer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponsePayloadBuilder responseContent(String responseContent) {
|
||||
this.responseContent = responseContent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponsePayload build() {
|
||||
ResponsePayload payload = new ResponsePayload();
|
||||
payload.setStatusCode(statusCode);
|
||||
payload.setMessageFromServer(messageFromServer);
|
||||
payload.setResponseContent(responseContent);
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>device-mgt-iot-androidsense-feature</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.feature</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<name>WSO2 Carbon - IoT Server Android Sense Feature</name>
|
||||
<url>http://wso2.org</url>
|
||||
<description>This feature contains the Android Sense Device type specific implementations for the IoT Server
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.api</artifactId>
|
||||
<type>war</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>resources</directory>
|
||||
<includes>
|
||||
<include>build.properties</include>
|
||||
<include>p2.inf</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-jaxrs-war</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.api</artifactId>
|
||||
<type>war</type>
|
||||
<overWrite>true</overWrite>
|
||||
<outputDirectory>${basedir}/src/main/resources/webapps/</outputDirectory>
|
||||
<destFileName>android_sense.war</destFileName>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.wso2.maven</groupId>
|
||||
<artifactId>carbon-p2-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>p2-feature-generation</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>p2-feature-gen</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<id>org.wso2.carbon.device.mgt.iot.androidsense</id>
|
||||
<propertiesFile>../../../features/etc/feature.properties</propertiesFile>
|
||||
<adviceFile>
|
||||
<properties>
|
||||
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
|
||||
<propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
|
||||
</properties>
|
||||
</adviceFile>
|
||||
<bundles>
|
||||
<bundleDef>
|
||||
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.androidsense:${carbon.iot.device.mgt.version}
|
||||
</bundleDef>
|
||||
</bundles>
|
||||
<importFeatures>
|
||||
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}</importFeatureDef>
|
||||
<importFeatureDef>org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version}</importFeatureDef>
|
||||
</importFeatures>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
templates=androidsense.apk
|
||||
zipfilename=androidsense.zip
|
@ -0,0 +1 @@
|
||||
custom = true
|
@ -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`) );
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
<div id="device_overview">
|
||||
<div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2">
|
||||
{{unit "cdmf.unit.device.overview.androidsense-display-image"}}
|
||||
</div>
|
||||
<div class="media-body asset-desc add-padding-left-5x">
|
||||
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Device Overview - Android Sense</div>
|
||||
{{#defineZone "device-detail-properties"}}
|
||||
<table class="table table-responsive table-striped" id="members">
|
||||
<tbody>
|
||||
<tr role="row" class="even"><td class="sorting_1" style="padding:10px 15px; width: 1%;;">Device</td><td style="padding:10px 15px;">{{device.viewModel.vendor}} {{device.properties.model}}</td></tr>
|
||||
<tr role="row" class="odd"><td class="sorting_1" style="padding:10px 15px;">Model</td><td style="padding:10px 15px;">{{device.viewModel.model}}</td></tr>
|
||||
<tr role="row" class="even"><td class="sorting_1" style="padding:10px 15px;">IMEI</td><td style="padding:10px 15px;">{{device.viewModel.imei}}</td></tr>
|
||||
{{#if device.viewModel.udid}}
|
||||
<tr role="row" class="even"><td class="sorting_1" style="padding:10px 15px;">UDID</td><td style="padding:10px 15px;">{{device.viewModel.udid}}</td></tr>
|
||||
{{/if}}
|
||||
{{#if device.viewModel.phoneNumber}}
|
||||
<tr role="row" class="even"><td class="sorting_1" style="padding:10px 15px;">Phone Number</td><td style="padding:10px 15px;">{{device.viewModel.phoneNumber}}</td></tr>
|
||||
{{/if}}
|
||||
<tr role="row" class="even">
|
||||
<td class="sorting_1" style="padding:10px 15px;">Status</td>
|
||||
<td style="padding:10px 15px;">
|
||||
{{#equal device.status "ACTIVE"}}<span><i class="fw fw-ok icon-success"></i> Active</span>{{/equal}}
|
||||
{{#equal device.status "INACTIVE"}}<span><i class="fw fw-warning icon-warning"></i> Inactive</span>{{/equal}}
|
||||
{{#equal device.status "BLOCKED"}}<span><i class="fw fw-remove icon-danger"></i> Blocked</span>{{/equal}}
|
||||
{{#equal device.status "REMOVED"}}<span><i class="fw fw-delete icon-danger"></i> Removed</span>{{/equal}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{/defineZone}}
|
||||
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Operations</div>
|
||||
<div class="add-margin-top-4x">
|
||||
{{unit "cdmf.unit.device.iot-operation" deviceType=device.type}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
@ -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);\
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>carbon-device-mgt-plugins-parent</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>device-mgt-iot-androidsense-feature</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 Carbon - IoT Server Android Sense Device Feature</name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<modules>
|
||||
<module>org.wso2.carbon.device.mgt.iot.androidsense.feature</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>device-mgt-mdm-feature</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>org.wso2.mdm.mdmmgt.server.feature</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>resources</directory>
|
||||
<includes>
|
||||
<include>build.properties</include>
|
||||
<include>p2.inf</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.wso2.maven</groupId>
|
||||
<artifactId>carbon-p2-plugin</artifactId>
|
||||
<version>${carbon.p2.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>p2-feature-generation</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>p2-feature-gen</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<id>org.wso2.mdm.mdmmgt.server</id>
|
||||
<propertiesFile>../../../features/etc/feature.properties
|
||||
</propertiesFile>
|
||||
<adviceFile>
|
||||
<properties>
|
||||
<propertyDef>org.wso2.carbon.p2.category.type:server
|
||||
</propertyDef>
|
||||
<propertyDef>org.eclipse.equinox.p2.type.group:false
|
||||
</propertyDef>
|
||||
</properties>
|
||||
</adviceFile>
|
||||
<bundles>
|
||||
<bundleDef>
|
||||
org.wso2.carbon.devicemgt-plugins:org.wso2.mdm.mdmmgt:${project.version}
|
||||
</bundleDef>
|
||||
<bundleDef>
|
||||
org.wso2.carbon.devicemgt-plugins:org.wso2.mdm.appmgt:${project.version}
|
||||
</bundleDef>
|
||||
</bundles>
|
||||
<importFeatures>
|
||||
<importFeatureDef>
|
||||
org.wso2.carbon.core.server:${carbon.kernel.version}
|
||||
</importFeatureDef>
|
||||
<importFeatureDef>
|
||||
org.wso2.carbon.apimgt.core:${carbon.api.mgt.version}
|
||||
</importFeatureDef>
|
||||
<importFeatureDef>
|
||||
org.wso2.carbon.device.mgt.extensions:${carbon.device.mgt.version}
|
||||
</importFeatureDef>
|
||||
</importFeatures>
|
||||
<importBundles>
|
||||
<importBundleDef>com.google.code.gson:gson:${google.gson.version}
|
||||
</importBundleDef>
|
||||
<importBundleDef>
|
||||
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.common:compatible:${carbon.device.mgt.version}
|
||||
</importBundleDef>
|
||||
<importBundleDef>
|
||||
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.core:compatible:${carbon.device.mgt.version}
|
||||
</importBundleDef>
|
||||
<importBundleDef>
|
||||
org.wso2.carbon.devicemgt:org.wso2.carbon.policy.mgt.core:compatible:${carbon.device.mgt.version}
|
||||
</importBundleDef>
|
||||
<importBundleDef>
|
||||
org.wso2.carbon.appmgt:org.wso2.carbon.appmgt.mobile:compatible:${appmgt.feature.version}
|
||||
</importBundleDef>
|
||||
</importBundles>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1 @@
|
||||
custom = true
|
@ -0,0 +1 @@
|
||||
instructions.configure = \
|
Loading…
Reference in new issue