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

@ -493,7 +493,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
if (HttpReportingUtil.isTrackerEnabled()) {
String currentUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
JSONObject obj = new JSONObject(DeviceMgtAPIUtils.getDeviceAPIClientService().returnUser(currentUser));
JSONObject obj = new JSONObject(DeviceAPIClientServiceImpl.returnUser(currentUser));
if (obj.has("error")) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(obj.getString("error")).build();
@ -535,11 +535,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
TrackerDeviceInfo trackerDevice;
for (Device device : devices.getList()) {
trackerDevice = deviceAPIClientService.getTrackerDevice(device.getId(), tenantId);
if(trackerDevice == null) {
String msg = "Tracker device not found for the device ID: " + device.getId();
log.error(msg);
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} else {
if(trackerDevice != null) {
int traccarDeviceId = trackerDevice.getTraccarDeviceId();
boolean getPermission = deviceAPIClientService.getUserIdofPermissionByDeviceIdNUserId(traccarDeviceId, userId);
traccarValidIdList.add(traccarDeviceId);

@ -31,7 +31,10 @@ import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.dao.util.TrackerManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.traccar.common.TraccarHandlerConstants;
import java.sql.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@ -106,8 +109,8 @@ public class TrackerDAOImpl implements TrackerDAO {
TrackerDeviceInfo trackerDeviceInfo = null;
try {
Connection conn = TrackerManagementDAOFactory.getConnection();
String sql = "SELECT ID, TRACCAR_DEVICE_ID, DEVICE_ID, TENANT_ID, STATUS FROM DM_EXT_DEVICE_MAPPING WHERE " +
"DEVICE_ID = ? AND TENANT_ID = ? ORDER BY ID DESC LIMIT 1";
String sql = "SELECT DM_EXT_DEVICE_MAPPING.ID, DM_EXT_DEVICE_MAPPING.TRACCAR_DEVICE_ID, DM_EXT_DEVICE_MAPPING.DEVICE_ID, DM_EXT_DEVICE_MAPPING.TENANT_ID, DM_EXT_DEVICE_MAPPING.STATUS FROM DM_EXT_DEVICE_MAPPING JOIN DM_DEVICE ON DM_EXT_DEVICE_MAPPING.DEVICE_ID=DM_DEVICE.ID WHERE " +
"DM_EXT_DEVICE_MAPPING.DEVICE_ID = ? AND DM_EXT_DEVICE_MAPPING.TENANT_ID = ? ORDER BY DM_EXT_DEVICE_MAPPING.ID DESC LIMIT 1";
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);

@ -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;

@ -178,7 +178,6 @@ public class TraccarClientFactory {
}
}
}
return TraccarHandlerConstants.Types.USER_NOT_FOUND;
}

@ -114,8 +114,8 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
client.deleteGroup(groupId, tenantId);
}
@Override
public String returnUser(String userName) {
// @Override
public static String returnUser(String userName) {
TraccarClientFactory client = TraccarClientFactory.getInstance();
try {
return client.returnUser(userName);

Loading…
Cancel
Save