minor code consistency fixes #11

Merged
deenath merged 1 commits from traccar_consistency_issue into master 2 years ago

@ -491,9 +491,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return false; return false;
} }
boolean status = deviceManager.modifyEnrollment(device); boolean status = deviceManager.modifyEnrollment(device);
int tenantId = this.getTenantId();
Device currentDevice = this.getDevice(deviceIdentifier, false);
try { try {
int tenantId = this.getTenantId();
Device currentDevice = this.getDevice(deviceIdentifier, false);
DeviceManagementDAOFactory.beginTransaction(); DeviceManagementDAOFactory.beginTransaction();
device.setId(currentDevice.getId()); device.setId(currentDevice.getId());
if (device.getEnrolmentInfo().getId() == 0) { if (device.getEnrolmentInfo().getId() == 0) {
@ -530,7 +530,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
//enroll Traccar device //enroll Traccar device
if (HttpReportingUtil.isTrackerEnabled()) { if (HttpReportingUtil.isTrackerEnabled()) {
try { try {
int tenantId = this.getTenantId();
DeviceManagementDataHolder.getInstance().getDeviceAPIClientService().modifyDevice(device, tenantId); DeviceManagementDataHolder.getInstance().getDeviceAPIClientService().modifyDevice(device, tenantId);
} catch (ExecutionException e) { } catch (ExecutionException e) {
log.error("ExecutionException : " + e); log.error("ExecutionException : " + e);

@ -54,6 +54,7 @@ public interface DeviceAPIClientService {
* Updates device Traccar configuration records (like device name) * Updates device Traccar configuration records (like device name)
* *
* @params device to be modifies * @params device to be modifies
* @param tenantId of the device
* @throws TrackerManagementDAOException errors thrown while modifing a traccar device * @throws TrackerManagementDAOException errors thrown while modifing a traccar device
*/ */
void modifyDevice(Device device, int tenantId) throws ExecutionException, InterruptedException; void modifyDevice(Device device, int tenantId) throws ExecutionException, InterruptedException;

@ -474,6 +474,7 @@ public class TraccarClientFactory {
* *
* @param traccarDevice with DeviceName UniqueId, Status, Disabled LastUpdate, PositionId, GroupId * @param traccarDevice with DeviceName UniqueId, Status, Disabled LastUpdate, PositionId, GroupId
* Model, Contact, Category, fenceIds * Model, Contact, Category, fenceIds
* @param tenantId tentantId of the specific device
* @throws TrackerManagementDAOException Failed while add Traccar Device the operation * @throws TrackerManagementDAOException Failed while add Traccar Device the operation
*/ */
public void modifyDevice(TraccarDevice traccarDevice, int tenantId) throws TrackerManagementDAOException, ExecutionException, InterruptedException { public void modifyDevice(TraccarDevice traccarDevice, int tenantId) throws TrackerManagementDAOException, ExecutionException, InterruptedException {
@ -511,8 +512,7 @@ public class TraccarClientFactory {
try { try {
addDevice(traccarDevice, tenantId); addDevice(traccarDevice, tenantId);
} catch (TrackerAlreadyExistException e) { } catch (TrackerAlreadyExistException e) {
String msg = "The device already exist"; log.error("The device already exist", e);
log.error(msg, e);
} }
} }
} }

@ -68,8 +68,7 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
try { try {
client.modifyDevice(traccarDevice, tenantId); client.modifyDevice(traccarDevice, tenantId);
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
String msg = "Error occurred while mapping with deviceId"; log.error("Error occurred while mapping with deviceId\"", e);
log.error(msg, e);
} }
} }

Loading…
Cancel
Save