From d46bed3186d302f52c459a87774e62977dbca366 Mon Sep 17 00:00:00 2001 From: Deenath Geeganage Date: Mon, 28 Nov 2022 16:42:16 +0530 Subject: [PATCH] minor code consistency fixes --- .../core/service/DeviceManagementProviderServiceImpl.java | 5 ++--- .../mgt/core/traccar/api/service/DeviceAPIClientService.java | 1 + .../mgt/core/traccar/api/service/TraccarClientFactory.java | 4 ++-- .../traccar/api/service/impl/DeviceAPIClientServiceImpl.java | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index d6cf2d7fc34..f088e1a6dbf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -491,9 +491,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return false; } boolean status = deviceManager.modifyEnrollment(device); + int tenantId = this.getTenantId(); + Device currentDevice = this.getDevice(deviceIdentifier, false); try { - int tenantId = this.getTenantId(); - Device currentDevice = this.getDevice(deviceIdentifier, false); DeviceManagementDAOFactory.beginTransaction(); device.setId(currentDevice.getId()); if (device.getEnrolmentInfo().getId() == 0) { @@ -530,7 +530,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv //enroll Traccar device if (HttpReportingUtil.isTrackerEnabled()) { try { - int tenantId = this.getTenantId(); DeviceManagementDataHolder.getInstance().getDeviceAPIClientService().modifyDevice(device, tenantId); } catch (ExecutionException e) { log.error("ExecutionException : " + e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/DeviceAPIClientService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/DeviceAPIClientService.java index 5dacc735d1a..54c4cd79ef0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/DeviceAPIClientService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/DeviceAPIClientService.java @@ -54,6 +54,7 @@ public interface DeviceAPIClientService { * Updates device Traccar configuration records (like device name) * * @params device to be modifies + * @param tenantId of the device * @throws TrackerManagementDAOException errors thrown while modifing a traccar device */ void modifyDevice(Device device, int tenantId) throws ExecutionException, InterruptedException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/TraccarClientFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/TraccarClientFactory.java index bffa6f5e859..11561208559 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/TraccarClientFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/TraccarClientFactory.java @@ -474,6 +474,7 @@ public class TraccarClientFactory { * * @param traccarDevice with DeviceName UniqueId, Status, Disabled LastUpdate, PositionId, GroupId * Model, Contact, Category, fenceIds + * @param tenantId tentantId of the specific device * @throws TrackerManagementDAOException Failed while add Traccar Device the operation */ public void modifyDevice(TraccarDevice traccarDevice, int tenantId) throws TrackerManagementDAOException, ExecutionException, InterruptedException { @@ -511,8 +512,7 @@ public class TraccarClientFactory { try { addDevice(traccarDevice, tenantId); } catch (TrackerAlreadyExistException e) { - String msg = "The device already exist"; - log.error(msg, e); + log.error("The device already exist", e); } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/impl/DeviceAPIClientServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/impl/DeviceAPIClientServiceImpl.java index 6b955d028d4..9e6c22a6396 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/impl/DeviceAPIClientServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/traccar/api/service/impl/DeviceAPIClientServiceImpl.java @@ -68,8 +68,7 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService { try { client.modifyDevice(traccarDevice, tenantId); } catch (TrackerManagementDAOException e) { - String msg = "Error occurred while mapping with deviceId"; - log.error(msg, e); + log.error("Error occurred while mapping with deviceId\"", e); } } -- 2.36.3