I'm accessing a REST WS (not Jersey) by using a Jersey Client. This service handles pagination in the header via the Link header
Using this call I get the full list of data for a single page.
resultList = new ArrayList<T>();
.....
// make call to get records
// start loop... (do-while actually)
tempResultList = (List<T>) response.readEntity(new GenericType<List<MyDataObject>>(){});
if (resultList == null) {
resultList = tempResultList;
}
else {
resultList.addAll(tempResultList);
}
// check for next pagination. If so, change the call to that "next" link and go to the top of the loop and make the call
// end loop
Let's say I have 200 results coming back. Well, paging for this web service only gives me 10 records at a time (I can set this to higher but let's go w/ this example for discussion).
I wrote some code that after each page call it checks the headers and makes a call to the "next" Link from the results' header and adds the next page's records to that list. And so forth until no more page result headers have a "next" Link header.
This work fine. But I hate custom code if there isn't a need for it. Is there any Jersey 2 client way to do this as something just naturally part of Jersey w/o using my own code to do the pagination?
Thanks!
- Damian