From 73d33211545b15e250f599c14a342ddcca9d1d40 Mon Sep 17 00:00:00 2001 From: charithag Date: Fri, 8 Apr 2016 16:13:37 +0530 Subject: [PATCH] Fix issues in virtual fire alarm jax-rs api --- .../VirtualFireAlarmControllerService.java | 17 +++---- .../impl/VirtualFireAlarmManagerService.java | 16 +++---- .../src/main/webapp/META-INF/permissions.xml | 4 +- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 44 +++++++++++-------- 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java index 0c5abe7b7..4281934c1 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java @@ -22,6 +22,7 @@ import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.dto.DeviceData; + import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; import javax.ws.rs.FormParam; @@ -55,7 +56,7 @@ public interface VirtualFireAlarmControllerService { * @return a custom message indicating whether the DeviceID to IP mapping was successful. */ @POST - @Path("device/register/{deviceId}/{ip}/{port}") + @Path("register/{deviceId}/{ip}/{port}") Response registerDeviceIP(@PathParam("deviceId") String deviceId, @PathParam("ip") String deviceIP, @PathParam("port") String devicePort, @Context HttpServletRequest request); @@ -71,7 +72,7 @@ public interface VirtualFireAlarmControllerService { * (Case-Insensitive String) */ @POST - @Path("device/{deviceId}/buzz") + @Path("{deviceId}/buzz") @Feature(code = "buzz", name = "Buzzer On / Off", type = "operation", description = "Switch on/off Virtual Fire Alarm Buzzer. (On / Off)") Response switchBuzzer(@PathParam("deviceId") String deviceId, @QueryParam("protocol") String protocol, @@ -88,7 +89,7 @@ public interface VirtualFireAlarmControllerService { * whose temperature reading was requested. */ @GET - @Path("device/{deviceId}/temperature") + @Path("{deviceId}/temperature") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Feature(code = "temperature", name = "Temperature", type = "monitor", @@ -104,7 +105,7 @@ public interface VirtualFireAlarmControllerService { * @param dataMsg the temperature data received from the device in JSON format complying to type 'DeviceData'. */ @POST - @Path("device/temperature") + @Path("temperature") @Consumes(MediaType.APPLICATION_JSON) Response pushTemperatureData(final DeviceData dataMsg); @@ -122,7 +123,7 @@ public interface VirtualFireAlarmControllerService { * @return an HTTP Response object with either the CA-Cert or the CA-Capabilities according to the operation. */ @GET - @Path("device/scep") + @Path("scep") Response scepRequest(@QueryParam("operation") String operation, @QueryParam("message") String message); @@ -139,13 +140,13 @@ public interface VirtualFireAlarmControllerService { * @return an HTTP Response object with the signed certificate for the device by the CA of the SCEP Server. */ @POST - @Path("device/scep") + @Path("scep") Response scepRequestPost(@QueryParam("operation") String operation, InputStream inputStream); /** - * Retreive Sensor data for the device type + * Retrieve Sensor data for the device type */ - @Path("device/stats/{deviceId}/sensors/{sensorName}") + @Path("stats/{deviceId}/sensors/{sensorName}") @GET @Consumes("application/json") @Produces("application/json") diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerService.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerService.java index 9f89af761..9ff48d931 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerService.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerService.java @@ -36,36 +36,36 @@ import javax.ws.rs.core.Response; @DeviceType(value = "virtual_firealarm") public interface VirtualFireAlarmManagerService { - @Path("manager/device/{device_id}") + @Path("{device_id}") @DELETE Response removeDevice(@PathParam("device_id") String deviceId); - @Path("manager/device/{device_id}") + @Path("{device_id}") @PUT Response updateDevice(@PathParam("device_id") String deviceId, @QueryParam("name") String name); - @Path("manager/device/{device_id}") + @Path("{device_id}") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getDevice(@PathParam("device_id") String deviceId); - @Path("manager/devices") + @Path("devices") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getFirealarmDevices(); - @Path("manager/device/{sketch_type}/download") + @Path("download") @GET @Produces(MediaType.APPLICATION_JSON) - Response downloadSketch(@QueryParam("deviceName") String deviceName, @PathParam("sketch_type") String sketchType); + Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType); - @Path("manager/device/{sketch_type}/generate_link") + @Path("generate_link") @GET Response generateSketchLink(@QueryParam("deviceName") String deviceName, - @PathParam("sketch_type") String sketchType); + @QueryParam("sketchType") String sketchType); } diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml index 2221af5d6..f855d1dfd 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml @@ -45,7 +45,7 @@ Download device /device-mgt/user/devices/add - /devices/*/download + /devices/download GET virtual_firealarm_user @@ -66,7 +66,7 @@ Generate Link /device-mgt/user/devices/generate_link - /devices/*/generate_link + /devices/generate_link GET virtual_firealarm_user diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/cxf-servlet.xml index f6a4d217c..6dd0282d3 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -1,6 +1,6 @@ - - - - - - - - + + + + + + + + + + + + + + + - - - - - + + + + +