|
|
@ -45,6 +45,7 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
|
|
|
|
private static final Log log = LogFactory.getLog(DeviceAPIClientServiceImpl.class);
|
|
|
|
private static final Log log = LogFactory.getLog(DeviceAPIClientServiceImpl.class);
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addDevice(Device device, int tenantId) throws ExecutionException, InterruptedException {
|
|
|
|
public void addDevice(Device device, int tenantId) throws ExecutionException, InterruptedException {
|
|
|
|
String lastUpdatedTime = String.valueOf((new Date().getTime()));
|
|
|
|
String lastUpdatedTime = String.valueOf((new Date().getTime()));
|
|
|
|
TraccarDevice traccarDevice = new TraccarDevice(device.getId(), device.getName(), device.getDeviceIdentifier(),
|
|
|
|
TraccarDevice traccarDevice = new TraccarDevice(device.getId(), device.getName(), device.getDeviceIdentifier(),
|
|
|
@ -61,6 +62,7 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateLocation(Device device, DeviceLocation deviceLocation, int tenantId) throws ExecutionException, InterruptedException {
|
|
|
|
public void updateLocation(Device device, DeviceLocation deviceLocation, int tenantId) throws ExecutionException, InterruptedException {
|
|
|
|
TraccarPosition traccarPosition = new TraccarPosition(device.getDeviceIdentifier(),
|
|
|
|
TraccarPosition traccarPosition = new TraccarPosition(device.getDeviceIdentifier(),
|
|
|
|
deviceLocation.getUpdatedTime().getTime(),
|
|
|
|
deviceLocation.getUpdatedTime().getTime(),
|
|
|
@ -82,6 +84,7 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void disEnrollDevice(int deviceId, int tenantId) throws ExecutionException, InterruptedException{
|
|
|
|
public void disEnrollDevice(int deviceId, int tenantId) throws ExecutionException, InterruptedException{
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
client.disEnrollDevice(deviceId, tenantId);
|
|
|
|
client.disEnrollDevice(deviceId, tenantId);
|
|
|
@ -91,79 +94,88 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addGroup(DeviceGroup group, int groupId, int tenantId) throws
|
|
|
|
public void addGroup(DeviceGroup group, int groupId, int tenantId) throws
|
|
|
|
TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
|
|
|
|
TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
|
|
|
|
TraccarGroups traccarGroups = new TraccarGroups(group.getName());
|
|
|
|
TraccarGroups traccarGroups = new TraccarGroups(group.getName());
|
|
|
|
client.addGroup(traccarGroups, groupId, tenantId);
|
|
|
|
client.addGroup(traccarGroups, groupId, tenantId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateGroup(DeviceGroup group, int groupId, int tenantId) throws
|
|
|
|
public void updateGroup(DeviceGroup group, int groupId, int tenantId) throws
|
|
|
|
TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
|
|
|
|
TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
|
|
|
|
TraccarGroups traccarGroups = new TraccarGroups(group.getName());
|
|
|
|
TraccarGroups traccarGroups = new TraccarGroups(group.getName());
|
|
|
|
client.updateGroup(traccarGroups, groupId, tenantId);
|
|
|
|
client.updateGroup(traccarGroups, groupId, tenantId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void deleteGroup(int groupId, int tenantId) throws
|
|
|
|
public void deleteGroup(int groupId, int tenantId) throws
|
|
|
|
TrackerManagementDAOException, ExecutionException, InterruptedException {
|
|
|
|
TrackerManagementDAOException, ExecutionException, InterruptedException {
|
|
|
|
client.deleteGroup(groupId, tenantId);
|
|
|
|
client.deleteGroup(groupId, tenantId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String fetchUserInfo(String userName) throws ExecutionException, InterruptedException {
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String returnUser(String userName) {
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
return client.fetchUserInfo(userName);
|
|
|
|
try {
|
|
|
|
|
|
|
|
return client.returnUser(userName);
|
|
|
|
|
|
|
|
} catch (TrackerManagementDAOException e) {
|
|
|
|
|
|
|
|
JSONObject obj = new JSONObject();
|
|
|
|
|
|
|
|
String msg = "Error occurred while creating a user: "+ e;
|
|
|
|
|
|
|
|
obj.put("error", msg);
|
|
|
|
|
|
|
|
return obj.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static TrackerDeviceInfo getTrackerDevice(int deviceId, int tenantId) throws
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public TrackerDeviceInfo getTrackerDevice(int deviceId, int tenantId) throws
|
|
|
|
TrackerManagementDAOException {
|
|
|
|
TrackerManagementDAOException {
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
return client.getTrackerDevice(deviceId, tenantId);
|
|
|
|
return client.getTrackerDevice(deviceId, tenantId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean getUserIdofPermissionByDeviceIdNUserId(int deviceId, int userId) throws
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean getUserIdofPermissionByDeviceIdNUserId(int deviceId, int userId) throws
|
|
|
|
TrackerManagementDAOException {
|
|
|
|
TrackerManagementDAOException {
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
return client.getUserIdofPermissionByDeviceIdNUserId(deviceId, userId);
|
|
|
|
return client.getUserIdofPermissionByDeviceIdNUserId(deviceId, userId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String createUser(TraccarUser traccarUser) throws ExecutionException, InterruptedException {
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void addTrackerUserDevicePermission(int userId, int deviceId) throws
|
|
|
|
|
|
|
|
TrackerManagementDAOException, ExecutionException, InterruptedException {
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
return client.createUser(traccarUser);
|
|
|
|
client.setPermission(userId, deviceId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String updateUser(TraccarUser traccarUser, int userId) throws
|
|
|
|
@Override
|
|
|
|
ExecutionException, InterruptedException {
|
|
|
|
public List<TrackerPermissionInfo> getUserIdofPermissionByUserIdNIdList(int userId, List<Integer> NotInDeviceIdList) throws
|
|
|
|
|
|
|
|
TrackerManagementDAOException {
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
return client.updateUser(traccarUser, userId);
|
|
|
|
return client.getUserIdofPermissionByUserIdNIdList(userId, NotInDeviceIdList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String returnUser(String userName) {
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void removeTrackerUserDevicePermission(int userId, int deviceId, int removeType) throws
|
|
|
|
|
|
|
|
TrackerManagementDAOException, ExecutionException, InterruptedException {
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
try {
|
|
|
|
client.removePermission(userId, deviceId, removeType);
|
|
|
|
return client.returnUser(userName);
|
|
|
|
|
|
|
|
} catch (TrackerManagementDAOException e) {
|
|
|
|
|
|
|
|
JSONObject obj = new JSONObject();
|
|
|
|
|
|
|
|
String msg = "Error occurred while creating a user: "+ e;
|
|
|
|
|
|
|
|
obj.put("error", msg);
|
|
|
|
|
|
|
|
return obj.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void addTrackerUserDevicePermission(int userId, int deviceId) throws
|
|
|
|
public static String fetchUserInfo(String userName) throws ExecutionException, InterruptedException {
|
|
|
|
TrackerManagementDAOException, ExecutionException, InterruptedException {
|
|
|
|
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
client.setPermission(userId, deviceId);
|
|
|
|
return client.fetchUserInfo(userName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void removeTrackerUserDevicePermission(int userId, int deviceId, int removeType) throws
|
|
|
|
public static String createUser(TraccarUser traccarUser) throws ExecutionException, InterruptedException {
|
|
|
|
TrackerManagementDAOException, ExecutionException, InterruptedException {
|
|
|
|
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
client.removePermission(userId, deviceId, removeType);
|
|
|
|
return client.createUser(traccarUser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static List<TrackerPermissionInfo> getUserIdofPermissionByUserIdNIdList(int userId, List<Integer> NotInDeviceIdList) throws
|
|
|
|
public static String updateUser(TraccarUser traccarUser, int userId) throws
|
|
|
|
TrackerManagementDAOException {
|
|
|
|
ExecutionException, InterruptedException {
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
return client.getUserIdofPermissionByUserIdNIdList(userId, NotInDeviceIdList);
|
|
|
|
return client.updateUser(traccarUser, userId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String generateRandomString(int len) {
|
|
|
|
public static String generateRandomString(int len) {
|
|
|
|