Fix Device renaming is not working. #442
Merged
tcdlpds
merged 4 commits from nipuni/device-mgt-core:#11349
into master
5 months ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'nipuni/device-mgt-core:#11349'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Fixes for: http://roadmap.entgra.net/issues/11452
persistedDevice.setName(device.getName());
System.out.println("This is rename device");
boolean responseOfmodifyEnrollment = deviceManagementProviderService.modifyEnrollment(persistedDevice);
boolean responseOfRenameDevice = deviceManagementProviderService.updateDeviceName(persistedDevice);
Review this logic and improve it.
boolean response = responseOfRenameDevice && responseOfDeviceNameChanged;
return Response.status(Response.Status.CREATED).entity(response).build();
} catch (DeviceManagementException e) {
Catch BadRequestException and throw 400 response.
log.debug("Device Manager associated with the device type '" + device.getType() + "' is null. " +
"Therefore, not attempting method 'modifyEnrolment'");
}
return false;
Throw 'DeviceManagementException' exception.
int tenantId = this.getTenantId();
Device currentDevice = this.getDevice(deviceIdentifier, false);
device.setId(currentDevice.getId());
if (device.getName() == null) {
Check this in the beginning of the method and throw an exception, because if this hits, it means this is a bad request.
deviceDAO.updateDevice(device, tenantId);
DeviceManagementDAOFactory.commitTransaction();
Remove unnecessary new lines.
(deviceId, deviceType), true);
persistedDevice.setName(device.getName());
System.out.println("This is rename device");
Remove unnecessary print statement.
d3c6c834fa
toe526b271bc
5 months ago@Override
public Device updateDeviceName(Device device) throws DeviceManagementException {
int tenantId = this.getTenantId();
This is required in line no 5535, so move this loading into there.
if (device == null) {
String msg = "Required values are not set to rename device";
log.error(msg);
throw new DeviceManagementException(msg);
Throw bad request
DeviceManagementDAOFactory.commitTransaction();
this.removeDeviceFromCache(deviceIdentifier);
return device;
Remove unnecessary new line.
return device;
} catch (DeviceManagementDAOException e) {
String msg = "Error occurred while renaming the device '" + device.getId() + "'";
rollback the transaction
String msg = "Error occurred while initiating transaction to rename device: " + device.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (Exception e) {
Do we need to catch from Exception class here?
06dc1620c8
toe4d2a0a29f
5 months agoDevice persistedDevice = deviceManagementProviderService.getDevice(new DeviceIdentifier
Move these two line also into the service method. With that improvement, we can improve the service method also.
Device persistedDevice = deviceManagementProviderService.getDevice(new DeviceIdentifier
(deviceId, deviceType), true);
persistedDevice.setName(device.getName());
If the name has been changed, then we need to rename and make the DAO call.
b0bdc22231
to68c510bba1
5 months agoc38e8ef484
to61a21edb9d
5 months agod43bc1c5a4
into master 5 months agoReviewers
d43bc1c5a4
.