Skip to content

Commit

Permalink
Fix: Fallback Values for Pagination (#194)
Browse files Browse the repository at this point in the history
* Add Fallback Values for Pagination

* Renove obsolete testcase

* More robust
  • Loading branch information
f11h authored Jul 21, 2022
1 parent ee51852 commit 617e48e
Show file tree
Hide file tree
Showing 2 changed files with 427 additions and 377 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,11 @@ public ResponseEntity<List<TrustListDto>> downloadTrustList(
) {
List<TrustListDto> trustList;
if (isPaginationRequired(page,size)) {
page = (page != null && page >= 0) ? page : 0;
size = (size != null && size >= 0) ? size : 100;

trustList = trustListMapper.trustListToTrustListDto(
trustListService.getTrustList(ifModifiedSince, page, size));
trustListService.getTrustList(ifModifiedSince, page, size));
} else {
trustList = trustListMapper.trustListToTrustListDto(
trustListService.getTrustList(ifModifiedSince, null, null));
Expand Down Expand Up @@ -240,8 +243,11 @@ public ResponseEntity<List<TrustListDto>> downloadTrustListFilteredByType(
TrustListType mappedType = trustListMapper.certificateTypeDtoToTrustListType(type);
List<TrustListDto> trustList;
if (isPaginationRequired(page,size)) {
page = (page != null && page >= 0) ? page : 0;
size = (size != null && size >= 0) ? size : 100;

trustList = trustListMapper.trustListToTrustListDto(
trustListService.getTrustList(mappedType, ifModifiedSince, page, size));
trustListService.getTrustList(mappedType, ifModifiedSince, page, size));
} else {
trustList = trustListMapper.trustListToTrustListDto(
trustListService.getTrustList(mappedType, ifModifiedSince, null, null));
Expand Down Expand Up @@ -342,8 +348,11 @@ public ResponseEntity<List<TrustListDto>> downloadTrustListFilteredByCountryAndT

List<TrustListDto> trustList;
if (isPaginationRequired(page,size)) {
page = (page != null && page >= 0) ? page : 0;
size = (size != null && size >= 0) ? size : 100;

trustList = trustListMapper.trustListToTrustListDto(
trustListService.getTrustList(mappedType, countryCode, ifModifiedSince, page, size));
trustListService.getTrustList(mappedType, countryCode, ifModifiedSince, page, size));
} else {
trustList = trustListMapper.trustListToTrustListDto(
trustListService.getTrustList(mappedType, countryCode, ifModifiedSince, null, null));
Expand Down Expand Up @@ -409,6 +418,6 @@ public ResponseEntity<List<TrustedIssuerDto>> getTrustedIssuersByCountry(
}

private boolean isPaginationRequired(Integer page, Integer size) {
return page != null && size != null && page >= 0 && size > 0;
return (page != null && page >= 0) || (size != null && size >= 0);
}
}
Loading

0 comments on commit 617e48e

Please sign in to comment.