/** * <p> * A helper method to resume the pages in case of unexpected failures. The method takes the last successful response * page as input and returns an instance of {@link ListObjectsV2Publisher} that can be used to retrieve the * consecutive pages that follows the input page. * </p> */ private final ListObjectsV2Publisher resume(ListObjectsV2Response lastSuccessfulPage) { if (nextPageFetcher.hasNextPage(lastSuccessfulPage)) { return new ListObjectsV2Publisher(client, firstRequest.toBuilder() .continuationToken(lastSuccessfulPage.nextContinuationToken()).build()); } return new ListObjectsV2Publisher(client, firstRequest, true) { @Override public void subscribe(Subscriber<? super ListObjectsV2Response> subscriber) { subscriber.onSubscribe(new EmptySubscription(subscriber)); } }; }
/** * <p> * A helper method to resume the pages in case of unexpected failures. The method takes the last successful response * page as input and returns an instance of {@link ListObjectsV2Iterable} that can be used to retrieve the * consecutive pages that follows the input page. * </p> */ private final ListObjectsV2Iterable resume(ListObjectsV2Response lastSuccessfulPage) { if (nextPageFetcher.hasNextPage(lastSuccessfulPage)) { return new ListObjectsV2Iterable(client, firstRequest.toBuilder() .continuationToken(lastSuccessfulPage.nextContinuationToken()).build()); } return new ListObjectsV2Iterable(client, firstRequest) { @Override public Iterator<ListObjectsV2Response> iterator() { return Collections.emptyIterator(); } }; }
@Override public ListObjectsV2Response nextPage(ListObjectsV2Response previousPage) { if (previousPage == null) { return client.listObjectsV2(firstRequest); } return client.listObjectsV2(firstRequest.toBuilder().continuationToken(previousPage.nextContinuationToken()).build()); } }
@Override public CompletableFuture<ListObjectsV2Response> nextPage(final ListObjectsV2Response previousPage) { if (previousPage == null) { return client.listObjectsV2(firstRequest); } return client.listObjectsV2(firstRequest.toBuilder().continuationToken(previousPage.nextContinuationToken()).build()); } }