Fix traccar loading issue

pull/5/head
shamalka 2 years ago
parent 084f83bc17
commit 8ad20279d2

@ -493,7 +493,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
if (HttpReportingUtil.isTrackerEnabled()) {
String currentUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
JSONObject obj = new JSONObject(DeviceAPIClientServiceImpl.returnUser(currentUser));
DeviceAPIClientService deviceAPIClientService = DeviceMgtAPIUtils.getDeviceAPIClientService();
JSONObject obj = new JSONObject(deviceAPIClientService.returnUser(currentUser));
if (obj.has("error")) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(obj.getString("error")).build();
@ -503,7 +504,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
/*Get Device Id List*/
try {
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
DeviceAPIClientService deviceAPIClientService = DeviceMgtAPIUtils.getDeviceAPIClientService();
DeviceAccessAuthorizationService deviceAccessAuthorizationService =
DeviceMgtAPIUtils.getDeviceAccessAuthorizationService();
PaginationRequest request = new PaginationRequest(0, 0);

@ -86,7 +86,7 @@ public interface DeviceAPIClientService {
void deleteGroup(int groupId, int tenantId) throws
TrackerManagementDAOException, ExecutionException, InterruptedException;
// String returnUser(String username);
String returnUser(String username);
TrackerDeviceInfo getTrackerDevice(int deviceId, int tenantId) throws
TrackerManagementDAOException;

@ -183,7 +183,7 @@ public class TraccarClientFactory {
public String returnUser(String userName) throws TrackerManagementDAOException {
try {
String result = DeviceAPIClientServiceImpl.fetchUserInfo(userName);
String result = fetchUserInfo(userName);
Date today = new Date();
LocalDateTime tomorrow = LocalDateTime.from(today.toInstant().atZone(ZoneId.of("UTC"))).plusDays(1);
String token = DeviceAPIClientServiceImpl.generateRandomString(TraccarHandlerConstants.Types.TRACCAR_TOKEN);
@ -224,6 +224,7 @@ public class TraccarClientFactory {
}
DeviceAPIClientServiceImpl.updateUser(traccarUser, obj.getInt("id"));
}
result = fetchUserInfo(userName);
return result;
} catch (InterruptedException | ExecutionException e) {
JSONObject obj = new JSONObject();

@ -114,11 +114,11 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
client.deleteGroup(groupId, tenantId);
}
// @Override
public static String returnUser(String userName) {
@Override
public String returnUser(String username) {
TraccarClientFactory client = TraccarClientFactory.getInstance();
try {
return client.returnUser(userName);
return client.returnUser(username);
} catch (TrackerManagementDAOException e) {
JSONObject obj = new JSONObject();
String msg = "Error occurred while creating a user: "+ e;

Loading…
Cancel
Save