diff --git a/modules/charon-core/src/main/java/org/wso2/charon3/core/utils/ResourceManagerUtil.java b/modules/charon-core/src/main/java/org/wso2/charon3/core/utils/ResourceManagerUtil.java index e09c2402d..6ba43b16f 100644 --- a/modules/charon-core/src/main/java/org/wso2/charon3/core/utils/ResourceManagerUtil.java +++ b/modules/charon-core/src/main/java/org/wso2/charon3/core/utils/ResourceManagerUtil.java @@ -404,9 +404,9 @@ public static Map getAllAttributeURIs(SCIMResourceTypeSchema sc */ public static int processCount(String countStr) throws BadRequestException { - int count; + Integer count; if (countStr == null || countStr.trim().isEmpty() || !countStr.matches("\\d+")) { - count = CharonConfiguration.getInstance().getCountValueForPagination(); + count = null; } else { try { count = Integer.parseInt(countStr); @@ -415,11 +415,7 @@ public static int processCount(String countStr) throws BadRequestException { } } - if (count < 0) { - count = 0; - } - - return count; + return processCount(count); } /** @@ -432,7 +428,7 @@ public static int processCount(String countStr) throws BadRequestException { public static Integer processCount(Integer countInt) { if (countInt == null || countInt.toString().isEmpty()) { - return null; + return CharonConfiguration.getInstance().getCountValueForPagination(); } else { // All the negative values are interpreted as zero according to the specification. if (countInt <= 0) { diff --git a/modules/charon-core/src/test/java/org/wso2/charon3/core/utils/ResourceManagerUtilTest.java b/modules/charon-core/src/test/java/org/wso2/charon3/core/utils/ResourceManagerUtilTest.java index f6d688ab2..85e5f6bad 100644 --- a/modules/charon-core/src/test/java/org/wso2/charon3/core/utils/ResourceManagerUtilTest.java +++ b/modules/charon-core/src/test/java/org/wso2/charon3/core/utils/ResourceManagerUtilTest.java @@ -236,7 +236,7 @@ public Object[][] dataToProcessCountInteger() { {20, 20}, {-1, 0}, - {null, null} + {null, 0} }; }