Skip to content

Commit

Permalink
Unify handling of unspecified count parameters for listWithGet and li…
Browse files Browse the repository at this point in the history
…stWithPost

In the SCIM 2.0 spec, it says that "the maximum number of results is set by the service provider" if the count parameter is left unspecified by the user. In case of the listWithPost methods, this defaulting is already done by Charon via CharonConfiguration.getInstance().getCountValueForPagination(). However, in case of listWithGet (using Integer parameters) Charon simply passes on a null value to the implementation of e.g. UserManager, where the developer has to do the defaulting in order to comply with the SCIM 2.0 spec. In order to increase consistency in Charon's handling of the count parameter, and in order to lower the implementation effort for the developer, Charon is now doing the defaulting for listWithPut as well as for listWithGet (in case of Integer parameters).
  • Loading branch information
klaasdellschaft committed Jan 11, 2023
1 parent b0a70fd commit c68fd4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ public static Map<String, Boolean> 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);
Expand All @@ -415,11 +415,7 @@ public static int processCount(String countStr) throws BadRequestException {
}
}

if (count < 0) {
count = 0;
}

return count;
return processCount(count);
}

/**
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public Object[][] dataToProcessCountInteger() {

{20, 20},
{-1, 0},
{null, null}
{null, 0}
};
}

Expand Down

0 comments on commit c68fd4d

Please sign in to comment.