From 318d4e3f9c068f83f14f49b58dee6c03bba93554 Mon Sep 17 00:00:00 2001 From: Yohan Avishke Date: Wed, 5 Feb 2020 12:06:52 +0530 Subject: [PATCH 1/2] Remove duplicate validation checks --- .../device/mgt/core/report/mgt/ReportManagementServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/report/mgt/ReportManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/report/mgt/ReportManagementServiceImpl.java index c5e9aa3758..5d408447f5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/report/mgt/ReportManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/report/mgt/ReportManagementServiceImpl.java @@ -160,7 +160,6 @@ public class ReportManagementServiceImpl implements ReportManagementService { public PaginationResult getDevicesExpiredByOSVersion(PaginationRequest request) throws ReportManagementException, DeviceTypeNotFoundException { if (request == null || - StringUtils.isBlank(request.getDeviceType()) || StringUtils.isBlank(request.getDeviceType()) || !request.getProperties().containsKey(Constants.OS_BUILD_DATE) || (Long) request.getProperty(Constants.OS_BUILD_DATE) == 0) { From 69aac07df56cc93b90ff651fef9497f527a8519b Mon Sep 17 00:00:00 2001 From: Yohan Avishke Date: Wed, 5 Feb 2020 12:07:59 +0530 Subject: [PATCH 2/2] Fix only reading one result when multiple results are present --- .../carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 2 +- .../device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index fa49844dc5..97db197a1b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -1837,7 +1837,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try (ResultSet rs = ps.executeQuery()) { List devices = new ArrayList<>(); DeviceInfo deviceInfo = new DeviceInfo(); - if (rs.next()) { + while (rs.next()) { Device device = DeviceManagementDAOUtil.loadDevice(rs); deviceInfo.setOsVersion(rs.getString(Constants.OS_VERSION)); deviceInfo.setOsBuildDate(rs.getString(Constants.OS_BUILD_DATE)); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index 10be14fa1d..033d7c80b9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -876,7 +876,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { try (ResultSet rs = ps.executeQuery()) { List devices = new ArrayList<>(); DeviceInfo deviceInfo = new DeviceInfo(); - if (rs.next()) { + while (rs.next()) { Device device = DeviceManagementDAOUtil.loadDevice(rs); deviceInfo.setOsVersion(rs.getString(Constants.OS_VERSION)); deviceInfo.setOsBuildDate(rs.getString(Constants.OS_BUILD_DATE));