Merge branch 'feature/traccar-sync' into 'feature/traccar-sync'

Feature/traccar sync

See merge request entgra/carbon-device-mgt!914
feature/traccar-sync
Shamalka Navod 2 years ago
commit 87ef31ab1b

@ -497,6 +497,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(obj.getString("error")).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(obj.getString("error")).build();
} else { } else {
int userId = obj.getInt("id"); int userId = obj.getInt("id");
String msg = "";
List<Integer> traccarValidIdList = new ArrayList<>(); List<Integer> traccarValidIdList = new ArrayList<>();
/*Get Device Id List*/ /*Get Device Id List*/
try { try {
@ -558,24 +559,28 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
getAllUserDevice.getTraccarDeviceId(), getAllUserDevice.getTraccarDeviceId(),
TraccarHandlerConstants.Types.REMOVE_TYPE_SINGLE); TraccarHandlerConstants.Types.REMOVE_TYPE_SINGLE);
} }
} catch (JSONException e) {
msg = "not a JSONObject. ";
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while fetching all enrolled devices"; msg = "Error occurred while fetching all enrolled devices. ";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (DeviceAccessAuthorizationException e) { } catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization"; msg = "Error occurred while checking device access authorization. ";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
String msg = "Error occurred while mapping with deviceId ."; msg = "Error occurred while mapping with deviceId .";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (ExecutionException e) { } catch (ExecutionException e) {
String msg = "ExecutionException occured "; msg = "ExecutionException occurred ";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (InterruptedException e) { } catch (InterruptedException e) {
String msg = "InterruptedException occured "; msg = "InterruptedException occurred ";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }

@ -23,8 +23,7 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
import org.wso2.carbon.device.mgt.common.exceptions.TrackerAlreadyExistException; import org.wso2.carbon.device.mgt.common.exceptions.TrackerAlreadyExistException;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException; import org.wso2.carbon.device.mgt.core.dao.TrackerManagementDAOException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
public interface DeviceAPIClientService { public interface DeviceAPIClientService {
@ -34,15 +33,16 @@ public interface DeviceAPIClientService {
* *
* @param device to be added to update location of the device * @param device to be added to update location of the device
* @param deviceLocation to be added to update location of the device * @param deviceLocation to be added to update location of the device
* @throws TraccarConfigurationException errors thrown while inserting location of a device traccar configuration * @throws TrackerManagementDAOException errors thrown while inserting location of a traccar device
*/ */
void updateLocation(Device device, DeviceLocation deviceLocation, int tenantId) throws ExecutionException, InterruptedException; void updateLocation(Device device, DeviceLocation deviceLocation, int tenantId) throws
ExecutionException, InterruptedException;
/** /**
* Create device Traccar configuration records * Create device Traccar configuration records
* *
* @param device to be added * @param device to be added
* @throws TraccarConfigurationException errors thrown while creating a device traccar configuration * @throws TrackerManagementDAOException errors thrown while creating a traccar device
*/ */
void addDevice(Device device, int tenantId) throws ExecutionException, InterruptedException; void addDevice(Device device, int tenantId) throws ExecutionException, InterruptedException;
@ -50,32 +50,35 @@ public interface DeviceAPIClientService {
* Delete a device Traccar configuration records * Delete a device Traccar configuration records
* *
* @param deviceId to be delete a device * @param deviceId to be delete a device
* @throws TraccarConfigurationException errors thrown while deleting a device traccar configuration * @throws TrackerManagementDAOException errors thrown while deleting a traccar device
*/ */
void disEnrollDevice(int deviceId, int tenantId); void disEnrollDevice(int deviceId, int tenantId) throws ExecutionException, InterruptedException;
/** /**
* Delete a device Traccar configuration records * Delete a device Traccar configuration records
* *
* @param group to be add a group * @param group to be add a group
* @throws TraccarConfigurationException errors thrown while adding a group traccar configuration * @throws TrackerManagementDAOException errors thrown while adding a traccar group
*/ */
void addGroup(DeviceGroup group, int groupID, int tenantId) throws TraccarConfigurationException, TrackerAlreadyExistException, ExecutionException, InterruptedException; void addGroup(DeviceGroup group, int groupID, int tenantId) throws
TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException;
/** /**
* Delete a device Traccar configuration records * Delete a device Traccar configuration records
* *
* @param group to be update the group * @param group to be update the group
* @throws TraccarConfigurationException errors thrown while adding a group traccar configuration * @throws TrackerManagementDAOException errors thrown while adding a traccar group
*/ */
void updateGroup(DeviceGroup group, int groupID, int tenantId) throws ExecutionException, InterruptedException, TraccarConfigurationException, TrackerAlreadyExistException; void updateGroup(DeviceGroup group, int groupID, int tenantId) throws
TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException;
/** /**
* Delete a device Traccar configuration records * Delete a device Traccar configuration records
* *
* @param groupId to delete a group * @param groupId to delete a group
* @param tenantId to delete a group * @param tenantId to delete a group
* @throws TraccarConfigurationException errors thrown while adding a group traccar configuration * @throws TrackerManagementDAOException errors thrown while adding a traccar group
*/ */
void deleteGroup(int groupId, int tenantId) throws ExecutionException, InterruptedException, TraccarConfigurationException; void deleteGroup(int groupId, int tenantId) throws
TrackerManagementDAOException, ExecutionException, InterruptedException;
} }

@ -27,7 +27,6 @@ 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.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.beans.TraccarUser; import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarUser;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.List;
@ -35,41 +34,46 @@ import java.util.concurrent.ExecutionException;
public interface TraccarClient { public interface TraccarClient {
//String fetchDevicesByUniqueId(String uniqueId) throws ExecutionException, InterruptedException;
void addDevice(TraccarDevice deviceInfo, int tenantId) throws void addDevice(TraccarDevice deviceInfo, int tenantId) throws
TraccarConfigurationException, TrackerAlreadyExistException, ExecutionException, InterruptedException, TrackerManagementDAOException; TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException;
void updateLocation(TraccarDevice device, TraccarPosition deviceInfo, int tenantId) throws void updateLocation(TraccarDevice device, TraccarPosition deviceInfo, int tenantId) throws
TraccarConfigurationException, TrackerAlreadyExistException, ExecutionException, InterruptedException, TrackerManagementDAOException; TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException;
void disEnrollDevice(int traccarDeviceId, int tenantId) throws TraccarConfigurationException; void disEnrollDevice(int traccarDeviceId, int tenantId) throws
TrackerManagementDAOException, ExecutionException, InterruptedException;
void addGroup(TraccarGroups groupInfo, int groupId, int tenantId) throws void addGroup(TraccarGroups groupInfo, int groupId, int tenantId) throws
TraccarConfigurationException, TrackerAlreadyExistException, ExecutionException, InterruptedException; TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException;
void updateGroup(TraccarGroups groupInfo, int groupId, int tenantId) void updateGroup(TraccarGroups groupInfo, int groupId, int tenantId) throws
throws TraccarConfigurationException, TrackerAlreadyExistException, ExecutionException, InterruptedException; TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException;
void deleteGroup(int traccarGroupId, int tenantId) throws TraccarConfigurationException, ExecutionException, InterruptedException; void deleteGroup(int traccarGroupId, int tenantId) throws
TrackerManagementDAOException, ExecutionException, InterruptedException;
void setPermission(int userId, int deviceId) throws TrackerManagementDAOException, ExecutionException, InterruptedException; void setPermission(int userId, int deviceId) throws
TrackerManagementDAOException, ExecutionException, InterruptedException;
void removePermission(int userId, int deviceId, int removeType) throws ExecutionException, InterruptedException; void removePermission(int userId, int deviceId, int removeType) throws
TrackerManagementDAOException, ExecutionException, InterruptedException;
List<TrackerPermissionInfo> getUserIdofPermissionByUserIdNIdList(int userId, List<Integer> NotInDeviceIdList) throws TrackerManagementDAOException; List<TrackerPermissionInfo> getUserIdofPermissionByUserIdNIdList(int userId, List<Integer> NotInDeviceIdList)
throws TrackerManagementDAOException;
boolean getUserIdofPermissionByDeviceIdNUserId(int deviceId, int userId) throws TraccarConfigurationException, SQLException, TrackerManagementDAOException; boolean getUserIdofPermissionByDeviceIdNUserId(int deviceId, int userId) throws
TrackerManagementDAOException, SQLException;
TrackerDeviceInfo getTrackerDevice(int deviceId, int tenantId) throws TraccarConfigurationException, SQLException, TrackerManagementDAOException; TrackerDeviceInfo getTrackerDevice(int deviceId, int tenantId) throws
TrackerManagementDAOException, SQLException;
String fetchAllUsers() throws TraccarConfigurationException, ExecutionException, InterruptedException; String fetchAllUsers() throws TrackerManagementDAOException, ExecutionException, InterruptedException;
String fetchUserInfo(String userName) throws TraccarConfigurationException, ExecutionException, InterruptedException; String fetchUserInfo(String userName) throws TrackerManagementDAOException, ExecutionException, InterruptedException;
String createUser(TraccarUser traccarUser) throws ExecutionException, InterruptedException; String createUser(TraccarUser traccarUser) throws ExecutionException, InterruptedException;
String updateUser(TraccarUser traccarUser, int userId) throws ExecutionException, InterruptedException; String updateUser(TraccarUser traccarUser, int userId) throws ExecutionException, InterruptedException;
String returnUser(String userName) throws TraccarConfigurationException, TrackerManagementDAOException; String returnUser(String userName) throws TrackerManagementDAOException;
} }

@ -19,7 +19,6 @@
package org.wso2.carbon.device.mgt.core.traccar.api.service.addons; package org.wso2.carbon.device.mgt.core.traccar.api.service.addons;
import com.google.gson.Gson;
import okhttp3.ConnectionPool; import okhttp3.ConnectionPool;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
@ -47,7 +46,6 @@ 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.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.beans.TraccarUser; import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarUser;
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;
import org.wso2.carbon.device.mgt.core.traccar.common.util.TraccarUtil; import org.wso2.carbon.device.mgt.core.traccar.common.util.TraccarUtil;
import org.wso2.carbon.device.mgt.core.traccar.core.config.TraccarConfigurationManager; import org.wso2.carbon.device.mgt.core.traccar.core.config.TraccarConfigurationManager;
@ -99,12 +97,6 @@ public class TraccarClientImpl implements TraccarClient {
private String authorizeKey; private String authorizeKey;
private String serverUri; private String serverUri;
private OkHttpClientThreadPool(String publisherUrlWithContext, JSONObject payload, String method, String authorizeKey) {
this.publisherUrlWithContext = publisherUrlWithContext;
this.payload = payload;
this.method = method;
this.authorizeKey = authorizeKey;
}
private OkHttpClientThreadPool(String publisherUrlWithContext, JSONObject payload, String method, private OkHttpClientThreadPool(String publisherUrlWithContext, JSONObject payload, String method,
String authorizeKey, String serverUri) { String authorizeKey, String serverUri) {
this.publisherUrlWithContext = publisherUrlWithContext; this.publisherUrlWithContext = publisherUrlWithContext;
@ -150,7 +142,6 @@ public class TraccarClientImpl implements TraccarClient {
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()), authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
serverUrl(HttpReportingUtil.trackerServer()))); serverUrl(HttpReportingUtil.trackerServer())));
String res = result.get(); String res = result.get();
//executor.shutdown();
return res; return res;
} }
@ -239,8 +230,6 @@ public class TraccarClientImpl implements TraccarClient {
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()), authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
serverUrl(HttpReportingUtil.trackerServer()))); serverUrl(HttpReportingUtil.trackerServer())));
String result = res.get(); String result = res.get();
//executor.shutdown();
return result; return result;
} }
@ -253,11 +242,11 @@ public class TraccarClientImpl implements TraccarClient {
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()), authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
serverUrl(HttpReportingUtil.trackerServer()))); serverUrl(HttpReportingUtil.trackerServer())));
String result = res.get(); String result = res.get();
//executor.shutdown();
return result; return result;
} }
public void setPermission(int userId, int deviceId) throws ExecutionException, InterruptedException, TrackerManagementDAOException { public void setPermission(int userId, int deviceId)
throws ExecutionException, InterruptedException, TrackerManagementDAOException {
JSONObject payload = new JSONObject(); JSONObject payload = new JSONObject();
payload.put("userId", userId); payload.put("userId", userId);
payload.put("deviceId", deviceId); payload.put("deviceId", deviceId);
@ -269,31 +258,33 @@ public class TraccarClientImpl implements TraccarClient {
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()), authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
serverUrl(HttpReportingUtil.trackerServer()))); serverUrl(HttpReportingUtil.trackerServer())));
String result = res.get(); String result = res.get();
//executor.shutdown();
if(result==""){ if(result==""){
String msg = "";
try { try {
TrackerManagementDAOFactory.beginTransaction(); TrackerManagementDAOFactory.beginTransaction();
trackerDAO.addTrackerUserDevicePermission(userId, deviceId); trackerDAO.addTrackerUserDevicePermission(userId, deviceId);
TrackerManagementDAOFactory.commitTransaction(); TrackerManagementDAOFactory.commitTransaction();
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while mapping with deviceId ."; msg = "Error occurred while mapping with deviceId .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally { } finally {
TrackerManagementDAOFactory.closeConnection(); TrackerManagementDAOFactory.closeConnection();
} }
}else{ }else{
log.error("Couldnt add the permission record: "+ result); log.error("Couldn't add the permission record: "+ result);
} }
} }
public void removePermission(int userId, int deviceId, int removeType) throws ExecutionException, InterruptedException { public void removePermission(int userId, int deviceId, int removeType)
throws TrackerManagementDAOException, ExecutionException, InterruptedException {
JSONObject payload = new JSONObject(); JSONObject payload = new JSONObject();
payload.put("userId", userId); payload.put("userId", userId);
payload.put("deviceId", deviceId); payload.put("deviceId", deviceId);
@ -305,40 +296,42 @@ public class TraccarClientImpl implements TraccarClient {
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()), authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
serverUrl(HttpReportingUtil.trackerServer()))); serverUrl(HttpReportingUtil.trackerServer())));
String result = res.get(); String result = res.get();
//executor.shutdown();
if(result!=null){ if(result!=null){
String msg = "";
try { try {
TrackerManagementDAOFactory.beginTransaction(); TrackerManagementDAOFactory.beginTransaction();
trackerDAO.removeTrackerUserDevicePermission(deviceId, userId, removeType); trackerDAO.removeTrackerUserDevicePermission(deviceId, userId, removeType);
TrackerManagementDAOFactory.commitTransaction(); TrackerManagementDAOFactory.commitTransaction();
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while mapping with deviceId ."; msg = "Error occurred while mapping with deviceId .";
log.error(msg, e); log.error(msg, e);
//throw new TraccarConfigurationException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection .";
log.error(msg, e); log.error(msg, e);
//throw new TraccarConfigurationException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally { } finally {
TrackerManagementDAOFactory.closeConnection(); TrackerManagementDAOFactory.closeConnection();
} }
} }
} }
public List<TrackerPermissionInfo> getUserIdofPermissionByUserIdNIdList(int userId, List<Integer> NotInDeviceIdList) throws TrackerManagementDAOException { public List<TrackerPermissionInfo> getUserIdofPermissionByUserIdNIdList(int userId, List<Integer> NotInDeviceIdList)
throws TrackerManagementDAOException {
String msg = "";
try { try {
TrackerManagementDAOFactory.openConnection(); TrackerManagementDAOFactory.openConnection();
return trackerDAO.getUserIdofPermissionByUserIdNIdList(userId, NotInDeviceIdList); return trackerDAO.getUserIdofPermissionByUserIdNIdList(userId, NotInDeviceIdList);
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while mapping with deviceId ."; msg = "Error occurred while mapping with deviceId .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally { } finally {
@ -347,15 +340,16 @@ public class TraccarClientImpl implements TraccarClient {
} }
public TrackerDeviceInfo getTrackerDevice(int deviceId, int tenantId) throws TrackerManagementDAOException { public TrackerDeviceInfo getTrackerDevice(int deviceId, int tenantId) throws TrackerManagementDAOException {
String msg = "";
try { try {
TrackerManagementDAOFactory.openConnection(); TrackerManagementDAOFactory.openConnection();
return trackerDAO.getTrackerDevice(deviceId, tenantId); return trackerDAO.getTrackerDevice(deviceId, tenantId);
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
String msg="Could not add new device location"; msg="Could not add new device location";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally{ } finally{
@ -363,17 +357,19 @@ public class TraccarClientImpl implements TraccarClient {
} }
} }
public boolean getUserIdofPermissionByDeviceIdNUserId(int deviceId, int userId) throws TrackerManagementDAOException { public boolean getUserIdofPermissionByDeviceIdNUserId(int deviceId, int userId)
throws TrackerManagementDAOException {
Boolean result = false; Boolean result = false;
String msg = "";
try { try {
TrackerManagementDAOFactory.openConnection(); TrackerManagementDAOFactory.openConnection();
result = trackerDAO.getUserIdofPermissionByDeviceIdNUserId(deviceId, userId); result = trackerDAO.getUserIdofPermissionByDeviceIdNUserId(deviceId, userId);
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
String msg = "Error occurred while mapping with deviceId ."; msg = "Error occurred while mapping with deviceId .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally { } finally {
@ -386,25 +382,26 @@ public class TraccarClientImpl implements TraccarClient {
* Add Traccar Device operation. * Add Traccar Device operation.
* @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
* @throws TraccarConfigurationException Failed while add Traccar Device the operation * @throws TrackerManagementDAOException Failed while add Traccar Device the operation
*/ */
public void addDevice(TraccarDevice traccarDevice, int tenantId) throws public void addDevice(TraccarDevice traccarDevice, int tenantId) throws
TrackerAlreadyExistException, ExecutionException, InterruptedException, TrackerManagementDAOException { TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
TrackerDeviceInfo trackerDeviceInfo = null; TrackerDeviceInfo trackerDeviceInfo = null;
String msg = "";
try { try {
TrackerManagementDAOFactory.openConnection(); TrackerManagementDAOFactory.openConnection();
trackerDeviceInfo = trackerDAO.getTrackerDevice(traccarDevice.getId(), tenantId); trackerDeviceInfo = trackerDAO.getTrackerDevice(traccarDevice.getId(), tenantId);
if(trackerDeviceInfo!=null){ if(trackerDeviceInfo!=null){
String msg = "The device already exist"; msg = "The device already exist";
log.error(msg); log.error(msg);
//throw new TrackerAlreadyExistException(msg); throw new TrackerAlreadyExistException(msg);
} }
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
String msg = "Error occurred while mapping with deviceId ."; msg = "Error occurred while mapping with deviceId .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally { } finally {
@ -421,7 +418,6 @@ public class TraccarClientImpl implements TraccarClient {
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()), authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
serverUrl(HttpReportingUtil.trackerServer()))); serverUrl(HttpReportingUtil.trackerServer())));
String result = res.get(); String result = res.get();
log.info("---------result--------");
if(result.charAt(0)=='{'){ if(result.charAt(0)=='{'){
JSONObject obj = new JSONObject(result); JSONObject obj = new JSONObject(result);
if (obj.has("id")){ if (obj.has("id")){
@ -438,12 +434,12 @@ public class TraccarClientImpl implements TraccarClient {
TrackerManagementDAOFactory.commitTransaction(); TrackerManagementDAOFactory.commitTransaction();
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while mapping with deviceId ."; msg = "Error occurred while mapping with deviceId .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally { } finally {
@ -455,24 +451,25 @@ public class TraccarClientImpl implements TraccarClient {
} }
} }
} }
//executor.shutdown();
} }
/** /**
* Add Device GPS Location operation. * Add Device GPS Location operation.
* @param deviceInfo with DeviceIdentifier, Timestamp, Lat, Lon, Bearing, Speed, ignition * @param deviceInfo with DeviceIdentifier, Timestamp, Lat, Lon, Bearing, Speed, ignition
*/ */
public void updateLocation(TraccarDevice device, TraccarPosition deviceInfo, int tenantId) throws TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException { public void updateLocation(TraccarDevice device, TraccarPosition deviceInfo, int tenantId) throws
TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
TrackerDeviceInfo trackerDeviceInfo = null; TrackerDeviceInfo trackerDeviceInfo = null;
String msg = "";
try { try {
TrackerManagementDAOFactory.openConnection(); TrackerManagementDAOFactory.openConnection();
trackerDeviceInfo = trackerDAO.getTrackerDevice(device.getId(), tenantId); trackerDeviceInfo = trackerDAO.getTrackerDevice(device.getId(), tenantId);
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection .";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
String msg="Could not add new device location"; msg = "Could not add new device location";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally{ } finally{
@ -495,28 +492,25 @@ public class TraccarClientImpl implements TraccarClient {
executor.submit(new OkHttpClientThreadPool(url, null, method, executor.submit(new OkHttpClientThreadPool(url, null, method,
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()), authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
"http://localhost:")); "http://localhost:"));
//executor.shutdown();
} }
} }
/** /**
* Dis-enroll a Device operation. * Dis-enroll a Device operation.
* @param deviceId identified via deviceIdentifier * @param deviceId identified via deviceIdentifier
* @throws TraccarConfigurationException Failed while dis-enroll a Traccar Device operation * @throws TrackerManagementDAOException Failed while dis-enroll a Traccar Device operation
*/ */
public void disEnrollDevice(int deviceId, int tenantId) throws TraccarConfigurationException { public void disEnrollDevice(int deviceId, int tenantId) throws TrackerManagementDAOException, ExecutionException, InterruptedException {
TrackerDeviceInfo trackerDeviceInfo = null; TrackerDeviceInfo trackerDeviceInfo = null;
List<TrackerPermissionInfo> trackerPermissionInfo = null; List<TrackerPermissionInfo> trackerPermissionInfo = null;
//JSONObject trackerDevice = null; String msg = "";
try { try {
TrackerManagementDAOFactory.beginTransaction(); TrackerManagementDAOFactory.beginTransaction();
trackerDeviceInfo = trackerDAO.getTrackerDevice(deviceId, tenantId); trackerDeviceInfo = trackerDAO.getTrackerDevice(deviceId, tenantId);
log.info("------deviceId-----" + deviceId); log.info("deviceId - " + deviceId);
log.info(trackerDeviceInfo);
if(trackerDeviceInfo!=null){ if(trackerDeviceInfo!=null){
//trackerDevice = new JSONObject(trackerDeviceInfo);
int status = trackerDAO.removeTrackerDevice(deviceId, tenantId); int status = trackerDAO.removeTrackerDevice(deviceId, tenantId);
log.info("Status" + status); log.info("Status" + status);
TrackerManagementDAOFactory.commitTransaction(); TrackerManagementDAOFactory.commitTransaction();
@ -525,14 +519,14 @@ public class TraccarClientImpl implements TraccarClient {
} }
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred establishing the DB connection"; msg = "Error occurred establishing the DB connection";
log.error(msg, e); log.error(msg, e);
throw new TraccarConfigurationException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while mapping with deviceId"; msg = "Error occurred while mapping with deviceId";
log.error(msg, e); log.error(msg, e);
throw new TraccarConfigurationException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally { } finally {
TrackerManagementDAOFactory.closeConnection(); TrackerManagementDAOFactory.closeConnection();
} }
@ -546,7 +540,6 @@ public class TraccarClientImpl implements TraccarClient {
executor.submit(new OkHttpClientThreadPool(url, null, method, executor.submit(new OkHttpClientThreadPool(url, null, method,
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()), authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
serverUrl(HttpReportingUtil.trackerServer()))); serverUrl(HttpReportingUtil.trackerServer())));
//executor.shutdown();
//remove permissions //remove permissions
try { try {
@ -556,10 +549,7 @@ public class TraccarClientImpl implements TraccarClient {
TraccarHandlerConstants.Types.REMOVE_TYPE_MULTIPLE); TraccarHandlerConstants.Types.REMOVE_TYPE_MULTIPLE);
} catch (ExecutionException e) { } catch (ExecutionException e) {
log.error("ExecutionException : " + e); log.error("ExecutionException : " + e);
//throw new RuntimeException(e); throw new ExecutionException(e);
} catch (InterruptedException e) {
log.error("InterruptedException : " + e);
//throw new RuntimeException(e);
} }
} }
} }
@ -567,27 +557,28 @@ public class TraccarClientImpl implements TraccarClient {
/** /**
* Add Traccar Device operation. * Add Traccar Device operation.
* @param groupInfo with groupName * @param groupInfo with groupName
* @throws TraccarConfigurationException Failed while add Traccar Device the operation * @throws TrackerManagementDAOException Failed while add Traccar Device the operation
*/ */
public void addGroup(TraccarGroups groupInfo, int groupId, int tenantId) throws public void addGroup(TraccarGroups groupInfo, int groupId, int tenantId) throws
TraccarConfigurationException, TrackerAlreadyExistException, ExecutionException, InterruptedException { TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
TrackerGroupInfo trackerGroupInfo = null; TrackerGroupInfo trackerGroupInfo = null;
String msg = "";
try { try {
TrackerManagementDAOFactory.openConnection(); TrackerManagementDAOFactory.openConnection();
trackerGroupInfo = trackerDAO.getTrackerGroup(groupId, tenantId); trackerGroupInfo = trackerDAO.getTrackerGroup(groupId, tenantId);
if (trackerGroupInfo!=null){ if (trackerGroupInfo!=null){
String msg = "The group already exit"; msg = "The group already exit";
log.error(msg); log.error(msg);
throw new TrackerAlreadyExistException(msg); throw new TrackerAlreadyExistException(msg);
} }
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
String msg = "Error occurred while mapping with groupId."; msg = "Error occurred while mapping with groupId.";
log.error(msg, e); log.error(msg, e);
throw new TraccarConfigurationException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred establishing the DB connection."; msg = "Error occurred establishing the DB connection.";
log.error(msg, e); log.error(msg, e);
throw new TraccarConfigurationException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally { } finally {
TrackerManagementDAOFactory.closeConnection(); TrackerManagementDAOFactory.closeConnection();
} }
@ -617,15 +608,15 @@ public class TraccarClientImpl implements TraccarClient {
trackerDAO.updateTrackerGroupIdANDStatus(trackerGroupInfo.getTraccarGroupId(), groupId, tenantId, 1); trackerDAO.updateTrackerGroupIdANDStatus(trackerGroupInfo.getTraccarGroupId(), groupId, tenantId, 1);
} }
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
String msg = "Error occurred while mapping with deviceId ."; msg = "Error occurred while mapping with deviceId. ";
log.error(msg, e); log.error(msg, e);
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
throw new TraccarConfigurationException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection. ";
log.error(msg, e); log.error(msg, e);
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
throw new TraccarConfigurationException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally { } finally {
TrackerManagementDAOFactory.closeConnection(); TrackerManagementDAOFactory.closeConnection();
} }
@ -635,25 +626,25 @@ public class TraccarClientImpl implements TraccarClient {
}else{ }else{
log.error("Something went wrong_2: " + result); log.error("Something went wrong_2: " + result);
} }
//executor.shutdown();
} }
/** /**
* update Traccar Group operation. * update Traccar Group operation.
* @param groupInfo with groupName * @param groupInfo with groupName
* @throws TraccarConfigurationException Failed while add Traccar Device the operation * @throws TrackerManagementDAOException Failed while add Traccar Device the operation
*/ */
public void updateGroup(TraccarGroups groupInfo, int groupId, int tenantId) throws public void updateGroup(TraccarGroups groupInfo, int groupId, int tenantId) throws
TraccarConfigurationException, TrackerAlreadyExistException, ExecutionException, InterruptedException { TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
TrackerGroupInfo res = null; TrackerGroupInfo res = null;
String msg = "";
try { try {
TrackerManagementDAOFactory.openConnection(); TrackerManagementDAOFactory.openConnection();
res = trackerDAO.getTrackerGroup(groupId, tenantId); res = trackerDAO.getTrackerGroup(groupId, tenantId);
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection. ";
log.error(msg, e); log.error(msg, e);
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
String msg="Could not find traccar group details"; msg="Could not find traccar group details. ";
log.error(msg, e); log.error(msg, e);
} finally{ } finally{
TrackerManagementDAOFactory.closeConnection(); TrackerManagementDAOFactory.closeConnection();
@ -670,14 +661,14 @@ public class TraccarClientImpl implements TraccarClient {
TrackerManagementDAOFactory.commitTransaction(); TrackerManagementDAOFactory.commitTransaction();
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg="Could not update the traccar group"; msg="Could not update the traccar group. ";
log.error(msg, e); log.error(msg, e);
throw new TraccarConfigurationException(msg, e); throw new TrackerManagementDAOException(msg, e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred establishing the DB connection ."; msg = "Error occurred establishing the DB connection. ";
log.error(msg, e); log.error(msg, e);
throw new TraccarConfigurationException(msg, e); throw new TrackerManagementDAOException(msg, e);
} finally{ } finally{
TrackerManagementDAOFactory.closeConnection(); TrackerManagementDAOFactory.closeConnection();
} }
@ -694,18 +685,18 @@ public class TraccarClientImpl implements TraccarClient {
executor.submit(new OkHttpClientThreadPool(url, payload, method, executor.submit(new OkHttpClientThreadPool(url, payload, method,
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()), authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
serverUrl(HttpReportingUtil.trackerServer()))); serverUrl(HttpReportingUtil.trackerServer())));
//executor.shutdown();
} }
} }
/** /**
* Add Traccar Device operation. * Add Traccar Device operation.
* @param groupId * @param groupId
* @throws TraccarConfigurationException Failed while add Traccar Device the operation * @throws TrackerManagementDAOException Failed while add Traccar Device the operation
*/ */
public void deleteGroup(int groupId, int tenantId) throws TraccarConfigurationException, ExecutionException, InterruptedException { public void deleteGroup(int groupId, int tenantId) throws TrackerManagementDAOException, ExecutionException, InterruptedException {
TrackerGroupInfo res = null; TrackerGroupInfo res = null;
JSONObject obj = null; JSONObject obj = null;
String msg = "";
try { try {
TrackerManagementDAOFactory.beginTransaction(); TrackerManagementDAOFactory.beginTransaction();
res = trackerDAO.getTrackerGroup(groupId, tenantId); res = trackerDAO.getTrackerGroup(groupId, tenantId);
@ -721,17 +712,18 @@ public class TraccarClientImpl implements TraccarClient {
executor.submit(new OkHttpClientThreadPool(url, null, method, executor.submit(new OkHttpClientThreadPool(url, null, method,
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()), authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
serverUrl(HttpReportingUtil.trackerServer()))); serverUrl(HttpReportingUtil.trackerServer())));
//executor.shutdown();
} }
} }
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred establishing the DB connection"; msg = "Error occurred establishing the DB connection. ";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e);
} catch (TrackerManagementDAOException e) { } catch (TrackerManagementDAOException e) {
TrackerManagementDAOFactory.rollbackTransaction(); TrackerManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while mapping with groupId"; msg = "Error occurred while mapping with groupId. ";
log.error(msg, e); log.error(msg, e);
throw new TrackerManagementDAOException(msg, e);
} finally { } finally {
TrackerManagementDAOFactory.closeConnection(); TrackerManagementDAOFactory.closeConnection();
} }

@ -26,7 +26,6 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.TrackerDeviceInfo; import org.wso2.carbon.device.mgt.common.TrackerDeviceInfo;
import org.wso2.carbon.device.mgt.common.TrackerPermissionInfo; import org.wso2.carbon.device.mgt.common.TrackerPermissionInfo;
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.common.exceptions.TrackerAlreadyExistException; import org.wso2.carbon.device.mgt.common.exceptions.TrackerAlreadyExistException;
import org.wso2.carbon.device.mgt.core.dao.TrackerManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.TrackerManagementDAOException;
@ -36,7 +35,6 @@ 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.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.beans.TraccarUser; import org.wso2.carbon.device.mgt.core.traccar.common.beans.TraccarUser;
import org.wso2.carbon.device.mgt.core.traccar.common.config.TraccarConfigurationException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -85,31 +83,32 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
} }
} }
public void disEnrollDevice(int deviceId, int tenantId) { public void disEnrollDevice(int deviceId, int tenantId) throws ExecutionException, InterruptedException{
TraccarClientImpl client = new TraccarClientImpl(); TraccarClientImpl client = new TraccarClientImpl();
try { try {
client.disEnrollDevice(deviceId, tenantId); client.disEnrollDevice(deviceId, tenantId);
} catch (TraccarConfigurationException e) { } catch (TrackerManagementDAOException e) {
String msg = "Error occurred while dis-enrolling the device"; String msg = "Error occurred while dis-enrolling the device";
log.error(msg, e); log.error(msg, e);
} }
} }
public void addGroup(DeviceGroup group, int groupId, int tenantId) throws public void addGroup(DeviceGroup group, int groupId, int tenantId) throws
TraccarConfigurationException, TrackerAlreadyExistException, ExecutionException, InterruptedException { TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
TraccarClientImpl client = new TraccarClientImpl(); TraccarClientImpl client = new TraccarClientImpl();
TraccarGroups traccarGroups = new TraccarGroups(group.getName()); TraccarGroups traccarGroups = new TraccarGroups(group.getName());
client.addGroup(traccarGroups, groupId, tenantId); client.addGroup(traccarGroups, groupId, tenantId);
} }
public void updateGroup(DeviceGroup group, int groupId, int tenantId) throws TraccarConfigurationException, TrackerAlreadyExistException, ExecutionException, InterruptedException { public void updateGroup(DeviceGroup group, int groupId, int tenantId) throws
TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
TraccarClientImpl client = new TraccarClientImpl(); TraccarClientImpl client = new TraccarClientImpl();
TraccarGroups traccarGroups = new TraccarGroups(group.getName()); TraccarGroups traccarGroups = new TraccarGroups(group.getName());
client.updateGroup(traccarGroups, groupId, tenantId); client.updateGroup(traccarGroups, groupId, tenantId);
} }
public void deleteGroup(int groupId, int tenantId) throws public void deleteGroup(int groupId, int tenantId) throws
TraccarConfigurationException, ExecutionException, InterruptedException { TrackerManagementDAOException, ExecutionException, InterruptedException {
TraccarClientImpl client = new TraccarClientImpl(); TraccarClientImpl client = new TraccarClientImpl();
client.deleteGroup(groupId, tenantId); client.deleteGroup(groupId, tenantId);
} }
@ -131,14 +130,13 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
return client.getUserIdofPermissionByDeviceIdNUserId(deviceId, userId); return client.getUserIdofPermissionByDeviceIdNUserId(deviceId, userId);
} }
public static String createUser(TraccarUser traccarUser) throws public static String createUser(TraccarUser traccarUser) throws ExecutionException, InterruptedException {
TrackerManagementDAOException, ExecutionException, InterruptedException {
TraccarClientImpl client = new TraccarClientImpl(); TraccarClientImpl client = new TraccarClientImpl();
return client.createUser(traccarUser); return client.createUser(traccarUser);
} }
public static String updateUser(TraccarUser traccarUser, int userId) throws public static String updateUser(TraccarUser traccarUser, int userId) throws
TrackerManagementDAOException, ExecutionException, InterruptedException { ExecutionException, InterruptedException {
TraccarClientImpl client = new TraccarClientImpl(); TraccarClientImpl client = new TraccarClientImpl();
return client.updateUser(traccarUser, userId); return client.updateUser(traccarUser, userId);
} }
@ -161,12 +159,14 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
client.setPermission(userId, deviceId); client.setPermission(userId, deviceId);
} }
public static void removeTrackerUserDevicePermission(int userId, int deviceId, int removeType) throws TrackerManagementDAOException, ExecutionException, InterruptedException { public static void removeTrackerUserDevicePermission(int userId, int deviceId, int removeType) throws
TrackerManagementDAOException, ExecutionException, InterruptedException {
TraccarClientImpl client = new TraccarClientImpl(); TraccarClientImpl client = new TraccarClientImpl();
client.removePermission(userId, deviceId, removeType); client.removePermission(userId, deviceId, removeType);
} }
public static List<TrackerPermissionInfo> getUserIdofPermissionByUserIdNIdList(int userId, List<Integer> NotInDeviceIdList) throws TrackerManagementDAOException { public static List<TrackerPermissionInfo> getUserIdofPermissionByUserIdNIdList(int userId, List<Integer> NotInDeviceIdList) throws
TrackerManagementDAOException {
TraccarClientImpl client = new TraccarClientImpl(); TraccarClientImpl client = new TraccarClientImpl();
return client.getUserIdofPermissionByUserIdNIdList(userId, NotInDeviceIdList); return client.getUserIdofPermissionByUserIdNIdList(userId, NotInDeviceIdList);
} }

@ -1,38 +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.common.config;
public class TraccarConfigurationException extends Exception {
public TraccarConfigurationException() {
super();
}
public TraccarConfigurationException(String message) {
super(message);
}
public TraccarConfigurationException(String message, Throwable cause) {
super(message, cause);
}
public TraccarConfigurationException(Throwable cause) {
super(cause);
}
}
Loading…
Cancel
Save