public abstract class HypermediaPagingStrategy extends Object implements PagingStrategy
PagingStrategy for APIs which do paging based on a next URL provided in the response of each request.
Request number 1 will obtain the first page plus the next URL embedded in the response. Said URL will be the request number 2, which will reply with the next page and a new URL which overwrites the prior one. The process continues until no new URL is provided or the next page comes back empty.
| Constructor and Description |
|---|
HypermediaPagingStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected Map<String,String> |
buildLinkHeaderMap(String linkHeader)
Parse Link header into a Map of links by its relation
|
org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder |
configureRequest(String baseUri,
org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder,
RestPagingProvider.PagingContext context)
Depending on the paging strategy, different parameters or headers may need to be passed.
|
protected abstract String |
extractNextUrl(org.mule.runtime.api.metadata.TypedValue<String> rawPage,
org.mule.runtime.api.util.MultiMap<String,String> headers) |
void |
onPage(List<org.mule.runtime.api.metadata.TypedValue<String>> page,
org.mule.runtime.api.metadata.TypedValue<String> rawPage,
org.mule.runtime.api.util.MultiMap<String,String> headers,
RestPagingProvider.PagingContext context)
Invoked each time a page is obtained.
|
public org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder configureRequest(String baseUri, org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder, RestPagingProvider.PagingContext context)
PagingStrategyconfigureRequest in interface PagingStrategybaseUri - the base uri of the REST API being consumed.requestBuilder - a HttpRequestBuilder.context - the pagination context to allow stopping the pagination mechanism.HttpRequestBuilder configured or a new one.public void onPage(List<org.mule.runtime.api.metadata.TypedValue<String>> page, org.mule.runtime.api.metadata.TypedValue<String> rawPage, org.mule.runtime.api.util.MultiMap<String,String> headers, RestPagingProvider.PagingContext context)
PagingStrategyonPage in interface PagingStrategypage - the obtained pagecontext - the pagination context to allow stopping the pagination mechanism.protected abstract String extractNextUrl(org.mule.runtime.api.metadata.TypedValue<String> rawPage, org.mule.runtime.api.util.MultiMap<String,String> headers)
Copyright © 2022. All rights reserved.