mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fixing issues in GET /operations and /admin/devices APIs
This commit is contained in:
parent
7a029743ba
commit
25e45dc9f1
@ -326,8 +326,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
dms = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||
operations = dms.getOperations(new DeviceIdentifier(id, type));
|
||||
if (operations == null) {
|
||||
Response.status(Response.Status.NOT_FOUND).entity("It is likely that no device is found upon " +
|
||||
"the provided type and id");
|
||||
return Response.status(Response.Status.NOT_FOUND).entity("It is likely that no device is found upon " +
|
||||
"the provided type and id").build();
|
||||
}
|
||||
} catch (OperationManagementException e) {
|
||||
String msg = "Error occurred while fetching the operations for the '" + type + "' device, which " +
|
||||
|
||||
@ -25,9 +25,11 @@ import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceManagementAdminService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnauthorizedAccessException;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnexpectedServerErrorException;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
@ -67,11 +69,17 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
|
||||
return Response.status(Response.Status.NOT_FOUND).entity("No device, which carries the name '" +
|
||||
name + "', is currently enrolled in the system").build();
|
||||
}
|
||||
return Response.status(Response.Status.OK).entity(devices).build();
|
||||
|
||||
DeviceList deviceList = new DeviceList();
|
||||
deviceList.setCount(devices.size());
|
||||
deviceList.setList(devices);
|
||||
|
||||
return Response.status(Response.Status.OK).entity(deviceList).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while fetching the devices that carry the name '" + name + "'";
|
||||
String msg = "Error occurred at server side while fetching device list.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
throw new UnexpectedServerErrorException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||
} finally {
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
}
|
||||
|
||||
@ -394,6 +394,20 @@
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>View device</name>
|
||||
<path>/device-mgt/admin/devices/view</path>
|
||||
<url>/devices/*/*/operations</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>View device</name>
|
||||
<path>/device-mgt/user/devices/view</path>
|
||||
<url>/devices/*/*/operations</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
|
||||
<!--<Permission>-->
|
||||
<!--<name>Get Applications For Device Type</name>-->
|
||||
<!--<path>/device-mgt/operations/application/view</path>-->
|
||||
|
||||
Loading…
Reference in New Issue
Block a user