From 3c9234d79c0fba0621fd876c2999d413a2905261 Mon Sep 17 00:00:00 2001 From: shamalka Date: Mon, 16 Jan 2023 09:49:45 +0530 Subject: [PATCH 01/10] Add traccar spi --- .../device/mgt/common/spi/TraccarManagementService.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java new file mode 100644 index 0000000000..909136a643 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java @@ -0,0 +1,9 @@ +package org.wso2.carbon.device.mgt.common.spi; + +public interface TraccarManagementService { + + String updateLocation(); + + String getToken(); + +} -- 2.36.3 From 83df14febdeb56509be8a20c2c678619fdf49cba Mon Sep 17 00:00:00 2001 From: shamalka Date: Mon, 30 Jan 2023 23:18:09 +0530 Subject: [PATCH 02/10] Add spi to data holder --- .../mgt/jaxrs/util/DeviceMgtAPIUtils.java | 14 +++++++++++ .../common/spi/TraccarManagementService.java | 6 ++++- .../internal/DeviceManagementDataHolder.java | 10 ++++++++ .../DeviceManagementProviderServiceImpl.java | 23 ++++++++++--------- .../src/main/resources/dbscripts/cdm/h2.sql | 13 +++++++++++ 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index 92bc2790d4..674cf5a647 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -79,6 +79,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.report.mgt.ReportManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService; import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; +import org.wso2.carbon.device.mgt.common.spi.TraccarManagementService; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeVersion; @@ -295,6 +296,19 @@ public class DeviceMgtAPIUtils { return deviceTypeGeneratorService; } + public static TraccarManagementService getTraccarManagementService() { + TraccarManagementService traccarManagementService; + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + traccarManagementService = (TraccarManagementService) ctx.getOSGiService( + TraccarManagementService.class, null); + if (traccarManagementService == null) { + String msg = "Traccar management service not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return traccarManagementService; + } + public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { Device device = getDeviceManagementService().getDevice(deviceIdentifier, false); if (device == null || device.getDeviceIdentifier() == null || diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java index 909136a643..604ef39633 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java @@ -1,9 +1,13 @@ package org.wso2.carbon.device.mgt.common.spi; +import org.wso2.carbon.device.mgt.common.Device; + public interface TraccarManagementService { String updateLocation(); - String getToken(); + String getToken(String username); + + void addDevice(Device device); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index 6a69cb02ba..8bbd2ef682 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -28,6 +28,7 @@ import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService; +import org.wso2.carbon.device.mgt.common.spi.TraccarManagementService; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; @@ -85,6 +86,7 @@ public class DeviceManagementDataHolder { private ExecutorService eventConfigExecutors; private OperationTimeoutTaskManagerService operationTimeoutTaskManagerService; private DeviceAPIClientService deviceAPIClientService; + private TraccarManagementService traccarManagementService; private final Map deviceStatusTaskPluginConfigs = Collections.synchronizedMap( new HashMap<>()); @@ -359,4 +361,12 @@ public class DeviceManagementDataHolder { public void setDeviceAPIClientService(DeviceAPIClientService deviceAPIClientService) { this.deviceAPIClientService = deviceAPIClientService; } + + public TraccarManagementService getTraccarManagementService() { + return traccarManagementService; + } + + public void setTraccarManagementService(TraccarManagementService traccarManagementService) { + this.traccarManagementService = traccarManagementService; + } } 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 d6cf2d7fc3..bf86dec915 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 @@ -430,17 +430,18 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv //enroll Traccar device if (HttpReportingUtil.isTrackerEnabled()) { - try { - DeviceManagementDataHolder.getInstance().getDeviceAPIClientService().addDevice(device, tenantId); - } catch (ExecutionException e) { - log.error("ExecutionException : " + e); - //throw new RuntimeException(e); - //Exception was not thrown due to being conflicted with non-traccar features - } catch (InterruptedException e) { - log.error("InterruptedException : " + e); - //throw new RuntimeException(e); - //Exception was not thrown due to being conflicted with non-traccar features - } +// try { +// DeviceManagementDataHolder.getInstance().getDeviceAPIClientService().addDevice(device, tenantId); +// } catch (ExecutionException e) { +// log.error("ExecutionException : " + e); +// //throw new RuntimeException(e); +// //Exception was not thrown due to being conflicted with non-traccar features +// } catch (InterruptedException e) { +// log.error("InterruptedException : " + e); +// //throw new RuntimeException(e); +// //Exception was not thrown due to being conflicted with non-traccar features +// } + DeviceManagementDataHolder.getInstance().getTraccarManagementService().addDevice(device); } else { log.info("Traccar is disabled"); } diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index bbcbcaf791..c032ae7e61 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -777,3 +777,16 @@ CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING ( TRACCAR_USER_ID INT DEFAULT 0 ); -- END OF DM_EXT_PERMISSION_MAPPING TABLE-- + +-- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- +CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_NAME VARCHAR(100) NOT NULL, + IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, + TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, + TRACCAR_USENAME VARCHAR(100) NULL, + STATUS VARCHAR(100) NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- -- 2.36.3 From 4e2ab456a7a8c6016337d4e5625980990044a7b3 Mon Sep 17 00:00:00 2001 From: shamalka Date: Fri, 10 Feb 2023 08:36:30 +0530 Subject: [PATCH 03/10] Change traccar location publish method --- .../mgt/jaxrs/util/DeviceMgtAPIUtils.java | 13 ----- .../common/spi/TraccarManagementService.java | 6 +++ .../impl/DeviceInformationManagerImpl.java | 50 ++++++++++--------- .../internal/DeviceManagementDataHolder.java | 10 ++++ .../DeviceManagementProviderServiceImpl.java | 25 +++++----- 5 files changed, 55 insertions(+), 49 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index 674cf5a647..12ada720be 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -296,19 +296,6 @@ public class DeviceMgtAPIUtils { return deviceTypeGeneratorService; } - public static TraccarManagementService getTraccarManagementService() { - TraccarManagementService traccarManagementService; - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - traccarManagementService = (TraccarManagementService) ctx.getOSGiService( - TraccarManagementService.class, null); - if (traccarManagementService == null) { - String msg = "Traccar management service not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return traccarManagementService; - } - public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { Device device = getDeviceManagementService().getDevice(deviceIdentifier, false); if (device == null || device.getDeviceIdentifier() == null || diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java index 604ef39633..d8dde3a441 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java @@ -1,6 +1,9 @@ package org.wso2.carbon.device.mgt.common.spi; import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; + +import java.util.List; public interface TraccarManagementService { @@ -10,4 +13,7 @@ public interface TraccarManagementService { void addDevice(Device device); + void addDevices(List devices); + + void updateLocation(Device device, DeviceLocation deviceLocation); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java index 585074894d..8334f2fe25 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java @@ -389,18 +389,19 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { //Tracker update GPS Location if (HttpReportingUtil.isLocationPublishing() && HttpReportingUtil.isTrackerEnabled()) { - try { - DeviceManagementDataHolder.getInstance().getDeviceAPIClientService() - .updateLocation(device, deviceLocation, CarbonContext.getThreadLocalCarbonContext().getTenantId()); - } catch (ExecutionException e) { - log.error("ExecutionException : " + e); - //throw new RuntimeException(e); - //Exception was not thrown due to being conflicted with non-traccar features - } catch (InterruptedException e) { - log.error("InterruptedException : " + e); - //throw new RuntimeException(e); - //Exception was not thrown due to being conflicted with non-traccar features - } +// try { +// DeviceManagementDataHolder.getInstance().getDeviceAPIClientService() +// .updateLocation(device, deviceLocation, CarbonContext.getThreadLocalCarbonContext().getTenantId()); +// } catch (ExecutionException e) { +// log.error("ExecutionException : " + e); +// //throw new RuntimeException(e); +// //Exception was not thrown due to being conflicted with non-traccar features +// } catch (InterruptedException e) { +// log.error("InterruptedException : " + e); +// //throw new RuntimeException(e); +// //Exception was not thrown due to being conflicted with non-traccar features +// } + DeviceManagementDataHolder.getInstance().getTraccarManagementService().updateLocation(device, deviceLocation); } else { if(!HttpReportingUtil.isLocationPublishing()) { if (log.isDebugEnabled()) { @@ -453,18 +454,19 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { for (DeviceLocation deviceLocation: deviceLocations) { //Tracker update GPS Location if (HttpReportingUtil.isLocationPublishing() && HttpReportingUtil.isTrackerEnabled()) { - try { - DeviceManagementDataHolder.getInstance().getDeviceAPIClientService() - .updateLocation(device, deviceLocation, CarbonContext.getThreadLocalCarbonContext().getTenantId()); - } catch (ExecutionException e) { - log.error("ExecutionException : " + e); - //throw new RuntimeException(e); - // NOTE: Exception was not thrown due to being conflicted with non-traccar features - } catch (InterruptedException e) { - log.error("InterruptedException : " + e); - //throw new RuntimeException(e); - // NOTE: Exception was not thrown due to being conflicted with non-traccar features - } +// try { +// DeviceManagementDataHolder.getInstance().getDeviceAPIClientService() +// .updateLocation(device, deviceLocation, CarbonContext.getThreadLocalCarbonContext().getTenantId()); +// } catch (ExecutionException e) { +// log.error("ExecutionException : " + e); +// //throw new RuntimeException(e); +// // NOTE: Exception was not thrown due to being conflicted with non-traccar features +// } catch (InterruptedException e) { +// log.error("InterruptedException : " + e); +// //throw new RuntimeException(e); +// // NOTE: Exception was not thrown due to being conflicted with non-traccar features +// } + DeviceManagementDataHolder.getInstance().getTraccarManagementService().updateLocation(device, deviceLocation); } else { if(!HttpReportingUtil.isLocationPublishing()) { if (log.isDebugEnabled()) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index 8bbd2ef682..51375d98c4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.core.internal; import io.entgra.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; @@ -363,6 +364,15 @@ public class DeviceManagementDataHolder { } public TraccarManagementService getTraccarManagementService() { + TraccarManagementService traccarManagementService; + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + traccarManagementService = (TraccarManagementService) ctx.getOSGiService( + TraccarManagementService.class, null); + if (traccarManagementService == null) { + String msg = "Traccar management service not initialized."; +// log.error(msg); + throw new IllegalStateException(msg); + } return traccarManagementService; } 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 bf86dec915..dc168b84aa 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 @@ -530,18 +530,19 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv extractDeviceLocationToUpdate(device); //enroll Traccar device if (HttpReportingUtil.isTrackerEnabled()) { - try { - int tenantId = this.getTenantId(); - DeviceManagementDataHolder.getInstance().getDeviceAPIClientService().modifyDevice(device, tenantId); - } catch (ExecutionException e) { - log.error("ExecutionException : " + e); - //throw new RuntimeException(e); - //Exception was not thrown due to being conflicted with non-traccar features - } catch (InterruptedException e) { - log.error("InterruptedException : " + e); - //throw new RuntimeException(e); - //Exception was not thrown due to being conflicted with non-traccar features - } +// try { +// int tenantId = this.getTenantId(); +// DeviceManagementDataHolder.getInstance().getDeviceAPIClientService().modifyDevice(device, tenantId); +// } catch (ExecutionException e) { +// log.error("ExecutionException : " + e); +// //throw new RuntimeException(e); +// //Exception was not thrown due to being conflicted with non-traccar features +// } catch (InterruptedException e) { +// log.error("InterruptedException : " + e); +// //throw new RuntimeException(e); +// //Exception was not thrown due to being conflicted with non-traccar features +// } + DeviceManagementDataHolder.getInstance().getTraccarManagementService().addDevice(device); } else { log.info("Traccar is disabled"); } -- 2.36.3 From 9e8f7144de95aced02bf223e29ddae9066e5b3d5 Mon Sep 17 00:00:00 2001 From: shamalka Date: Tue, 21 Mar 2023 12:16:17 +0530 Subject: [PATCH 04/10] Change Traccar integration on device management --- .../common/spi/TraccarManagementService.java | 29 ++++++++--- ...ApplicationManagerProviderServiceImpl.java | 18 +++---- .../impl/DeviceInformationManagerImpl.java | 29 ----------- .../DeviceManagementProviderServiceImpl.java | 51 ++++++++----------- .../src/main/resources/dbscripts/cdm/h2.sql | 17 +++++++ 5 files changed, 69 insertions(+), 75 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java index d8dde3a441..a5f3e71f5e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java @@ -3,17 +3,30 @@ package org.wso2.carbon.device.mgt.common.spi; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; -import java.util.List; - public interface TraccarManagementService { - String updateLocation(); - - String getToken(String username); - + /** + * Adds the provided device to Traccar. + * @param device The device to be added to Traccar. + */ void addDevice(Device device); - void addDevices(List devices); - + /** + * Removes the Traccar device with the specified device ID from the logged in user. + * @param deviceId The ID of the Traccar device to be unlinked from the user. + */ + void unLinkTraccarDevice(int deviceId); + + /** + * Removes the device with the specified enrollment ID from Traccar. + * @param deviceEnrollmentId The enrollment ID of the device to be removed from Traccar. + */ + void removeDevice(int deviceEnrollmentId); + + /** + * Updates the location of the provided device with the specified device location. + * @param device The device whose location is to be updated. + * @param deviceLocation The new location of the device. + */ void updateLocation(Device device, DeviceLocation deviceLocation); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java index cc82921cbc..73259d7142 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java @@ -270,14 +270,14 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem applicationDAO.removeApplications(new ArrayList<>(appsToRemove.values()), device.getId(), device.getEnrolmentInfo().getId(), tenantId); } - if (!appsToUpdate.isEmpty()) { - applicationDAO.updateApplications(new ArrayList<>(appsToUpdate.values()), device.getId(), - device.getEnrolmentInfo().getId(), tenantId); - } - if (!appsToInsert.isEmpty()) { - applicationDAO.addApplications(new ArrayList<>(appsToInsert.values()), device.getId(), - device.getEnrolmentInfo().getId(), tenantId); - } +// if (!appsToUpdate.isEmpty()) { +// applicationDAO.updateApplications(new ArrayList<>(appsToUpdate.values()), device.getId(), +// device.getEnrolmentInfo().getId(), tenantId); +// } +// if (!appsToInsert.isEmpty()) { +// applicationDAO.addApplications(new ArrayList<>(appsToInsert.values()), device.getId(), +// device.getEnrolmentInfo().getId(), tenantId); +// } DeviceManagementDAOFactory.commitTransaction(); String reportingHost = HttpReportingUtil.getReportingHost(); @@ -354,4 +354,4 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem DeviceManagementDAOFactory.closeConnection(); } } -} \ No newline at end of file +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java index 8334f2fe25..16c6b4cccd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java @@ -382,25 +382,10 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { deviceLocation.getBearing(), deviceLocation.getDistance() }; -// DeviceManagerUtil.getEventPublisherService().publishEvent( -// LOCATION_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload -// ); } //Tracker update GPS Location if (HttpReportingUtil.isLocationPublishing() && HttpReportingUtil.isTrackerEnabled()) { -// try { -// DeviceManagementDataHolder.getInstance().getDeviceAPIClientService() -// .updateLocation(device, deviceLocation, CarbonContext.getThreadLocalCarbonContext().getTenantId()); -// } catch (ExecutionException e) { -// log.error("ExecutionException : " + e); -// //throw new RuntimeException(e); -// //Exception was not thrown due to being conflicted with non-traccar features -// } catch (InterruptedException e) { -// log.error("InterruptedException : " + e); -// //throw new RuntimeException(e); -// //Exception was not thrown due to being conflicted with non-traccar features -// } DeviceManagementDataHolder.getInstance().getTraccarManagementService().updateLocation(device, deviceLocation); } else { if(!HttpReportingUtil.isLocationPublishing()) { @@ -414,8 +399,6 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { } } } - //Tracker update GPS Location - DeviceManagementDAOFactory.commitTransaction(); } catch (TransactionManagementException e) { throw new DeviceDetailsMgtException("Transactional error occurred while adding the device location " + @@ -454,18 +437,6 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { for (DeviceLocation deviceLocation: deviceLocations) { //Tracker update GPS Location if (HttpReportingUtil.isLocationPublishing() && HttpReportingUtil.isTrackerEnabled()) { -// try { -// DeviceManagementDataHolder.getInstance().getDeviceAPIClientService() -// .updateLocation(device, deviceLocation, CarbonContext.getThreadLocalCarbonContext().getTenantId()); -// } catch (ExecutionException e) { -// log.error("ExecutionException : " + e); -// //throw new RuntimeException(e); -// // NOTE: Exception was not thrown due to being conflicted with non-traccar features -// } catch (InterruptedException e) { -// log.error("InterruptedException : " + e); -// //throw new RuntimeException(e); -// // NOTE: Exception was not thrown due to being conflicted with non-traccar features -// } DeviceManagementDataHolder.getInstance().getTraccarManagementService().updateLocation(device, deviceLocation); } else { if(!HttpReportingUtil.isLocationPublishing()) { 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 dc168b84aa..8191d776bd 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 @@ -48,6 +48,7 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.protocol.HTTP; +import org.opensaml.xmlsec.signature.P; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -430,22 +431,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv //enroll Traccar device if (HttpReportingUtil.isTrackerEnabled()) { -// try { -// DeviceManagementDataHolder.getInstance().getDeviceAPIClientService().addDevice(device, tenantId); -// } catch (ExecutionException e) { -// log.error("ExecutionException : " + e); -// //throw new RuntimeException(e); -// //Exception was not thrown due to being conflicted with non-traccar features -// } catch (InterruptedException e) { -// log.error("InterruptedException : " + e); -// //throw new RuntimeException(e); -// //Exception was not thrown due to being conflicted with non-traccar features -// } DeviceManagementDataHolder.getInstance().getTraccarManagementService().addDevice(device); } else { - log.info("Traccar is disabled"); + if (log.isDebugEnabled()) { + log.info("Traccar is disabled"); + } } - //enroll Traccar device if (status) { addDeviceToGroups(deviceIdentifier, device.getEnrolmentInfo().getOwnership()); @@ -530,23 +521,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv extractDeviceLocationToUpdate(device); //enroll Traccar device if (HttpReportingUtil.isTrackerEnabled()) { -// try { -// int tenantId = this.getTenantId(); -// DeviceManagementDataHolder.getInstance().getDeviceAPIClientService().modifyDevice(device, tenantId); -// } catch (ExecutionException e) { -// log.error("ExecutionException : " + e); -// //throw new RuntimeException(e); -// //Exception was not thrown due to being conflicted with non-traccar features -// } catch (InterruptedException e) { -// log.error("InterruptedException : " + e); -// //throw new RuntimeException(e); -// //Exception was not thrown due to being conflicted with non-traccar features -// } DeviceManagementDataHolder.getInstance().getTraccarManagementService().addDevice(device); } else { - log.info("Traccar is disabled"); + if (log.isDebugEnabled()) { + log.info("Traccar is disabled"); + } } - //enroll Traccar device + return status; } @@ -630,8 +611,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv //procees to dis-enroll a device from traccar starts if (HttpReportingUtil.isTrackerEnabled()) { - DeviceManagementDataHolder.getInstance().getDeviceAPIClientService() - .disEnrollDevice(device.getId(), tenantId); + DeviceManagementDataHolder.getInstance().getTraccarManagementService().unLinkTraccarDevice(device.getEnrolmentInfo().getId()); + } else { + if (log.isDebugEnabled()) { + log.info("Traccar is disabled"); + } } //procees to dis-enroll a device from traccar ends @@ -751,6 +735,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (log.isDebugEnabled()) { log.debug("Successfully permanently deleted the details of devices : " + validDeviceIdentifiers); } + if (HttpReportingUtil.isTrackerEnabled()) { + for (int enrollmentId : enrollmentIds) { + DeviceManagementDataHolder.getInstance().getTraccarManagementService().removeDevice(enrollmentId); + } + } else { + if (log.isDebugEnabled()) { + log.info("Traccar is disabled"); + } + } return true; } catch (TransactionManagementException e) { String msg = "Error occurred while initiating transaction"; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index c032ae7e61..a7e14b68b0 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -790,3 +790,20 @@ CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( PRIMARY KEY (ID) ); -- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- + +-- DM_TRACCAR_USER_MAPPING TABLE -- +CREATE TABLE IF NOT EXISTS DM_TRACCAR_USER_MAPPING ( + USER_EMAIL VARCHAR(100) NOT NULL UNIQUE, + USER_ID INT NOT NULL, + PRIMARY KEY (USER_EMAIL,USER_ID) +); +-- END OF DM_TRACCAR_USER_MAPPING TABLE -- + +-- DM_TRACCAR_USER_MAPPING TABLE -- +CREATE TABLE IF NOT EXISTS DM_TRACCAR_DEVICE_MAPPING ( + DEVICE_UNIQUE_ID VARCHAR(100) NOT NULL, + DEVICE_ID INT NOT NULL, + USER_EMAIL VARCHAR(100) NOT NULL, + PRIMARY KEY (DEVICE_UNIQUE_ID) +); +-- END OF DM_TRACCAR_USER_MAPPING TABLE -- -- 2.36.3 From bfd9197c4fd2bd8a10dfc7485bb5d86639f96b21 Mon Sep 17 00:00:00 2001 From: shamalka Date: Tue, 21 Mar 2023 12:36:36 +0530 Subject: [PATCH 05/10] Add licence to Traccar spi --- .../common/spi/TraccarManagementService.java | 18 ++++++++++++++++++ .../ApplicationManagerProviderServiceImpl.java | 16 ++++++++-------- .../internal/DeviceManagementDataHolder.java | 1 - .../src/main/resources/dbscripts/cdm/h2.sql | 9 +-------- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java index a5f3e71f5e..39bb7d85ef 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * you may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.carbon.device.mgt.common.spi; import org.wso2.carbon.device.mgt.common.Device; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java index 73259d7142..7dde5efb16 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java @@ -270,14 +270,14 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem applicationDAO.removeApplications(new ArrayList<>(appsToRemove.values()), device.getId(), device.getEnrolmentInfo().getId(), tenantId); } -// if (!appsToUpdate.isEmpty()) { -// applicationDAO.updateApplications(new ArrayList<>(appsToUpdate.values()), device.getId(), -// device.getEnrolmentInfo().getId(), tenantId); -// } -// if (!appsToInsert.isEmpty()) { -// applicationDAO.addApplications(new ArrayList<>(appsToInsert.values()), device.getId(), -// device.getEnrolmentInfo().getId(), tenantId); -// } + if (!appsToUpdate.isEmpty()) { + applicationDAO.updateApplications(new ArrayList<>(appsToUpdate.values()), device.getId(), + device.getEnrolmentInfo().getId(), tenantId); + } + if (!appsToInsert.isEmpty()) { + applicationDAO.addApplications(new ArrayList<>(appsToInsert.values()), device.getId(), + device.getEnrolmentInfo().getId(), tenantId); + } DeviceManagementDAOFactory.commitTransaction(); String reportingHost = HttpReportingUtil.getReportingHost(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index 51375d98c4..9d560b0483 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -370,7 +370,6 @@ public class DeviceManagementDataHolder { TraccarManagementService.class, null); if (traccarManagementService == null) { String msg = "Traccar management service not initialized."; -// log.error(msg); throw new IllegalStateException(msg); } return traccarManagementService; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 6873494890..820b9dadc2 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -787,6 +787,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE ); -- END OF DYNAMIC TASK TABLE-- + -- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( ID INT NOT NULL AUTO_INCREMENT, @@ -800,14 +801,6 @@ CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( ); -- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- --- DM_TRACCAR_USER_MAPPING TABLE -- -CREATE TABLE IF NOT EXISTS DM_TRACCAR_USER_MAPPING ( - USER_EMAIL VARCHAR(100) NOT NULL UNIQUE, - USER_ID INT NOT NULL, - PRIMARY KEY (USER_EMAIL,USER_ID) -); --- END OF DM_TRACCAR_USER_MAPPING TABLE -- - -- DM_TRACCAR_USER_MAPPING TABLE -- CREATE TABLE IF NOT EXISTS DM_TRACCAR_DEVICE_MAPPING ( DEVICE_UNIQUE_ID VARCHAR(100) NOT NULL, -- 2.36.3 From a313bd5d35061d7110a30ffacb2c84c6303c3e65 Mon Sep 17 00:00:00 2001 From: shamalka Date: Wed, 22 Mar 2023 13:32:38 +0530 Subject: [PATCH 06/10] Add Traccar device rename method --- .../mgt/common/spi/TraccarManagementService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java index 39bb7d85ef..dceba7d6e2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java @@ -31,9 +31,9 @@ public interface TraccarManagementService { /** * Removes the Traccar device with the specified device ID from the logged in user. - * @param deviceId The ID of the Traccar device to be unlinked from the user. + * @param deviceEnrollmentId The enrollment ID of the device to be removed from Traccar. */ - void unLinkTraccarDevice(int deviceId); + void unLinkTraccarDevice(int deviceEnrollmentId); /** * Removes the device with the specified enrollment ID from Traccar. @@ -41,6 +41,13 @@ public interface TraccarManagementService { */ void removeDevice(int deviceEnrollmentId); + /** + * Renames the device with the specified enrollment ID to the given name. + * @param deviceEnrollmentId the enrollment ID of the device to be renamed + * @param name The new name for the device + */ + void renameDevice(int deviceEnrollmentId, String name); + /** * Updates the location of the provided device with the specified device location. * @param device The device whose location is to be updated. -- 2.36.3 From fd482a966a69c5827af45c0ee3b72b48fbc70c40 Mon Sep 17 00:00:00 2001 From: shamalka Date: Wed, 29 Mar 2023 16:10:04 +0530 Subject: [PATCH 07/10] Add update device method to Traccar SPI' --- .../device/mgt/common/spi/TraccarManagementService.java | 8 +++++++- .../core/service/DeviceManagementProviderServiceImpl.java | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java index dceba7d6e2..f7bb80136d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java @@ -24,7 +24,7 @@ import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; public interface TraccarManagementService { /** - * Adds the provided device to Traccar. + * Add the provided device to Traccar. * @param device The device to be added to Traccar. */ void addDevice(Device device); @@ -35,6 +35,12 @@ public interface TraccarManagementService { */ void unLinkTraccarDevice(int deviceEnrollmentId); + /** + * Update the provided device to Traccar. + * @param device The device to be updated on Traccar. + */ + void updateDevice(Device device); + /** * Removes the device with the specified enrollment ID from Traccar. * @param deviceEnrollmentId The enrollment ID of the device to be removed from Traccar. 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 53aaa365d7..c268b6a403 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 @@ -523,7 +523,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv extractDeviceLocationToUpdate(device); //enroll Traccar device if (HttpReportingUtil.isTrackerEnabled()) { - DeviceManagementDataHolder.getInstance().getTraccarManagementService().addDevice(device); + DeviceManagementDataHolder.getInstance().getTraccarManagementService().updateDevice(device); } else { if (log.isDebugEnabled()) { log.info("Traccar is disabled"); -- 2.36.3 From 3472d23f1bbeca3c09105079620dbf6c645e8585 Mon Sep 17 00:00:00 2001 From: shamalka Date: Tue, 4 Apr 2023 13:36:24 +0530 Subject: [PATCH 08/10] Remove rename method from Traccar spi --- .../device/mgt/common/spi/TraccarManagementService.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java index f7bb80136d..0c3379eedf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/TraccarManagementService.java @@ -47,13 +47,6 @@ public interface TraccarManagementService { */ void removeDevice(int deviceEnrollmentId); - /** - * Renames the device with the specified enrollment ID to the given name. - * @param deviceEnrollmentId the enrollment ID of the device to be renamed - * @param name The new name for the device - */ - void renameDevice(int deviceEnrollmentId, String name); - /** * Updates the location of the provided device with the specified device location. * @param device The device whose location is to be updated. -- 2.36.3 From 1f8e72d66442885764df60d617e09d6991cf23d5 Mon Sep 17 00:00:00 2001 From: shamalka Date: Tue, 4 Apr 2023 16:48:03 +0530 Subject: [PATCH 09/10] Add debug logs --- .../core/service/DeviceManagementProviderServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 95d7c75a5c..d3363717ad 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 @@ -437,7 +437,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDataHolder.getInstance().getTraccarManagementService().addDevice(device); } else { if (log.isDebugEnabled()) { - log.info("Traccar is disabled"); + log.debug("Traccar is disabled"); } } @@ -527,7 +527,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDataHolder.getInstance().getTraccarManagementService().updateDevice(device); } else { if (log.isDebugEnabled()) { - log.info("Traccar is disabled"); + log.debug("Traccar is disabled"); } } @@ -617,7 +617,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDataHolder.getInstance().getTraccarManagementService().unLinkTraccarDevice(device.getEnrolmentInfo().getId()); } else { if (log.isDebugEnabled()) { - log.info("Traccar is disabled"); + log.debug("Traccar is disabled"); } } //procees to dis-enroll a device from traccar ends @@ -744,7 +744,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } } else { if (log.isDebugEnabled()) { - log.info("Traccar is disabled"); + log.debug("Traccar is disabled"); } } return true; -- 2.36.3 From 85e46ee212ea761204b4982da69621dc5400caad Mon Sep 17 00:00:00 2001 From: shamalka Date: Tue, 4 Apr 2023 16:50:22 +0530 Subject: [PATCH 10/10] Remove unwanted sql table --- .../src/main/resources/dbscripts/cdm/h2.sql | 9 --------- 1 file changed, 9 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 820b9dadc2..960fedcc20 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -800,12 +800,3 @@ CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( PRIMARY KEY (ID) ); -- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- - --- DM_TRACCAR_USER_MAPPING TABLE -- -CREATE TABLE IF NOT EXISTS DM_TRACCAR_DEVICE_MAPPING ( - DEVICE_UNIQUE_ID VARCHAR(100) NOT NULL, - DEVICE_ID INT NOT NULL, - USER_EMAIL VARCHAR(100) NOT NULL, - PRIMARY KEY (DEVICE_UNIQUE_ID) -); --- END OF DM_TRACCAR_USER_MAPPING TABLE -- -- 2.36.3