From 6c317f3e4a76fbe56683323bf7913ed3dad7264f Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Tue, 22 Oct 2024 17:30:39 +0530 Subject: [PATCH 1/5] Filter by domains in get tenants API --- .../user/core/tenant/JDBCTenantManager.java | 62 ++++++++++++------- .../user/core/tenant/TenantConstants.java | 2 + 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java index 0c0379e884f..0fcf6f2b7f8 100644 --- a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java +++ b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java @@ -564,7 +564,7 @@ public TenantSearchResult listTenants(Integer limit, Integer offset, String sort TenantSearchResult tenantSearchResult = new TenantSearchResult(); String sortedOrder = sortBy + " " + sortOrder; try (Connection dbConnection = getDBConnection(); - ResultSet resultSet = getTenantQueryResultSet(dbConnection, sortedOrder, offset, limit)) { + ResultSet resultSet = getTenantQueryResultSet(dbConnection, sortedOrder, offset, limit, filter)) { List tenantList = populateTenantList(resultSet); tenantSearchResult.setTenantList(tenantList); tenantSearchResult.setTotalTenantCount(getCountOfTenants()); @@ -1292,7 +1292,7 @@ private int getCountOfTenants() throws UserStoreException { } private ResultSet getTenantQueryResultSet(Connection dbConnection, String sortedOrder, Integer offset, - Integer limit) throws SQLException, UserStoreException { + Integer limit, String filter) throws SQLException, UserStoreException { String dbType; try { @@ -1305,48 +1305,62 @@ private ResultSet getTenantQueryResultSet(Connection dbConnection, String sorted throw new UserStoreException(msg, e); } PreparedStatement prepStmt; - String sqlQuery; + String sqlQuery = TenantConstants.LIST_TENANTS_PAGINATED_SQL; String sqlTail; - sqlQuery = TenantConstants.LIST_TENANTS_PAGINATED_SQL; + int offsetParameter; + int limitParameter; + + String domainNameParameter = StringUtils.EMPTY; + String sqlFilter = StringUtils.EMPTY; + if (StringUtils.isNotBlank(filter)) { + if (filter.contains("*")) { + // Convert SCIM wildcards to SQL wildcards. + domainNameParameter = filter.trim().replace("*", "%"); + sqlFilter = TenantConstants.LIST_TENANTS_DOMAIN_FILTER_LIKE; + } else { + domainNameParameter = filter.trim(); + sqlFilter = TenantConstants.LIST_TENANTS_DOMAIN_FILTER_EQUAL; + } + } if (MYSQL.equalsIgnoreCase(dbType) || MARIADB.equalsIgnoreCase(dbType) || H2.equalsIgnoreCase(dbType)) { sqlTail = String.format(TenantConstants.LIST_TENANTS_MYSQL_TAIL, sortedOrder); - sqlQuery = sqlQuery + sqlTail; - prepStmt = dbConnection.prepareStatement(sqlQuery); - prepStmt.setInt(1, offset); - prepStmt.setInt(2, limit); + offsetParameter = offset; + limitParameter = limit; } else if (ORACLE.equalsIgnoreCase(dbType)) { sqlQuery = TenantConstants.LIST_TENANTS_PAGINATED_ORACLE; sqlTail = String.format(TenantConstants.LIST_TENANTS_ORACLE_TAIL, sortedOrder); - sqlQuery = sqlQuery + sqlTail; - prepStmt = dbConnection.prepareStatement(sqlQuery); - prepStmt.setInt(1, offset + limit); - prepStmt.setInt(2, offset); + offsetParameter = offset + limit; + limitParameter = offset; } else if (MSSQL.equalsIgnoreCase(dbType)) { sqlTail = String.format(TenantConstants.LIST_TENANTS_MSSQL_TAIL, sortedOrder); - sqlQuery = sqlQuery + sqlTail; - prepStmt = dbConnection.prepareStatement(sqlQuery); - prepStmt.setInt(1, offset); - prepStmt.setInt(2, limit); + offsetParameter = offset; + limitParameter = limit; } else if (DB2.equalsIgnoreCase(dbType)) { sqlQuery = TenantConstants.LIST_TENANTS_PAGINATED_DB2; sqlTail = String.format(TenantConstants.LIST_TENANTS_DB2_TAIL, sortedOrder); - sqlQuery = sqlQuery + sqlTail; - prepStmt = dbConnection.prepareStatement(sqlQuery); - prepStmt.setInt(1, offset + 1); - prepStmt.setInt(2, offset + limit); + offsetParameter = offset + 1; + limitParameter = offset + limit; } else if (POSTGRESQL.equalsIgnoreCase(dbType)) { sqlTail = String.format(TenantConstants.LIST_TENANTS_POSTGRESQL_TAIL, sortedOrder); - sqlQuery = sqlQuery + sqlTail; - prepStmt = dbConnection.prepareStatement(sqlQuery); - prepStmt.setInt(1, limit); - prepStmt.setInt(2, offset); + offsetParameter = limit; + limitParameter = offset; } else { String message = "Error while loading tenant from DB: Database driver could not be identified" + " or not supported."; log.error(message); throw new UserStoreException(message); } + sqlQuery = sqlQuery + sqlFilter + sqlTail; + prepStmt = dbConnection.prepareStatement(sqlQuery); + if (StringUtils.isBlank(sqlFilter)) { + prepStmt.setInt(1, offsetParameter); + prepStmt.setInt(2, limitParameter); + } else { + prepStmt.setString(1, domainNameParameter); + prepStmt.setInt(2, offsetParameter); + prepStmt.setInt(3, limitParameter); + } return prepStmt.executeQuery(); } diff --git a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java index acb49d5ab99..440a10e80ee 100644 --- a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java +++ b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java @@ -74,6 +74,8 @@ public class TenantConstants { "UM_ORG_UUID IN (SELECT UM_ID FROM UM_ORG WHERE UM_PARENT_ID IS NULL) ) WHERE rn BETWEEN ? AND ?"; public static final String LIST_TENANTS_MSSQL_TAIL = "ORDER BY %s OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; public static final String LIST_TENANTS_ORACLE_TAIL = "ORDER BY %s) WHERE rownum <= ?) WHERE rnum > ?"; + public static final String LIST_TENANTS_DOMAIN_FILTER_LIKE = "AND UM_DOMAIN_NAME LIKE ? "; + public static final String LIST_TENANTS_DOMAIN_FILTER_EQUAL = "AND UM_DOMAIN_NAME=? "; public static final String GET_DOMAIN_SQL = "SELECT UM_DOMAIN_NAME FROM UM_TENANT WHERE UM_ID=?"; public static final String GET_TENANT_ID_SQL = "SELECT UM_ID FROM UM_TENANT WHERE UM_DOMAIN_NAME=?"; public static final String ACTIVATE_SQL = "UPDATE UM_TENANT SET UM_ACTIVE='1' WHERE UM_ID=?"; From a600793b44053d151232dc885db5719bf8ce8dcc Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:36:09 +0530 Subject: [PATCH 2/5] Extract domain from filter in kernel level --- .../user/core/tenant/JDBCTenantManager.java | 68 +++++++++++++++---- .../user/core/tenant/TenantConstants.java | 4 +- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java index 0fcf6f2b7f8..20ebe5f1363 100644 --- a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java +++ b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java @@ -38,6 +38,7 @@ import org.wso2.carbon.user.core.hybrid.HybridJDBCConstants; import org.wso2.carbon.user.core.internal.UserStoreMgtDSComponent; import org.wso2.carbon.user.core.jdbc.JDBCRealmConstants; +import org.wso2.carbon.user.core.model.ExpressionOperation; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.util.DatabaseUtil; import org.wso2.carbon.utils.CarbonUtils; @@ -563,11 +564,12 @@ public TenantSearchResult listTenants(Integer limit, Integer offset, String sort TenantSearchResult tenantSearchResult = new TenantSearchResult(); String sortedOrder = sortBy + " " + sortOrder; + String domainName = buildDomainNameFilter(filter); try (Connection dbConnection = getDBConnection(); - ResultSet resultSet = getTenantQueryResultSet(dbConnection, sortedOrder, offset, limit, filter)) { + ResultSet resultSet = getTenantQueryResultSet(dbConnection, sortedOrder, offset, limit, domainName)) { List tenantList = populateTenantList(resultSet); tenantSearchResult.setTenantList(tenantList); - tenantSearchResult.setTotalTenantCount(getCountOfTenants()); + tenantSearchResult.setTotalTenantCount(getCountOfTenants(domainName)); tenantSearchResult.setLimit(limit); tenantSearchResult.setOffSet(offset); tenantSearchResult.setSortBy(sortBy); @@ -1274,12 +1276,23 @@ private StringBuilder printCurrentStackTrace() { * @return number of tenant count. * @throws UserStoreException Error when getting count of tenants. */ - private int getCountOfTenants() throws UserStoreException { + private int getCountOfTenants(String domainName) throws UserStoreException { - String sqlStmt = TenantConstants.LIST_TENANTS_COUNT_SQL; + String sqlFilter = StringUtils.EMPTY; + if (StringUtils.isNotBlank(domainName)) { + if (domainName.contains("%")) { + sqlFilter = String.format(TenantConstants.LIST_TENANTS_DOMAIN_FILTER_LIKE, " WHERE"); + } else { + sqlFilter = String.format(TenantConstants.LIST_TENANTS_DOMAIN_FILTER_EQUAL, " WHERE"); + } + } + String sqlStmt = TenantConstants.LIST_TENANTS_COUNT_SQL + sqlFilter; int tenantCount = 0; try (Connection dbConnection = getDBConnection(); PreparedStatement prepStmt = dbConnection.prepareStatement(sqlStmt)) { + if (StringUtils.isNotBlank(sqlFilter)) { + prepStmt.setString(1, domainName); + } try (ResultSet rs = prepStmt.executeQuery()) { if (rs.next()) { tenantCount = Integer.parseInt(rs.getString(1)); @@ -1292,7 +1305,7 @@ private int getCountOfTenants() throws UserStoreException { } private ResultSet getTenantQueryResultSet(Connection dbConnection, String sortedOrder, Integer offset, - Integer limit, String filter) throws SQLException, UserStoreException { + Integer limit, String domainName) throws SQLException, UserStoreException { String dbType; try { @@ -1310,16 +1323,12 @@ private ResultSet getTenantQueryResultSet(Connection dbConnection, String sorted int offsetParameter; int limitParameter; - String domainNameParameter = StringUtils.EMPTY; String sqlFilter = StringUtils.EMPTY; - if (StringUtils.isNotBlank(filter)) { - if (filter.contains("*")) { - // Convert SCIM wildcards to SQL wildcards. - domainNameParameter = filter.trim().replace("*", "%"); - sqlFilter = TenantConstants.LIST_TENANTS_DOMAIN_FILTER_LIKE; + if (StringUtils.isNotBlank(domainName)) { + if (domainName.contains("%")) { + sqlFilter = String.format(TenantConstants.LIST_TENANTS_DOMAIN_FILTER_LIKE, "AND"); } else { - domainNameParameter = filter.trim(); - sqlFilter = TenantConstants.LIST_TENANTS_DOMAIN_FILTER_EQUAL; + sqlFilter = String.format(TenantConstants.LIST_TENANTS_DOMAIN_FILTER_EQUAL, "AND"); } } @@ -1357,13 +1366,44 @@ private ResultSet getTenantQueryResultSet(Connection dbConnection, String sorted prepStmt.setInt(1, offsetParameter); prepStmt.setInt(2, limitParameter); } else { - prepStmt.setString(1, domainNameParameter); + prepStmt.setString(1, domainName); prepStmt.setInt(2, offsetParameter); prepStmt.setInt(3, limitParameter); } return prepStmt.executeQuery(); } + private String buildDomainNameFilter(String filter) { + + if (StringUtils.isNotBlank(filter)) { + String[] filterArgs = filter.split(" "); + if (filterArgs.length == 3) { + String filterAttribute = filterArgs[0]; + String operation = filterArgs[1]; + String attributeValue = filterArgs[2]; + if (StringUtils.equalsIgnoreCase(filterAttribute, "DOMAIN")) { + return generateFilterString(operation, attributeValue); + } + } + } + return StringUtils.EMPTY; + } + + private String generateFilterString(String operation, String attributeValue) { + + String formattedFilter = null; + if (StringUtils.equalsIgnoreCase(operation, ExpressionOperation.SW.toString())) { + formattedFilter = attributeValue + "%"; + } else if (StringUtils.equalsIgnoreCase(operation, ExpressionOperation.EW.toString())) { + formattedFilter = "%" + attributeValue; + } else if (StringUtils.equalsIgnoreCase(operation, ExpressionOperation.CO.toString())) { + formattedFilter = "%" + attributeValue + "%"; + } else if (StringUtils.equalsIgnoreCase(operation, ExpressionOperation.EQ.toString())) { + formattedFilter = attributeValue; + } + return formattedFilter; + } + private List populateTenantList(ResultSet resultSet) throws SQLException, UserStoreException { diff --git a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java index 440a10e80ee..f2b2ebf9b07 100644 --- a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java +++ b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java @@ -74,8 +74,8 @@ public class TenantConstants { "UM_ORG_UUID IN (SELECT UM_ID FROM UM_ORG WHERE UM_PARENT_ID IS NULL) ) WHERE rn BETWEEN ? AND ?"; public static final String LIST_TENANTS_MSSQL_TAIL = "ORDER BY %s OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; public static final String LIST_TENANTS_ORACLE_TAIL = "ORDER BY %s) WHERE rownum <= ?) WHERE rnum > ?"; - public static final String LIST_TENANTS_DOMAIN_FILTER_LIKE = "AND UM_DOMAIN_NAME LIKE ? "; - public static final String LIST_TENANTS_DOMAIN_FILTER_EQUAL = "AND UM_DOMAIN_NAME=? "; + public static final String LIST_TENANTS_DOMAIN_FILTER_LIKE = "%s UM_DOMAIN_NAME LIKE ? "; + public static final String LIST_TENANTS_DOMAIN_FILTER_EQUAL = "%s UM_DOMAIN_NAME=? "; public static final String GET_DOMAIN_SQL = "SELECT UM_DOMAIN_NAME FROM UM_TENANT WHERE UM_ID=?"; public static final String GET_TENANT_ID_SQL = "SELECT UM_ID FROM UM_TENANT WHERE UM_DOMAIN_NAME=?"; public static final String ACTIVATE_SQL = "UPDATE UM_TENANT SET UM_ACTIVE='1' WHERE UM_ID=?"; From 6ad453a7a08557a07e7ed2fab318852ad8117e0f Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:49:07 +0530 Subject: [PATCH 3/5] Rename filter attribute --- .../org/wso2/carbon/user/core/tenant/JDBCTenantManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java index 20ebe5f1363..fc8177a091a 100644 --- a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java +++ b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java @@ -1381,7 +1381,7 @@ private String buildDomainNameFilter(String filter) { String filterAttribute = filterArgs[0]; String operation = filterArgs[1]; String attributeValue = filterArgs[2]; - if (StringUtils.equalsIgnoreCase(filterAttribute, "DOMAIN")) { + if (StringUtils.equalsIgnoreCase(filterAttribute, "domainName")) { return generateFilterString(operation, attributeValue); } } From f53f3ed23d91cdf14cf540aeda6772ec51b9f5cf Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:05:05 +0530 Subject: [PATCH 4/5] Fix review comments --- .../user/core/tenant/JDBCTenantManager.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java index fc8177a091a..45dc4aba42b 100644 --- a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java +++ b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java @@ -88,6 +88,12 @@ public class JDBCTenantManager implements TenantManager { private static final String MARIADB = "mariadb"; private static final String POSTGRESQL = "postgresql"; private static final String H2 = "h2"; + private static final String SPACE_SEPARATOR = " "; + private static final String DOMAIN_NAME = "domainName"; + private static final String SQL_FILTER_STRING_ANY = "%"; + private static final String SQL_WHERE_CLAUSE = "WHERE"; + private static final String SQL_AND_CLAUSE = "AND"; + /** * Map which maps tenant domains to tenant IDs *

@@ -563,7 +569,7 @@ public TenantSearchResult listTenants(Integer limit, Integer offset, String sort throws UserStoreException { TenantSearchResult tenantSearchResult = new TenantSearchResult(); - String sortedOrder = sortBy + " " + sortOrder; + String sortedOrder = sortBy + SPACE_SEPARATOR + sortOrder; String domainName = buildDomainNameFilter(filter); try (Connection dbConnection = getDBConnection(); ResultSet resultSet = getTenantQueryResultSet(dbConnection, sortedOrder, offset, limit, domainName)) { @@ -1280,11 +1286,11 @@ private int getCountOfTenants(String domainName) throws UserStoreException { String sqlFilter = StringUtils.EMPTY; if (StringUtils.isNotBlank(domainName)) { - if (domainName.contains("%")) { - sqlFilter = String.format(TenantConstants.LIST_TENANTS_DOMAIN_FILTER_LIKE, " WHERE"); - } else { - sqlFilter = String.format(TenantConstants.LIST_TENANTS_DOMAIN_FILTER_EQUAL, " WHERE"); - } + sqlFilter = SPACE_SEPARATOR + String.format( + domainName.contains(SQL_FILTER_STRING_ANY) + ? TenantConstants.LIST_TENANTS_DOMAIN_FILTER_LIKE + : TenantConstants.LIST_TENANTS_DOMAIN_FILTER_EQUAL, + SQL_WHERE_CLAUSE); } String sqlStmt = TenantConstants.LIST_TENANTS_COUNT_SQL + sqlFilter; int tenantCount = 0; @@ -1325,11 +1331,11 @@ private ResultSet getTenantQueryResultSet(Connection dbConnection, String sorted String sqlFilter = StringUtils.EMPTY; if (StringUtils.isNotBlank(domainName)) { - if (domainName.contains("%")) { - sqlFilter = String.format(TenantConstants.LIST_TENANTS_DOMAIN_FILTER_LIKE, "AND"); - } else { - sqlFilter = String.format(TenantConstants.LIST_TENANTS_DOMAIN_FILTER_EQUAL, "AND"); - } + sqlFilter = String.format( + domainName.contains(SQL_FILTER_STRING_ANY) + ? TenantConstants.LIST_TENANTS_DOMAIN_FILTER_LIKE + : TenantConstants.LIST_TENANTS_DOMAIN_FILTER_EQUAL, + SQL_AND_CLAUSE); } if (MYSQL.equalsIgnoreCase(dbType) || MARIADB.equalsIgnoreCase(dbType) || H2.equalsIgnoreCase(dbType)) { @@ -1376,12 +1382,12 @@ private ResultSet getTenantQueryResultSet(Connection dbConnection, String sorted private String buildDomainNameFilter(String filter) { if (StringUtils.isNotBlank(filter)) { - String[] filterArgs = filter.split(" "); + String[] filterArgs = filter.split(SPACE_SEPARATOR); if (filterArgs.length == 3) { String filterAttribute = filterArgs[0]; String operation = filterArgs[1]; String attributeValue = filterArgs[2]; - if (StringUtils.equalsIgnoreCase(filterAttribute, "domainName")) { + if (StringUtils.equalsIgnoreCase(filterAttribute, DOMAIN_NAME)) { return generateFilterString(operation, attributeValue); } } @@ -1393,11 +1399,11 @@ private String generateFilterString(String operation, String attributeValue) { String formattedFilter = null; if (StringUtils.equalsIgnoreCase(operation, ExpressionOperation.SW.toString())) { - formattedFilter = attributeValue + "%"; + formattedFilter = attributeValue + SQL_FILTER_STRING_ANY; } else if (StringUtils.equalsIgnoreCase(operation, ExpressionOperation.EW.toString())) { - formattedFilter = "%" + attributeValue; + formattedFilter = SQL_FILTER_STRING_ANY + attributeValue; } else if (StringUtils.equalsIgnoreCase(operation, ExpressionOperation.CO.toString())) { - formattedFilter = "%" + attributeValue + "%"; + formattedFilter = SQL_FILTER_STRING_ANY + attributeValue + SQL_FILTER_STRING_ANY; } else if (StringUtils.equalsIgnoreCase(operation, ExpressionOperation.EQ.toString())) { formattedFilter = attributeValue; } From d57b68c3efc92224495231534bac7a5ab66ebb2d Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:29:11 +0530 Subject: [PATCH 5/5] Rename getCountOfTenants methods --- .../org/wso2/carbon/user/core/tenant/JDBCTenantManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java index 45dc4aba42b..fa99c1ab1a9 100644 --- a/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java +++ b/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/JDBCTenantManager.java @@ -575,7 +575,7 @@ public TenantSearchResult listTenants(Integer limit, Integer offset, String sort ResultSet resultSet = getTenantQueryResultSet(dbConnection, sortedOrder, offset, limit, domainName)) { List tenantList = populateTenantList(resultSet); tenantSearchResult.setTenantList(tenantList); - tenantSearchResult.setTotalTenantCount(getCountOfTenants(domainName)); + tenantSearchResult.setTotalTenantCount(getTenantResultCount(domainName)); tenantSearchResult.setLimit(limit); tenantSearchResult.setOffSet(offset); tenantSearchResult.setSortBy(sortBy); @@ -1282,7 +1282,7 @@ private StringBuilder printCurrentStackTrace() { * @return number of tenant count. * @throws UserStoreException Error when getting count of tenants. */ - private int getCountOfTenants(String domainName) throws UserStoreException { + private int getTenantResultCount(String domainName) throws UserStoreException { String sqlFilter = StringUtils.EMPTY; if (StringUtils.isNotBlank(domainName)) {