Merge pull request #314 from madhawap/master

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

@ -32,7 +32,7 @@
<!-- Device related APIs --> <!-- Device related APIs -->
<Permission> <Permission>
<name>get certificate in the database</name> <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> <url>/certificates/scep/signcsr</url>
<method>POST</method> <method>POST</method>
<scope>emm_admin</scope> <scope>emm_admin</scope>

@ -32,22 +32,16 @@
<!-- CertificateManagementAdminService related APIs --> <!-- CertificateManagementAdminService related APIs -->
<Permission> <Permission>
<name>Save certificate</name> <name>View all certificates</name>
<path>/device-mgt/admin/certificate/Save</path> <path>/device-mgt/admin/certificate/GetAll</path>
<url>/admin/certificates</url> <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> <method>GET</method>
</Permission> </Permission>
<Permission> <Permission>
<name>Get all certificates</name> <name>Add certificate</name>
<path>/device-mgt/admin/certificate/GetAll</path> <path>/device-mgt/admin/certificate/Add</path>
<url>/admin/certificates</url> <url>/admin/certificates</url>
<method>GET</method> <method>POST</method>
</Permission> </Permission>
<Permission> <Permission>
<name>Remove certificate</name> <name>Remove certificate</name>
@ -55,5 +49,11 @@
<url>/admin/certificates/*</url> <url>/admin/certificates/*</url>
<method>DELETE</method> <method>DELETE</method>
</Permission> </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 --> <!-- End of CertificateManagementAdminService related APIs -->
</PermissionConfiguration> </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.Log;
import org.apache.commons.logging.LogFactory; 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.*;
import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; 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 @GET
@Path("/{type}/{id}") @Path("/{type}/{id}")
@Override @Override

Loading…
Cancel
Save