From c3cc4fe6d42599c9302d849c6e9955cd5afe4e0f Mon Sep 17 00:00:00 2001 From: Oshani Silva Date: Mon, 16 Oct 2023 05:21:44 +0000 Subject: [PATCH] Add fix for search operation (#251) fixes https://roadmap.entgra.net/issues/10279 Co-authored-by: osh Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/251 Co-authored-by: Oshani Silva Co-committed-by: Oshani Silva --- .../device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java | 4 ++-- .../mgt/core/service/DeviceManagementProviderServiceImpl.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 32bffa5af4..fcb1799568 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -94,7 +94,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "t.NAME AS DEVICE_TYPE "; //Filter by serial number or any Custom Property in DM_DEVICE_INFO - if (serial != null || !request.getCustomProperty().isEmpty()) { + if ((serial != null) || (request.getCustomProperty() != null && !request.getCustomProperty().isEmpty())) { sql = sql + "FROM DM_DEVICE d " + "INNER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID " + @@ -170,7 +170,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { if (isSerialProvided) { stmt.setString(paramIdx++, "%" + serial + "%"); } - if (!request.getCustomProperty().isEmpty()) { + if (request.getCustomProperty() != null && !request.getCustomProperty().isEmpty()) { for (Map.Entry entry : request.getCustomProperty().entrySet()) { stmt.setString(paramIdx++, "%" + entry.getValue() + "%"); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 8413b1499f..344325ae10 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -652,7 +652,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv Map deviceManagerMap = new HashMap<>(); List deviceCacheKeyList = new ArrayList<>(); List existingDevices; - List validDevices = new ArrayList<>();; + List validDevices = new ArrayList<>(); int tenantId = this.getTenantId(); try {