Update the code structure

feature/traccar-sync
Rushdi Mohamed 3 years ago
parent 4e3567202d
commit c18b3b1c1f

@ -18,7 +18,6 @@
package org.wso2.carbon.device.mgt.core.device.details.mgt.impl; package org.wso2.carbon.device.mgt.core.device.details.mgt.impl;
import com.google.gson.Gson;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -44,15 +43,13 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsMgtDA
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.report.mgt.Constants; import org.wso2.carbon.device.mgt.core.report.mgt.Constants;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.traccar.api.service.impl.DeviceAPIClientServiceImpl; import org.wso2.carbon.device.mgt.core.traccar.api.service.DeviceAPIClientService;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarDevice; import org.wso2.carbon.device.mgt.core.traccar.api.service.impl.TraccarAPIClientServiceImpl;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarPosition;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException; import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.device.mgt.core.util.HttpReportingUtil; import org.wso2.carbon.device.mgt.core.util.HttpReportingUtil;
import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreException;
import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
@ -393,12 +390,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
} }
//Traccar update GPS Location //Traccar update GPS Location
TraccarPosition trackerinfo = new TraccarPosition(device.getDeviceIdentifier(), DeviceAPIClientService dac= DeviceManagementDataHolder.getInstance().getDeviceAPIClientService();
deviceLocation.getUpdatedTime().getTime(), dac.updateLocation(device, deviceLocation);
deviceLocation.getLatitude(), deviceLocation.getLongitude(),
deviceLocation.getBearing(), deviceLocation.getSpeed());
DeviceAPIClientServiceImpl dac= new DeviceAPIClientServiceImpl();
dac.updateLocation(trackerinfo);
//Traccar update GPS Location //Traccar update GPS Location
DeviceManagementDAOFactory.commitTransaction(); DeviceManagementDAOFactory.commitTransaction();

@ -41,6 +41,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskManagerService; import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskManagerService;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.device.mgt.core.traccar.api.service.DeviceAPIClientService;
import org.wso2.carbon.email.sender.core.service.EmailSenderService; import org.wso2.carbon.email.sender.core.service.EmailSenderService;
import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.ntask.core.service.TaskService;
import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.registry.core.service.RegistryService;
@ -83,6 +84,7 @@ public class DeviceManagementDataHolder {
private GeoFenceEventOperationManager geoFenceEventOperationManager; private GeoFenceEventOperationManager geoFenceEventOperationManager;
private ExecutorService eventConfigExecutors; private ExecutorService eventConfigExecutors;
private OperationTimeoutTaskManagerService operationTimeoutTaskManagerService; private OperationTimeoutTaskManagerService operationTimeoutTaskManagerService;
private DeviceAPIClientService deviceAPIClientService;
private final Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = Collections.synchronizedMap( private final Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = Collections.synchronizedMap(
new HashMap<>()); new HashMap<>());
@ -349,4 +351,12 @@ public class DeviceManagementDataHolder {
OperationTimeoutTaskManagerService operationTimeoutTaskManagerService) { OperationTimeoutTaskManagerService operationTimeoutTaskManagerService) {
this.operationTimeoutTaskManagerService = operationTimeoutTaskManagerService; this.operationTimeoutTaskManagerService = operationTimeoutTaskManagerService;
} }
public DeviceAPIClientService getDeviceAPIClientService() {
return deviceAPIClientService;
}
public void setDeviceAPIClientService(DeviceAPIClientService deviceAPIClientService) {
this.deviceAPIClientService = deviceAPIClientService;
}
} }

@ -78,6 +78,8 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceIm
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.device.mgt.core.traccar.api.service.DeviceAPIClientService;
import org.wso2.carbon.device.mgt.core.traccar.api.service.impl.TraccarAPIClientServiceImpl;
import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer; import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.device.mgt.core.util.DeviceMgtTenantMgtListener; import org.wso2.carbon.device.mgt.core.util.DeviceMgtTenantMgtListener;
@ -302,6 +304,11 @@ public class DeviceManagementServiceComponent {
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider); DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider);
bundleContext.registerService(DeviceManagementProviderService.class.getName(), deviceManagementProvider, null); bundleContext.registerService(DeviceManagementProviderService.class.getName(), deviceManagementProvider, null);
/* Registering Device API Client Service */
DeviceAPIClientService deviceAPIClientService = new TraccarAPIClientServiceImpl();
DeviceManagementDataHolder.getInstance().setDeviceAPIClientService(deviceAPIClientService);
bundleContext.registerService(DeviceAPIClientService.class.getName(), deviceAPIClientService, null);
/* Registering Group Management Service */ /* Registering Group Management Service */
GroupManagementProviderService groupManagementProvider = new GroupManagementProviderServiceImpl(); GroupManagementProviderService groupManagementProvider = new GroupManagementProviderServiceImpl();
String defaultGroups = String defaultGroups =

