From 81591157210e8a0245a4101ec0dafc36f4137cc0 Mon Sep 17 00:00:00 2001 From: princeap173 Date: Thu, 14 Dec 2023 09:49:04 +0530 Subject: [PATCH] RANGER-4606: /assets/assets/count API does not return the proper count if the number of services is greater than 200 Signed-off-by: Madhan Neethiraj --- .../org/apache/ranger/rest/AssetREST.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java b/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java index 2e1982c4a8..e5ef779f43 100644 --- a/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java +++ b/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java @@ -277,9 +277,26 @@ public VXLong countXAssets(@Context HttpServletRequest request) { logger.debug("==> AssetREST.countXAssets()"); } + SearchFilter filter = searchUtil.getSearchFilterFromLegacyRequest(request, xResourceService.sortFields); + + filter.setMaxRows(Integer.MAX_VALUE); + + List services = serviceREST.getServices(filter); + int servicesCount = 0; + + if (services != null) { + for (RangerService service : services) { + VXAsset asset = serviceUtil.toVXAsset(service); + + if (asset != null) { + servicesCount++; + } + } + } + VXLong ret = new VXLong(); - ret.setValue(searchXAssets(request).getListSize()); + ret.setValue(servicesCount); if(logger.isDebugEnabled()) { logger.debug("<== AssetREST.countXAssets(): " + ret);