From 2eb5aebb608b873dcc8a860d23848db2a4b59ab1 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Wed, 25 May 2016 13:53:39 +0530 Subject: [PATCH] fixed code issues in EventService --- .../android/services/event/EventService.java | 10 +++++----- .../services/event/impl/EventServiceImpl.java | 13 ++++++------- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 9 +++++++++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/event/EventService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/event/EventService.java index 30ce612d6..6eb87f002 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/event/EventService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/event/EventService.java @@ -21,7 +21,6 @@ package org.wso2.carbon.mdm.services.android.services.event; import io.swagger.annotations.*; import org.wso2.carbon.mdm.services.android.bean.DeviceState; import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; -import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -49,7 +48,8 @@ public interface EventService { @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "eventBeanWrapper", value = "Information of the agent event to be published on DAS.") - EventBeanWrapper eventBeanWrapper) throws AndroidAgentException; + EventBeanWrapper eventBeanWrapper); + @GET @Path("{deviceId}") @Produces("application/json") @@ -70,7 +70,7 @@ public interface EventService { Response retrieveAlert(@ApiParam(name = "acceptHeader", value = "Accept Header.") @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceId", value = "DeviceId which need to retrieve published events.") - @PathParam("deviceId") String deviceId) throws AndroidAgentException; + @PathParam("deviceId") String deviceId); @GET @Path("{deviceId}/date") @@ -97,7 +97,7 @@ public interface EventService { @ApiParam(name = "from", value = "From Date.") @QueryParam("from") long from, @ApiParam(name = "to", value = "To Date.") - @QueryParam("to") long to) throws AndroidAgentException; + @QueryParam("to") long to); @GET @Path("{deviceId}/type/{type}") @@ -120,5 +120,5 @@ public interface EventService { @ApiParam(name = "deviceId", value = "Device Identifier to be need to retrieve events.") @PathParam("deviceId") String deviceId, @ApiParam(name = "type", value = "Type of the Alert to be need to retrieve events.") - @PathParam("type") String type) throws AndroidAgentException; + @PathParam("type") String type); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/event/impl/EventServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/event/impl/EventServiceImpl.java index 16d80297d..00f9f9759 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/event/impl/EventServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/event/impl/EventServiceImpl.java @@ -42,7 +42,7 @@ public class EventServiceImpl implements EventService { @POST public Response publishEvents(@HeaderParam(ACCEPT) String acceptHeader, - EventBeanWrapper eventBeanWrapper) throws AndroidAgentException { + EventBeanWrapper eventBeanWrapper) { if (log.isDebugEnabled()) { log.debug("Invoking Android device even logging."); @@ -73,7 +73,7 @@ public class EventServiceImpl implements EventService { @Produces("application/json") @GET public Response retrieveAlert(@HeaderParam(ACCEPT) String acceptHeader, - @PathParam("deviceId") String deviceId) throws AndroidAgentException { + @PathParam("deviceId") String deviceId) { if (log.isDebugEnabled()) { log.debug("Retrieving events for given device Identifier."); @@ -104,7 +104,7 @@ public class EventServiceImpl implements EventService { @GET public Response retrieveAlertFromDate(@HeaderParam(ACCEPT) String acceptHeader, @PathParam("deviceId") String deviceId, @QueryParam("from") long from, - @QueryParam("to") long to) throws AndroidAgentException { + @QueryParam("to") long to) { String fromDate = String.valueOf(from); String toDate = String.valueOf(to); if (log.isDebugEnabled()) { @@ -136,8 +136,7 @@ public class EventServiceImpl implements EventService { @Path("{deviceId}/type/{type}") @GET public Response retrieveAlertType(@HeaderParam(ACCEPT) String acceptHeader, - @PathParam("deviceId") String deviceId, @PathParam("type") String type) - throws AndroidAgentException { + @PathParam("deviceId") String deviceId, @PathParam("type") String type) { if (log.isDebugEnabled()) { log.debug("Retrieving events for given device identifier and type."); @@ -149,8 +148,8 @@ public class EventServiceImpl implements EventService { try { deviceStates = AndroidAPIUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query); if (deviceStates == null) { - message.setResponseCode("No any alerts are published for given Device: " + - "" + deviceId + " on specific date."); + message.setResponseCode("No any alerts are published for given Device: " + + deviceId + " on specific date."); return Response.status(Response.Status.OK).entity(message).build(); } else { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 27ff000ae..1eb310318 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -68,6 +68,15 @@ + + + + + + + + +