From aed8d6f277c14cfbe204cf5de19163ea370f5616 Mon Sep 17 00:00:00 2001 From: Gimhan-minion Date: Wed, 23 Mar 2022 19:43:53 +0530 Subject: [PATCH] Fix validation of appname when a webclip is created --- .../application/GenericApplicationDAOImpl.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 679f2ed7136..e8764c5f1f1 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -1736,12 +1736,24 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "AP_APP.NAME = ? AND " + "AP_APP.DEVICE_TYPE_ID = ? AND " + "AP_APP.TENANT_ID = ?"; + if(deviceTypeId != -1){ + sql = "SELECT AP_APP.ID AS ID " + + "FROM AP_APP " + + "WHERE " + + "AP_APP.NAME = ? AND " + + "AP_APP.TENANT_ID = ?"; + } try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)){ - stmt.setString(1, appName); - stmt.setInt(2, deviceTypeId); - stmt.setInt(3, tenantId); + if(deviceTypeId != -1){ + stmt.setString(1, appName); + stmt.setInt(2, tenantId); + } else { + stmt.setString(1, appName); + stmt.setInt(2, deviceTypeId); + stmt.setInt(3, tenantId); + } try (ResultSet rs = stmt.executeQuery()){ return rs.next(); }