Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify handling of unspecified count parameters for listWithGet and listWithPost #376

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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