Update group with pagination

charithag 9 years ago
parent 7a3d9dcf24
commit ea821f94f7

@ -280,22 +280,6 @@ import java.util.List;
} }
} }
@Path("/device/group/{groupId}/{limit}")
@GET
@Consumes("application/json")
@Produces("application/json")
public Device[] getDevices(@PathParam("groupId") int groupId, @PathParam("limit") int limit){
try{
List<Device> devices = this.getServiceProvider().getDevices(groupId,limit);
return this.getActiveDevices(devices);
} catch (DeviceManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
return null;
} finally {
this.endTenantFlow();
}
}
@Path("/device/role/{role}/all") @Path("/device/role/{role}/all")
@GET @GET
@Consumes("application/json") @Consumes("application/json")

@ -24,6 +24,7 @@ import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device; 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.PaginationResult;
import org.wso2.carbon.device.mgt.group.common.DeviceGroup; import org.wso2.carbon.device.mgt.group.common.DeviceGroup;
import org.wso2.carbon.device.mgt.group.common.GroupManagementException; import org.wso2.carbon.device.mgt.group.common.GroupManagementException;
import org.wso2.carbon.device.mgt.group.common.GroupUser; import org.wso2.carbon.device.mgt.group.common.GroupUser;
@ -407,14 +408,14 @@ public class GroupManagerService {
return usersArray; return usersArray;
} }
@Path("/group/id/{groupId}/device/{limit}") @Path("/group/id/{groupId}/device/all")
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public Device[] getDevices(@PathParam("groupId") int groupId,@PathParam("limit") int limit) { public Device[] getDevices(@PathParam("groupId") int groupId) {
Device[] deviceArray = null; Device[] deviceArray = null;
try { try {
List<Device> devices = this.getServiceProvider().getDevices(groupId,limit); List<Device> devices = this.getServiceProvider().getDevices(groupId);
deviceArray = new Device[devices.size()]; deviceArray = new Device[devices.size()];
response.setStatus(Response.Status.OK.getStatusCode()); response.setStatus(Response.Status.OK.getStatusCode());
devices.toArray(deviceArray); devices.toArray(deviceArray);
@ -427,6 +428,40 @@ public class GroupManagerService {
return deviceArray; return deviceArray;
} }
@Path("/group/id/{groupId}/device/count")
@GET
@Consumes("application/json")
@Produces("application/json")
public int getDeviceCount(@PathParam("groupId") int groupId) {
try {
return this.getServiceProvider().getDeviceCount(groupId);
} catch (GroupManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
log.error(e.getErrorMessage(), e);
return -1;
} finally {
this.endTenantFlow();
}
}
@Path("/group/id/{groupId}/device")
@GET
@Consumes("application/json")
@Produces("application/json")
public PaginationResult getDevices(@PathParam("groupId") int groupId,
@QueryParam("index") int index,
@QueryParam("limit") int limit) {
try {
return this.getServiceProvider().getDevices(groupId, index, limit);
} catch (GroupManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
log.error(e.getErrorMessage(), e);
return null;
} finally {
this.endTenantFlow();
}
}
@Path("/group/id/{groupId}/device/assign") @Path("/group/id/{groupId}/device/assign")
@PUT @PUT
@Consumes("application/json") @Consumes("application/json")

Loading…
Cancel
Save