mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fix issue in initial device info persistence
This commit is contained in:
parent
52b45abb16
commit
50a7721926
@ -156,7 +156,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
||||
Connection conn;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
DeviceInfo deviceInfo = new DeviceInfo();
|
||||
DeviceInfo deviceInfo = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
|
||||
@ -169,6 +169,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
||||
if (rs.next()) {
|
||||
// deviceInfo.setIMEI(rs.getString("IMEI"));
|
||||
// deviceInfo.setIMSI(rs.getString("IMSI"));
|
||||
deviceInfo = new DeviceInfo();
|
||||
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
||||
deviceInfo.setVendor(rs.getString("VENDOR"));
|
||||
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
||||
|
||||
@ -92,7 +92,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
deviceDetailsDAO.addDeviceInformation(device.getId(), device.getEnrolmentInfo().getId(), deviceInfo);
|
||||
newDeviceInfo = deviceInfo;
|
||||
}
|
||||
if (previousDeviceProperties == null) {
|
||||
if (previousDeviceProperties.isEmpty()) {
|
||||
deviceDetailsDAO.addDeviceProperties(newDeviceInfo.getDeviceDetailsMap(), device.getId(),
|
||||
device.getEnrolmentInfo().getId());
|
||||
} else {
|
||||
|
||||
@ -116,6 +116,7 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
||||
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
||||
import org.wso2.carbon.device.mgt.core.dao.EnrollmentDAO;
|
||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsMgtDAOException;
|
||||
@ -169,9 +170,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
||||
private EnrollmentDAO enrollmentDAO;
|
||||
private ApplicationDAO applicationDAO;
|
||||
private DeviceManagementPluginRepository pluginRepository;
|
||||
private DeviceInformationManager deviceInformationManager;
|
||||
|
||||
public DeviceManagementProviderServiceImpl() {
|
||||
this.pluginRepository = new DeviceManagementPluginRepository();
|
||||
this.deviceInformationManager = new DeviceInformationManagerImpl();
|
||||
initDataAccessObjects();
|
||||
/* Registering a listener to retrieve events when some device management service plugin is installed after
|
||||
* the component is done getting initialized */
|
||||
@ -386,6 +389,16 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
||||
sendNotification(device);
|
||||
}
|
||||
extractDeviceLocationToUpdate(device);
|
||||
try {
|
||||
if (device.getDeviceInfo() != null) {
|
||||
deviceInformationManager.addDeviceInfo(device, device.getDeviceInfo());
|
||||
}
|
||||
} catch (DeviceDetailsMgtException e) {
|
||||
//This is not logging as error, neither throwing an exception as this is not an exception in main
|
||||
// business logic.
|
||||
String msg = "Error occurred while adding device info";
|
||||
log.warn(msg, e);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -3414,7 +3427,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
||||
deviceLocation.setDistance(Double.parseDouble(distance));
|
||||
deviceLocation.setSpeed(Float.parseFloat(speed));
|
||||
deviceLocation.setBearing(Float.parseFloat(bearing));
|
||||
DeviceInformationManager deviceInformationManager = new DeviceInformationManagerImpl();
|
||||
deviceInformationManager.addDeviceLocation(device, deviceLocation);
|
||||
} catch (Exception e) {
|
||||
//We are not failing the execution since this is not critical for the functionality. But logging as
|
||||
|
||||
@ -88,7 +88,7 @@ public class ProcessorImplTest extends BaseDeviceManagementTest {
|
||||
context.setConditions(conditions);
|
||||
ProcessorImpl processor = new ProcessorImpl();
|
||||
List<Device> devices = processor.execute(context);
|
||||
Assert.assertEquals(5, devices.size(), "There should be exactly 5 devices with matching search criteria");
|
||||
Assert.assertEquals(devices.size(), 5, "There should be exactly 5 devices with matching search criteria");
|
||||
}
|
||||
|
||||
@Test (description = "Search for device with or condition")
|
||||
@ -106,7 +106,7 @@ public class ProcessorImplTest extends BaseDeviceManagementTest {
|
||||
context.setConditions(conditions);
|
||||
ProcessorImpl processor = new ProcessorImpl();
|
||||
List<Device> devices = processor.execute(context);
|
||||
Assert.assertEquals(5, devices.size(), "There should be exactly 5 devices with matching search criteria");
|
||||
Assert.assertEquals(devices.size(), 5, "There should be exactly 5 devices with matching search criteria");
|
||||
}
|
||||
|
||||
@Test (description = "Search for device with wrong condition")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user