diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java index 5c54bc8ea16..13867d1d4df 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java @@ -419,26 +419,32 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { @Override public void deleteDeviceLocation(Device device) throws DeviceDetailsMgtException { try { + if (log.isDebugEnabled()) { + log.debug("Deleting device location for device: " + device.getId()); + } DeviceManagementDAOFactory.beginTransaction(); DeviceLocation deviceLocation = deviceDetailsDAO.getDeviceLocation(device.getId(), device.getEnrolmentInfo().getId()); if (deviceLocation != null) { deviceDetailsDAO.deleteDeviceLocation(device.getId(), device.getEnrolmentInfo().getId()); } else { - throw new DeviceDetailsMgtException("Device location not found."); + log.error("Device location not found for device: " + device.getId()); + throw new DeviceDetailsMgtException("Device location not found for device: " + device.getId()); } DeviceManagementDAOFactory.commitTransaction(); } catch (TransactionManagementException e) { - throw new DeviceDetailsMgtException("Transactional error occurred while deleting the device location " + "information.", e); + log.error("Transactional error occurred while deleting the device location information. Device ID: " + device.getId(), e); + throw new DeviceDetailsMgtException("Transactional error occurred while deleting the device location " + + "information.", e); } catch (DeviceDetailsMgtDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); + log.error("Error occurred while deleting the device location information. Device ID: " + device.getId(), e); throw new DeviceDetailsMgtException("Error occurred while deleting the device location information.", e); } finally { DeviceManagementDAOFactory.closeConnection(); } } - @Override public void addDeviceLocations(Device device, List deviceLocations) throws DeviceDetailsMgtException { try {