@ -677,7 +677,7 @@ public interface DeviceManagementProviderService {
boolean modifyEnrollment(Device device) throws DeviceManagementException; boolean modifyEnrollment(Device device) throws DeviceManagementException;
boolean enrollDevice(Device device) throws DeviceManagementException, IOException; boolean enrollDevice(Device device) throws DeviceManagementException;
boolean saveConfiguration(PlatformConfiguration configuration) throws DeviceManagementException; boolean saveConfiguration(PlatformConfiguration configuration) throws DeviceManagementException;

@ -118,9 +118,7 @@ import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener;
import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataDAO; import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataDAO;
import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.core.traccar.api.service.impl.DeviceAPIClientServiceImpl; import org.wso2.carbon.device.mgt.core.traccar.api.service.DeviceAPIClientService;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarDevice;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarPosition;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException; import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.email.sender.core.ContentProviderInfo; import org.wso2.carbon.email.sender.core.ContentProviderInfo;
@ -397,13 +395,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} }
//enroll Traccar device //enroll Traccar device
String lastUpdatedTime = String.valueOf((new Date().getTime()));
TraccarDevice traccarDeviceInfo = new TraccarDevice(device.getName(), device.getDeviceIdentifier(),
"online", "false", lastUpdatedTime, "", "", "", "",
"", "");
DeviceAPIClientServiceImpl dac= new DeviceAPIClientServiceImpl();
try { try {
dac.addDevice(traccarDeviceInfo); DeviceAPIClientService dac= DeviceManagementDataHolder.getInstance().getDeviceAPIClientService();
dac.addDevice(device);
} catch (TraccarConfigurationException e) { } catch (TraccarConfigurationException e) {
log.error("Error on Traccar add device" + e); log.error("Error on Traccar add device" + e);
//e.printStackTrace(); //e.printStackTrace();
@ -572,10 +566,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
this.removeDeviceFromCache(deviceId); this.removeDeviceFromCache(deviceId);
//disenroll Traccar device //disenroll Traccar device
TraccarDevice traccarDeviceInfo = new TraccarDevice(device.getDeviceIdentifier());
DeviceAPIClientServiceImpl dac= new DeviceAPIClientServiceImpl();
try { try {
dac.disDevice(traccarDeviceInfo); DeviceAPIClientService dac= DeviceManagementDataHolder.getInstance().getDeviceAPIClientService();
dac.disDevice(device.getDeviceIdentifier());
} catch (TraccarConfigurationException e) { } catch (TraccarConfigurationException e) {
log.error("Error on Traccar disenroll a device" + e); log.error("Error on Traccar disenroll a device" + e);
//e.printStackTrace(); //e.printStackTrace();

@ -19,37 +19,48 @@
package org.wso2.carbon.device.mgt.core.traccar.api.service; package org.wso2.carbon.device.mgt.core.traccar.api.service;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarDevice; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarGroups; import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarGroups;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarPosition;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException; import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException;
import java.io.IOException;
public interface DeviceAPIClientService { public interface DeviceAPIClientService {
/** /**
* Create device Traccar configuration records * Add GPS location of a device Traccar configuration records
* *
* @param deviceInfo to be added * @param device to be added to update location of the device
* @throws TraccarConfigurationException errors thrown while creating a device traccar configuration * @param deviceLocation to be added to update location of the device
* @throws TraccarConfigurationException errors thrown while inserting location of a device traccar configuration
*/ */
void addDevice(TraccarDevice deviceInfo) throws TraccarConfigurationException; void updateLocation(Device device, DeviceLocation deviceLocation) throws TraccarConfigurationException;
/** /**
* Add GPS location of a device Traccar configuration records * Create device Traccar configuration records
* *
* @param deviceInfo to be added to update location of the device * @param device to be added
* @throws TraccarConfigurationException errors thrown while inserting location of a device traccar configuration * @throws TraccarConfigurationException errors thrown while creating a device traccar configuration
*/ */
void updateLocation(TraccarPosition deviceInfo) throws TraccarConfigurationException; void addDevice(Device device) throws TraccarConfigurationException;
/** /**
* Delete a device Traccar configuration records * Delete a device Traccar configuration records
* *
* @param deviceInfo to be delete a device * @param deviceIdentifier to be delete a device
* @throws TraccarConfigurationException errors thrown while deleting a device traccar configuration * @throws TraccarConfigurationException errors thrown while deleting a device traccar configuration
*/ */
void disDevice(TraccarDevice deviceInfo) throws TraccarConfigurationException; void disDevice(String deviceIdentifier) throws TraccarConfigurationException;
//String addGroup(TraccarGroups groupInfo) throws IOException; /**
* Delete a device Traccar configuration records
*
* @param group to be add a group
* @throws TraccarConfigurationException errors thrown while adding a group traccar configuration
*/
void addGroup(DeviceGroup group) throws TraccarConfigurationException;
} }

@ -30,10 +30,10 @@ import org.apache.commons.logging.LogFactory;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.wso2.carbon.device.mgt.common.event.config.EventConfigurationException;
import org.wso2.carbon.device.mgt.core.traccar.common.TraccarClient; import org.wso2.carbon.device.mgt.core.traccar.common.TraccarClient;
import org.wso2.carbon.device.mgt.core.traccar.common.TraccarHandlerConstants; import org.wso2.carbon.device.mgt.core.traccar.common.TraccarHandlerConstants;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarDevice; import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarDevice;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarGroups;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarPosition; import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarPosition;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException; import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarGateway; import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarGateway;
@ -166,13 +166,14 @@ public class TrackerClient implements TraccarClient {
/** /**
* Add Device GPS Location operation. * Add Device GPS Location operation.
* @param deviceIdentifier * @param deviceId
* @return device info * @return device info
* @throws TraccarConfigurationException Failed while add Traccar Device location operation * @throws TraccarConfigurationException Failed while add Traccar Device location operation
*/ */
public String getDeviceByDeviceIdentifier(String deviceIdentifier) throws TraccarConfigurationException { @Override
public String getDeviceByDeviceIdentifier(String deviceId) throws TraccarConfigurationException {
try { try {
String context = "8082/api/devices?uniqueId="+deviceIdentifier; String context = "8082/api/devices?uniqueId="+ deviceId;
Runnable trackerExecutor = new TrackerExecutor(endpoint, context, null, "get"); Runnable trackerExecutor = new TrackerExecutor(endpoint, context, null, "get");
executor.execute(trackerExecutor); executor.execute(trackerExecutor);
Request request = new Request.Builder() Request request = new Request.Builder()
@ -200,6 +201,11 @@ public class TrackerClient implements TraccarClient {
String result = getDeviceByDeviceIdentifier(deviceInfo.getDeviceIdentifier()); String result = getDeviceByDeviceIdentifier(deviceInfo.getDeviceIdentifier());
String jsonData ="{"+ "\"geodata\": "+ result+ "}"; String jsonData ="{"+ "\"geodata\": "+ result+ "}";
log.info("======================");
log.info("result");
log.info(result);
log.info(deviceInfo.getDeviceIdentifier());
log.info("===========================");
JSONObject obj = new JSONObject(jsonData); JSONObject obj = new JSONObject(jsonData);
JSONArray geodata = obj.getJSONArray("geodata"); JSONArray geodata = obj.getJSONArray("geodata");
JSONObject jsonResponse = geodata.getJSONObject(0); JSONObject jsonResponse = geodata.getJSONObject(0);
@ -219,6 +225,28 @@ public class TrackerClient implements TraccarClient {
} }
} }
/**
* Add Traccar Device operation.
* @param groupInfo with groupName
* @throws TraccarConfigurationException Failed while add Traccar Device the operation
*/
public void addGroup(TraccarGroups groupInfo) throws TraccarConfigurationException {
try{
JSONObject payload = new JSONObject();
payload.put("name", groupInfo.getName());
payload.put("attributes", new JSONObject());
String context = "8082/api/groups";
Runnable trackerExecutor = new TrackerExecutor(endpoint, context, payload, "post");
executor.execute(trackerExecutor);
log.info("Group successfully on traccar");
}catch (Exception e){
String msg="Could not add a traccar group";
log.error(msg, e);
throw new TraccarConfigurationException(msg, e);
}
}
private TraccarGateway getTraccarGateway(){ private TraccarGateway getTraccarGateway(){
return TraccarConfigurationManager.getInstance().getTraccarConfig().getTraccarGateway( return TraccarConfigurationManager.getInstance().getTraccarConfig().getTraccarGateway(
TraccarHandlerConstants.GATEWAY_NAME); TraccarHandlerConstants.GATEWAY_NAME);

@ -1,59 +0,0 @@
/*
* Copyright (C) 2018 - 2022 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.core.traccar.api.service.impl;
import org.wso2.carbon.device.mgt.common.event.config.EventMetaData;
import org.wso2.carbon.device.mgt.core.event.config.EventOperationExecutor;
import org.wso2.carbon.device.mgt.core.geo.task.GeoFenceEventOperationManager;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.traccar.api.service.DeviceAPIClientService;
import org.wso2.carbon.device.mgt.core.traccar.api.service.addons.TrackerClient;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarDevice;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarGroups;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarPosition;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException;
import java.io.IOException;
import java.util.List;
public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
public void addDevice(TraccarDevice deviceInfo) throws TraccarConfigurationException {
TrackerClient client = new TrackerClient();
client.addDevice(deviceInfo);
}
public void updateLocation(TraccarPosition deviceInfo) throws TraccarConfigurationException {
TrackerClient client = new TrackerClient();
client.updateLocation(deviceInfo);
}
public void disDevice(TraccarDevice deviceInfo) throws TraccarConfigurationException {
TrackerClient client = new TrackerClient();
client.disDevice(deviceInfo);
}
/*public String addGroup(TraccarGroups groupInfo) throws IOException {
TrackerClient client = new TrackerClient();
return (client.addGroup(groupInfo));
}*/
}

@ -0,0 +1,68 @@
/*
* Copyright (C) 2018 - 2022 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.core.traccar.api.service.impl;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.core.traccar.api.service.DeviceAPIClientService;
import org.wso2.carbon.device.mgt.core.traccar.api.service.addons.TrackerClient;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarDevice;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarGroups;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarPosition;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException;
import java.util.Date;
public class TraccarAPIClientServiceImpl implements DeviceAPIClientService {
public void addDevice(Device device) throws TraccarConfigurationException {
TrackerClient client = new TrackerClient();
String lastUpdatedTime = String.valueOf((new Date().getTime()));
TraccarDevice traccarDeviceInfo = new TraccarDevice(device.getName(), device.getDeviceIdentifier(),
"online", "false", lastUpdatedTime, "", "", "", "",
"", "");
client.addDevice(traccarDeviceInfo);
}
public void updateLocation(Device device, DeviceLocation deviceLocation) throws TraccarConfigurationException {
TrackerClient client = new TrackerClient();
TraccarPosition traccarPosition = new TraccarPosition(device.getDeviceIdentifier(),
deviceLocation.getUpdatedTime().getTime(),
deviceLocation.getLatitude(), deviceLocation.getLongitude(),
deviceLocation.getBearing(), deviceLocation.getSpeed());
client.updateLocation(traccarPosition);
}
public void disDevice(String deviceIdentifier) throws TraccarConfigurationException {
TrackerClient client = new TrackerClient();
TraccarDevice traccarDeviceInfo = new TraccarDevice(deviceIdentifier);
client.disDevice(traccarDeviceInfo);
}
public void addGroup(DeviceGroup group) throws TraccarConfigurationException {
TrackerClient client = new TrackerClient();
TraccarGroups traccarGroups = new TraccarGroups(group.getName());
client.addGroup(traccarGroups);
}
}

@ -20,20 +20,19 @@
package org.wso2.carbon.device.mgt.core.traccar.common; package org.wso2.carbon.device.mgt.core.traccar.common;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarDevice; import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarDevice;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarGroups;
import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarPosition; import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarPosition;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException; import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException;
import java.io.IOException;
public interface TraccarClient { public interface TraccarClient {
void addDevice(TraccarDevice deviceInfo) throws IOException, TraccarConfigurationException; void addDevice(TraccarDevice deviceInfo) throws TraccarConfigurationException;
void updateLocation(TraccarPosition deviceInfo) throws IOException, TraccarConfigurationException; void updateLocation(TraccarPosition deviceInfo) throws TraccarConfigurationException;
String getDeviceByDeviceIdentifier(String deviceInfo) throws IOException, TraccarConfigurationException; String getDeviceByDeviceIdentifier(String deviceId) throws TraccarConfigurationException;
void disDevice(TraccarDevice deviceInfo) throws TraccarConfigurationException, IOException; void disDevice(TraccarDevice deviceInfo) throws TraccarConfigurationException;
//String addGroup(TraccarGroups groupInfo) throws IOException; void addGroup(TraccarGroups groupInfo) throws TraccarConfigurationException;
} }

@ -19,6 +19,8 @@
package org.wso2.carbon.device.mgt.core.traccar.common.beans; package org.wso2.carbon.device.mgt.core.traccar.common.beans;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
public class TraccarDevice { public class TraccarDevice {
private String deviceIdentifier; private String deviceIdentifier;
private String deviceName; private String deviceName;

Loading…
Cancel
Save