code formatting and resource xml file/ deployment failure fixed

Menaka Madushanka 9 years ago committed by menaka
parent e4296b301b
commit 972484faef

@ -80,12 +80,10 @@
<dependency> <dependency>
<groupId>org.codehaus.jackson</groupId> <groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId> <artifactId>jackson-core-asl</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.jackson</groupId> <groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId> <artifactId>jackson-jaxrs</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax</groupId> <groupId>javax</groupId>

@ -25,13 +25,13 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.iot.DeviceManagement;
import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants;
import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.DeviceJSON; 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.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.exception.DeviceControllerException;
import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager; 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.sensormgt.SensorRecord;
import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -83,7 +83,9 @@ public class AndroidSenseService {
@Context //injected response proxy supporting multiple thread @Context //injected response proxy supporting multiple thread
private HttpServletResponse response; private HttpServletResponse response;
@Path("manager/device") @PUT public boolean register(@FormParam("deviceId") String deviceId, @Path("manager/device")
@PUT
public boolean register(@FormParam("deviceId") String deviceId,
@FormParam("owner") String owner) { @FormParam("owner") String owner) {
DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT); DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT);
@ -126,7 +128,9 @@ public class AndroidSenseService {
} }
} }
@Path("manager/device/remove/{device_id}") @DELETE public void removeDevice(@PathParam("device_id") String deviceId, @Path("manager/device/remove/{device_id}")
@DELETE
public void removeDevice(@PathParam("device_id") String deviceId,
@Context HttpServletResponse response) { @Context HttpServletResponse response) {
DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT); DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT);
@ -150,9 +154,10 @@ public class AndroidSenseService {
} }
@Path("manager/device/update/{device_id}") @POST @Path("manager/device/update/{device_id}")
public boolean updateDevice(@PathParam("device_id") String deviceId, @POST
@QueryParam("name") String name, public boolean updateDevice(
@PathParam("device_id") String deviceId, @QueryParam("name") String name,
@Context HttpServletResponse response) { @Context HttpServletResponse response) {
DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT); DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT);
@ -189,7 +194,11 @@ public class AndroidSenseService {
} }
@Path("manager/device/{device_id}") @GET @Consumes("application/json") @Produces("application/json") public Device getDevice( @Path("manager/device/{device_id}")
@GET
@Consumes("application/json")
@Produces("application/json")
public Device getDevice(
@PathParam("device_id") String deviceId) { @PathParam("device_id") String deviceId) {
DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT); DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT);
@ -211,8 +220,11 @@ public class AndroidSenseService {
/* Service to push all the sensor data collected by the Android /* Service to push all the sensor data collected by the Android
Called by the Android device */ Called by the Android device */
@Path("controller/sensordata") @POST @Consumes(MediaType.APPLICATION_JSON) @Path("controller/sensordata")
public void pushSensorData(final DeviceJSON dataMsg, @Context HttpServletResponse response) { @POST
@Consumes(MediaType.APPLICATION_JSON)
public void pushSensorData(
final DeviceJSON dataMsg, @Context HttpServletResponse response) {
PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
@ -229,7 +241,7 @@ public class AndroidSenseService {
switch (sensor.key) { switch (sensor.key) {
case "battery": case "battery":
streamDef = BATTERY_STREAM_DEFINITION; streamDef = BATTERY_STREAM_DEFINITION;
payloadData = new Object[] { Float.parseFloat(sensor.value) }; payloadData = new Object[]{Float.parseFloat(sensor.value)};
sensorName = SENSOR_BATTERY; sensorName = SENSOR_BATTERY;
break; break;
case "GPS": case "GPS":
@ -258,8 +270,8 @@ public class AndroidSenseService {
} else if (androidSensorId == 5) { } else if (androidSensorId == 5) {
streamDef = LIGHT_STREAM_DEFINITION; streamDef = LIGHT_STREAM_DEFINITION;
sensorName = SENSOR_LIGHT; sensorName = SENSOR_LIGHT;
payloadData = new Object[] { Float.parseFloat(sensor.value) }; payloadData = new Object[]{Float.parseFloat(sensor.value)};
} else if (androidSensorId == 1){ } else if (androidSensorId == 1) {
streamDef = ACCELEROMETER_STREAM_DEFINITION; streamDef = ACCELEROMETER_STREAM_DEFINITION;
String value = sensor.value; String value = sensor.value;
String valuesM[] = value.split(","); String valuesM[] = value.split(",");
@ -298,11 +310,11 @@ public class AndroidSenseService {
} else if (androidSensorId == 8) { } else if (androidSensorId == 8) {
streamDef = PROXIMITY_STREAM_DEFINITION; streamDef = PROXIMITY_STREAM_DEFINITION;
sensorName = SENSOR_PROXIMITY; sensorName = SENSOR_PROXIMITY;
payloadData = new Object[] { Float.parseFloat(sensor.value) }; payloadData = new Object[]{Float.parseFloat(sensor.value)};
} else if (androidSensorId == 6) { } else if (androidSensorId == 6) {
streamDef = PRESSURE_STREAM_DEFINITION; streamDef = PRESSURE_STREAM_DEFINITION;
sensorName = SENSOR_PRESSURE; sensorName = SENSOR_PRESSURE;
payloadData = new Object[] { Float.parseFloat(sensor.value) }; payloadData = new Object[]{Float.parseFloat(sensor.value)};
} }
//Add the remaining sensor types. //Add the remaining sensor types.
@ -311,7 +323,7 @@ public class AndroidSenseService {
} }
} }
Object metdaData[] = { dataMsg.owner, AndroidSenseConstants.DEVICE_TYPE, dataMsg.deviceId, sensor.time }; Object metdaData[] = {dataMsg.owner, AndroidSenseConstants.DEVICE_TYPE, dataMsg.deviceId, sensor.time};
if (streamDef != null && payloadData != null && payloadData.length > 0) { if (streamDef != null && payloadData != null && payloadData.length > 0) {
try { try {
@ -385,13 +397,12 @@ public class AndroidSenseService {
return sensorRecord; return sensorRecord;
} }
@Path("controller/readmagnetic") @Path("controller/readmagnetic")
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SensorRecord readMagnetic(@HeaderParam("owner") String owner, public SensorRecord readMagnetic(
@HeaderParam("deviceId") String deviceId, @HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) { @Context HttpServletResponse response) {
SensorRecord sensorRecord = null; SensorRecord sensorRecord = null;
@ -408,14 +419,14 @@ public class AndroidSenseService {
/** /**
* Created by Menaka * Created by Menaka
* Adding Accelerometer * Adding Accelerometer
* */ */
@Path("controller/readaccelerometer") @Path("controller/readaccelerometer")
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SensorRecord readAccelerometer(@HeaderParam("owner") String owner, public SensorRecord readAccelerometer(
@HeaderParam("deviceId") String deviceId, @HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) { @Context HttpServletResponse response) {
SensorRecord sensorRecord = null; SensorRecord sensorRecord = null;
@ -433,8 +444,8 @@ public class AndroidSenseService {
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SensorRecord readRotation(@HeaderParam("owner") String owner, public SensorRecord readRotation(
@HeaderParam("deviceId") String deviceId, @HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) { @Context HttpServletResponse response) {
SensorRecord sensorRecord = null; SensorRecord sensorRecord = null;
@ -452,8 +463,8 @@ public class AndroidSenseService {
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SensorRecord readProximity(@HeaderParam("owner") String owner, public SensorRecord readProximity(
@HeaderParam("deviceId") String deviceId, @HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) { @Context HttpServletResponse response) {
SensorRecord sensorRecord = null; SensorRecord sensorRecord = null;
@ -471,8 +482,8 @@ public class AndroidSenseService {
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SensorRecord readGyroscope(@HeaderParam("owner") String owner, public SensorRecord readGyroscope(
@HeaderParam("deviceId") String deviceId, @HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) { @Context HttpServletResponse response) {
SensorRecord sensorRecord = null; SensorRecord sensorRecord = null;
@ -490,8 +501,8 @@ public class AndroidSenseService {
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SensorRecord readPressure(@HeaderParam("owner") String owner, public SensorRecord readPressure(
@HeaderParam("deviceId") String deviceId, @HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) { @Context HttpServletResponse response) {
SensorRecord sensorRecord = null; SensorRecord sensorRecord = null;
@ -509,8 +520,8 @@ public class AndroidSenseService {
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public SensorRecord readGravity(@HeaderParam("owner") String owner, public SensorRecord readGravity(
@HeaderParam("deviceId") String deviceId, @HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) { @Context HttpServletResponse response) {
SensorRecord sensorRecord = null; SensorRecord sensorRecord = null;
@ -524,5 +535,4 @@ public class AndroidSenseService {
return sensorRecord; return sensorRecord;
} }
} }

@ -84,6 +84,36 @@
<Uri>http://localhost:9763/android_sense/controller/readmagnetic</Uri> <Uri>http://localhost:9763/android_sense/controller/readmagnetic</Uri>
<UriTemplate>/controller/readmagnetic</UriTemplate> <UriTemplate>/controller/readmagnetic</UriTemplate>
</Resource> </Resource>
<Resource>
<AuthType>Any</AuthType>
<HttpVerb>GET</HttpVerb>
<Uri>http://localhost:9763/android_sense/controller/readgravity</Uri>
<UriTemplate>/controller/readgravity</UriTemplate>
</Resource>
<Resource>
<AuthType>Any</AuthType>
<HttpVerb>GET</HttpVerb>
<Uri>http://localhost:9763/android_sense/controller/readpressure</Uri>
<UriTemplate>/controller/readpressure</UriTemplate>
</Resource>
<Resource>
<AuthType>Any</AuthType>
<HttpVerb>GET</HttpVerb>
<Uri>http://localhost:9763/android_sense/controller/readproximity</Uri>
<UriTemplate>/controller/readproximity</UriTemplate>
</Resource>
<Resource>
<AuthType>Any</AuthType>
<HttpVerb>GET</HttpVerb>
<Uri>http://localhost:9763/android_sense/controller/readgyroscope</Uri>
<UriTemplate>/controller/readgyroscope</UriTemplate>
</Resource>
<Resource>
<AuthType>Any</AuthType>
<HttpVerb>GET</HttpVerb>
<Uri>http://localhost:9763/android_sense/controller/readrotation</Uri>
<UriTemplate>/controller/readrotation</UriTemplate>
</Resource>
<Resource> <Resource>
<AuthType>Any</AuthType> <AuthType>Any</AuthType>
<HttpVerb>GET</HttpVerb> <HttpVerb>GET</HttpVerb>

@ -19,44 +19,44 @@
<url-pattern>/*</url-pattern> <url-pattern>/*</url-pattern>
</servlet-mapping> </servlet-mapping>
<context-param> <!--<context-param>-->
<param-name>isAdminService</param-name> <!--<param-name>isAdminService</param-name>-->
<param-value>false</param-value> <!--<param-value>false</param-value>-->
</context-param> <!--</context-param>-->
<context-param> <!--<context-param>-->
<param-name>doAuthentication</param-name> <!--<param-name>doAuthentication</param-name>-->
<param-value>false</param-value> <!--<param-value>false</param-value>-->
</context-param> <!--</context-param>-->
<!--publish to apim--> <!--publish to apim-->
<context-param> <!--<context-param>-->
<param-name>managed-api-enabled</param-name> <!--<param-name>managed-api-enabled</param-name>-->
<param-value>true</param-value> <!--<param-value>true</param-value>-->
</context-param> <!--</context-param>-->
<context-param> <!--<context-param>-->
<param-name>managed-api-owner</param-name> <!--<param-name>managed-api-owner</param-name>-->
<param-value>admin</param-value> <!--<param-value>admin</param-value>-->
</context-param> <!--</context-param>-->
<context-param> <!--<context-param>-->
<param-name>managed-api-name</param-name> <!--<param-name>managed-api-name</param-name>-->
<param-value>android_sense</param-value> <!--<param-value>android_sense</param-value>-->
</context-param> <!--</context-param>-->
<context-param> <!--<context-param>-->
<param-name>managed-api-endpoint</param-name> <!--<param-name>managed-api-endpoint</param-name>-->
<param-value>http://localhost:9763/android_sense</param-value> <!--<param-value>http://localhost:9763/android_sense</param-value>-->
</context-param> <!--</context-param>-->
<context-param> <!--<context-param>-->
<param-name>managed-api-version</param-name> <!--<param-name>managed-api-version</param-name>-->
<param-value>1.0.0</param-value> <!--<param-value>1.0.0</param-value>-->
</context-param> <!--</context-param>-->
<context-param> <!--<context-param>-->
<param-name>managed-api-context</param-name> <!--<param-name>managed-api-context</param-name>-->
<param-value>/android_sense</param-value> <!--<param-value>/android_sense</param-value>-->
</context-param> <!--</context-param>-->
<context-param> <!--<context-param>-->
<param-name>managed-api-isSecured</param-name> <!--<param-name>managed-api-isSecured</param-name>-->
<param-value>true</param-value> <!--<param-value>true</param-value>-->
</context-param> <!--</context-param>-->
<!-- Below configuration is used to redirect http requests to https --> <!-- Below configuration is used to redirect http requests to https -->
<!--<security-constraint>--> <!--<security-constraint>-->

Loading…
Cancel
Save