Merge pull request #314 from madhawap/master

Added end-point to get devices enrolled under a specific user
revert-70aa11f8
Milan Perera 8 years ago committed by GitHub
commit c323b5162e

@ -32,7 +32,7 @@
<!-- Device related APIs -->
<Permission>
<name>get certificate in the database</name>
<path>/device-mgt/emm-admin/certificate/GetSignCSR</path>
<path>/device-mgt/admin/certificate/GetSignCSR</path>
<url>/certificates/scep/signcsr</url>
<method>POST</method>
<scope>emm_admin</scope>

@ -32,22 +32,16 @@
<!-- CertificateManagementAdminService related APIs -->
<Permission>
<name>Save certificate</name>
<path>/device-mgt/admin/certificate/Save</path>
<name>View all certificates</name>
<path>/device-mgt/admin/certificate/GetAll</path>
<url>/admin/certificates</url>
<method>POST</method>
</Permission>
<Permission>
<name>Get certificate</name>
<path>/device-mgt/admin/certificate/Get</path>
<url>/admin/certificates/*</url>
<method>GET</method>
</Permission>
<Permission>
<name>Get all certificates</name>
<path>/device-mgt/admin/certificate/GetAll</path>
<name>Add certificate</name>
<path>/device-mgt/admin/certificate/Add</path>
<url>/admin/certificates</url>
<method>GET</method>
<method>POST</method>
</Permission>
<Permission>
<name>Remove certificate</name>
@ -55,5 +49,11 @@
<url>/admin/certificates/*</url>
<method>DELETE</method>
</Permission>
<Permission>
<name>View certificate</name>
<path>/device-mgt/admin/certificate/View</path>
<url>/admin/certificates/*</url>
<method>GET</method>
</Permission>
<!-- End of CertificateManagementAdminService related APIs -->
</PermissionConfiguration>

@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
@ -144,6 +145,32 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
}
}
@GET
@Path("/user-devices")
public Response getDeviceByUser(@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
PaginationRequest request = new PaginationRequest(offset, limit);
PaginationResult result;
DeviceList devices = new DeviceList();
String currentUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
request.setOwner(currentUser);
try {
result = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesOfUser(request);
devices.setList((List<Device>) result.getData());
devices.setCount(result.getRecordsTotal());
return Response.status(Response.Status.OK).entity(devices).build();
} catch (DeviceManagementException e) {
String msg = "Error occurred while fetching all enrolled devices";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
}
@GET
@Path("/{type}/{id}")
@Override

Loading…
Cancel
Save