mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
fixed code issues in EventService
This commit is contained in:
parent
df6f420d6e
commit
2eb5aebb60
@ -21,7 +21,6 @@ package org.wso2.carbon.mdm.services.android.services.event;
|
|||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
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.bean.wrapper.EventBeanWrapper;
|
||||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
@ -49,7 +48,8 @@ public interface EventService {
|
|||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
@ApiParam(name = "eventBeanWrapper",
|
@ApiParam(name = "eventBeanWrapper",
|
||||||
value = "Information of the agent event to be published on DAS.")
|
value = "Information of the agent event to be published on DAS.")
|
||||||
EventBeanWrapper eventBeanWrapper) throws AndroidAgentException;
|
EventBeanWrapper eventBeanWrapper);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{deviceId}")
|
@Path("{deviceId}")
|
||||||
@Produces("application/json")
|
@Produces("application/json")
|
||||||
@ -70,7 +70,7 @@ public interface EventService {
|
|||||||
Response retrieveAlert(@ApiParam(name = "acceptHeader", value = "Accept Header.")
|
Response retrieveAlert(@ApiParam(name = "acceptHeader", value = "Accept Header.")
|
||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
@ApiParam(name = "deviceId", value = "DeviceId which need to retrieve published events.")
|
@ApiParam(name = "deviceId", value = "DeviceId which need to retrieve published events.")
|
||||||
@PathParam("deviceId") String deviceId) throws AndroidAgentException;
|
@PathParam("deviceId") String deviceId);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{deviceId}/date")
|
@Path("{deviceId}/date")
|
||||||
@ -97,7 +97,7 @@ public interface EventService {
|
|||||||
@ApiParam(name = "from", value = "From Date.")
|
@ApiParam(name = "from", value = "From Date.")
|
||||||
@QueryParam("from") long from,
|
@QueryParam("from") long from,
|
||||||
@ApiParam(name = "to", value = "To Date.")
|
@ApiParam(name = "to", value = "To Date.")
|
||||||
@QueryParam("to") long to) throws AndroidAgentException;
|
@QueryParam("to") long to);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{deviceId}/type/{type}")
|
@Path("{deviceId}/type/{type}")
|
||||||
@ -120,5 +120,5 @@ public interface EventService {
|
|||||||
@ApiParam(name = "deviceId", value = "Device Identifier to be need to retrieve events.")
|
@ApiParam(name = "deviceId", value = "Device Identifier to be need to retrieve events.")
|
||||||
@PathParam("deviceId") String deviceId,
|
@PathParam("deviceId") String deviceId,
|
||||||
@ApiParam(name = "type", value = "Type of the Alert to be need to retrieve events.")
|
@ApiParam(name = "type", value = "Type of the Alert to be need to retrieve events.")
|
||||||
@PathParam("type") String type) throws AndroidAgentException;
|
@PathParam("type") String type);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class EventServiceImpl implements EventService {
|
|||||||
|
|
||||||
@POST
|
@POST
|
||||||
public Response publishEvents(@HeaderParam(ACCEPT) String acceptHeader,
|
public Response publishEvents(@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
EventBeanWrapper eventBeanWrapper) throws AndroidAgentException {
|
EventBeanWrapper eventBeanWrapper) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Invoking Android device even logging.");
|
log.debug("Invoking Android device even logging.");
|
||||||
@ -73,7 +73,7 @@ public class EventServiceImpl implements EventService {
|
|||||||
@Produces("application/json")
|
@Produces("application/json")
|
||||||
@GET
|
@GET
|
||||||
public Response retrieveAlert(@HeaderParam(ACCEPT) String acceptHeader,
|
public Response retrieveAlert(@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
@PathParam("deviceId") String deviceId) throws AndroidAgentException {
|
@PathParam("deviceId") String deviceId) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Retrieving events for given device Identifier.");
|
log.debug("Retrieving events for given device Identifier.");
|
||||||
@ -104,7 +104,7 @@ public class EventServiceImpl implements EventService {
|
|||||||
@GET
|
@GET
|
||||||
public Response retrieveAlertFromDate(@HeaderParam(ACCEPT) String acceptHeader,
|
public Response retrieveAlertFromDate(@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
|
@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
|
||||||
@QueryParam("to") long to) throws AndroidAgentException {
|
@QueryParam("to") long to) {
|
||||||
String fromDate = String.valueOf(from);
|
String fromDate = String.valueOf(from);
|
||||||
String toDate = String.valueOf(to);
|
String toDate = String.valueOf(to);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
@ -136,8 +136,7 @@ public class EventServiceImpl implements EventService {
|
|||||||
@Path("{deviceId}/type/{type}")
|
@Path("{deviceId}/type/{type}")
|
||||||
@GET
|
@GET
|
||||||
public Response retrieveAlertType(@HeaderParam(ACCEPT) String acceptHeader,
|
public Response retrieveAlertType(@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
@PathParam("deviceId") String deviceId, @PathParam("type") String type)
|
@PathParam("deviceId") String deviceId, @PathParam("type") String type) {
|
||||||
throws AndroidAgentException {
|
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Retrieving events for given device identifier and type.");
|
log.debug("Retrieving events for given device identifier and type.");
|
||||||
@ -149,8 +148,8 @@ public class EventServiceImpl implements EventService {
|
|||||||
try {
|
try {
|
||||||
deviceStates = AndroidAPIUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
deviceStates = AndroidAPIUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
||||||
if (deviceStates == null) {
|
if (deviceStates == null) {
|
||||||
message.setResponseCode("No any alerts are published for given Device: " +
|
message.setResponseCode("No any alerts are published for given Device: "
|
||||||
"" + deviceId + " on specific date.");
|
+ deviceId + " on specific date.");
|
||||||
return Response.status(Response.Status.OK).entity(message).build();
|
return Response.status(Response.Status.OK).entity(message).build();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -68,6 +68,15 @@
|
|||||||
<ref bean="errorHandler"/>
|
<ref bean="errorHandler"/>
|
||||||
</jaxrs:providers>
|
</jaxrs:providers>
|
||||||
</jaxrs:server>
|
</jaxrs:server>
|
||||||
|
<jaxrs:server id="eventService" address="/events">
|
||||||
|
<jaxrs:serviceBeans>
|
||||||
|
<ref bean="eventServiceBean"/>
|
||||||
|
</jaxrs:serviceBeans>
|
||||||
|
<jaxrs:providers>
|
||||||
|
<ref bean="jsonProvider"/>
|
||||||
|
<ref bean="errorHandler"/>
|
||||||
|
</jaxrs:providers>
|
||||||
|
</jaxrs:server>
|
||||||
|
|
||||||
<bean id="deviceMgtServiceBean" class="org.wso2.carbon.mdm.services.android.services.devicemgt.DeviceManagementServiceImpl"/>
|
<bean id="deviceMgtServiceBean" class="org.wso2.carbon.mdm.services.android.services.devicemgt.DeviceManagementServiceImpl"/>
|
||||||
<bean id="enrollmentServiceBean" class="org.wso2.carbon.mdm.services.android.services.enrollment.EnrollmentServiceImpl"/>
|
<bean id="enrollmentServiceBean" class="org.wso2.carbon.mdm.services.android.services.enrollment.EnrollmentServiceImpl"/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user