|
|
|
@ -45,6 +45,7 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
|
|
|
|
|
private static final Log log = LogFactory.getLog(DeviceAPIClientServiceImpl.class);
|
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addDevice(Device device, int tenantId) throws ExecutionException, InterruptedException {
|
|
|
|
|
String lastUpdatedTime = String.valueOf((new Date().getTime()));
|
|
|
|
|
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 {
|
|
|
|
|
TraccarPosition traccarPosition = new TraccarPosition(device.getDeviceIdentifier(),
|
|
|
|
|
deviceLocation.getUpdatedTime().getTime(),
|
|
|
|
@ -82,6 +84,7 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void disEnrollDevice(int deviceId, int tenantId) throws ExecutionException, InterruptedException{
|
|
|
|
|
try {
|
|
|
|
|
client.disEnrollDevice(deviceId, tenantId);
|
|
|
|
@ -91,79 +94,88 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addGroup(DeviceGroup group, int groupId, int tenantId) throws
|
|
|
|
|
TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
|
|
|
|
|
TraccarGroups traccarGroups = new TraccarGroups(group.getName());
|
|
|
|
|
client.addGroup(traccarGroups, groupId, tenantId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateGroup(DeviceGroup group, int groupId, int tenantId) throws
|
|
|
|
|
TrackerManagementDAOException, TrackerAlreadyExistException, ExecutionException, InterruptedException {
|
|
|
|
|
TraccarGroups traccarGroups = new TraccarGroups(group.getName());
|
|
|
|
|
client.updateGroup(traccarGroups, groupId, tenantId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteGroup(int groupId, int tenantId) throws
|
|
|
|
|
TrackerManagementDAOException, ExecutionException, InterruptedException {
|
|
|
|
|
client.deleteGroup(groupId, tenantId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String fetchUserInfo(String userName) throws ExecutionException, InterruptedException {
|
|
|
|
|
@Override
|
|
|
|
|
public String returnUser(String userName) {
|
|
|
|
|
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 {
|
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
|
return client.getTrackerDevice(deviceId, tenantId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean getUserIdofPermissionByDeviceIdNUserId(int deviceId, int userId) throws
|
|
|
|
|
@Override
|
|
|
|
|
public boolean getUserIdofPermissionByDeviceIdNUserId(int deviceId, int userId) throws
|
|
|
|
|
TrackerManagementDAOException {
|
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
|
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();
|
|
|
|
|
return client.createUser(traccarUser);
|
|
|
|
|
client.setPermission(userId, deviceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String updateUser(TraccarUser traccarUser, int userId) throws
|
|
|
|
|
ExecutionException, InterruptedException {
|
|
|
|
|
@Override
|
|
|
|
|
public List<TrackerPermissionInfo> getUserIdofPermissionByUserIdNIdList(int userId, List<Integer> NotInDeviceIdList) throws
|
|
|
|
|
TrackerManagementDAOException {
|
|
|
|
|
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();
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
client.removePermission(userId, deviceId, removeType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void addTrackerUserDevicePermission(int userId, int deviceId) throws
|
|
|
|
|
TrackerManagementDAOException, ExecutionException, InterruptedException {
|
|
|
|
|
public static String fetchUserInfo(String userName) throws ExecutionException, InterruptedException {
|
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
|
client.setPermission(userId, deviceId);
|
|
|
|
|
return client.fetchUserInfo(userName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void removeTrackerUserDevicePermission(int userId, int deviceId, int removeType) throws
|
|
|
|
|
TrackerManagementDAOException, ExecutionException, InterruptedException {
|
|
|
|
|
public static String createUser(TraccarUser traccarUser) throws ExecutionException, InterruptedException {
|
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
|
client.removePermission(userId, deviceId, removeType);
|
|
|
|
|
return client.createUser(traccarUser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<TrackerPermissionInfo> getUserIdofPermissionByUserIdNIdList(int userId, List<Integer> NotInDeviceIdList) throws
|
|
|
|
|
TrackerManagementDAOException {
|
|
|
|
|
public static String updateUser(TraccarUser traccarUser, int userId) throws
|
|
|
|
|
ExecutionException, InterruptedException {
|
|
|
|
|
TraccarClientFactory client = TraccarClientFactory.getInstance();
|
|
|
|
|
return client.getUserIdofPermissionByUserIdNIdList(userId, NotInDeviceIdList);
|
|
|
|
|
return client.updateUser(traccarUser, userId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String generateRandomString(int len) {
|
|
|
|
|