|
|
@ -323,7 +323,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
|
|
@DELETE
|
|
|
|
@DELETE
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Path("/type/{device-type}/id/{device-id}")
|
|
|
|
@Path("/type/{device-type}/id/{device-id}")
|
|
|
|
public Response deleteDevice(@PathParam("device-type") String deviceType, @PathParam("device-id") String deviceId) {
|
|
|
|
public Response deleteDevice(@PathParam("device-type") String deviceType,
|
|
|
|
|
|
|
|
@PathParam("device-id") String deviceId,
|
|
|
|
|
|
|
|
@QueryParam("permanentDelete") boolean permanentDelete) {
|
|
|
|
DeviceManagementProviderService deviceManagementProviderService =
|
|
|
|
DeviceManagementProviderService deviceManagementProviderService =
|
|
|
|
DeviceMgtAPIUtils.getDeviceManagementService();
|
|
|
|
DeviceMgtAPIUtils.getDeviceManagementService();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -333,13 +335,19 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean response = deviceManagementProviderService.disenrollDevice(deviceIdentifier);
|
|
|
|
boolean response;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (permanentDelete) {
|
|
|
|
|
|
|
|
response = deviceManagementProviderService.deleteDevice(deviceIdentifier);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
response = deviceManagementProviderService.disenrollDevice(deviceIdentifier);
|
|
|
|
|
|
|
|
}
|
|
|
|
return Response.status(Response.Status.OK).entity(response).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(response).build();
|
|
|
|
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
String msg = "Error encountered while deleting device of type : " + deviceType + " and " +
|
|
|
|
String msg = "Error encountered while deleting device of type : " + deviceType + " and " +
|
|
|
|
"ID : " + deviceId;
|
|
|
|
"ID : " + deviceId;
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()
|
|
|
|
).build();
|
|
|
|
).build();
|
|
|
|