Log and set message in response whend device not found to delete

merge-requests/205/head
Saad Sahibjan 5 years ago
parent 0261f96cc1
commit dd4a31beb7

@ -147,7 +147,11 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType);
Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, true); Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, true);
if (persistedDevice == null) { if (persistedDevice == null) {
return Response.status(Response.Status.NOT_FOUND).build(); String msg = "No device found with the device type: " + deviceType +
" having the device ID: " + deviceId + " to permanently delete.";
log.error(msg);
return Response.status(Response.Status.NOT_FOUND).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
boolean response = deviceManagementProviderService.deleteDevice(deviceIdentifier); boolean response = deviceManagementProviderService.deleteDevice(deviceIdentifier);
return Response.status(Response.Status.OK).entity(response).build(); return Response.status(Response.Status.OK).entity(response).build();
@ -155,8 +159,8 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
String msg = "Error encountered while permanently deleting device of type : " + deviceType + " and " + String msg = "Error encountered while permanently deleting device of type : " + deviceType + " and " +
"ID : " + deviceId; "ID : " + deviceId;
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST) return Response.status(Response.Status.BAD_REQUEST).entity(
.entity(new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
} }
} }

Loading…
Cancel
Save