public abstract class RestPagingProvider<C extends RestConnection> extends Object implements org.mule.runtime.extension.api.runtime.streaming.PagingProvider<C,org.mule.runtime.api.metadata.TypedValue<String>>
Different APIs use different paging strategies which are tackled in implementations of this class. This class provides the basics as:
PagingProvider contract
Each item in the obtained page will be returned as an individual TypedValue, with the proper mime type and encoding
set.
Type parameters: RestConnection
| Modifier and Type | Class and Description |
|---|---|
static interface |
RestPagingProvider.PagingContext
Context related to the pagination.
|
| Modifier and Type | Field and Description |
|---|---|
protected org.mule.runtime.api.metadata.MediaType |
defaultMediaType |
| Constructor and Description |
|---|
RestPagingProvider(Function<C,org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder> requestFactory,
org.mule.runtime.api.metadata.MediaType defaultMediaType,
PagingStrategy pagingStrategy)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(RestConnection connection) |
protected abstract List<org.mule.runtime.api.metadata.TypedValue<String>> |
extractPageItems(org.mule.runtime.api.metadata.TypedValue<String> content,
org.mule.runtime.api.metadata.MediaType defaultMediaType)
Given the raw content response body this method will extract the payload data as a list of items which represent a page.
|
List<org.mule.runtime.api.metadata.TypedValue<String>> |
getPage(C connection) |
Optional<Integer> |
getTotalResults(RestConnection connection) |
protected org.mule.runtime.api.metadata.TypedValue<String> |
postProcess(org.mule.runtime.api.metadata.TypedValue<String> rawPage,
org.mule.runtime.api.metadata.MediaType defaultMediaType)
Allows post process the server response before the payload is extracted.
|
protected org.mule.runtime.http.api.domain.message.response.HttpResponse |
send(C connection,
org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder)
Does the HTTP call with the given connection for the requestBuilder.
|
protected final org.mule.runtime.api.metadata.MediaType defaultMediaType
public RestPagingProvider(Function<C,org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder> requestFactory, org.mule.runtime.api.metadata.MediaType defaultMediaType, PagingStrategy pagingStrategy)
requestFactory - a Function to generate the request to be used on each page request. Each invocation should
yield a different instance.defaultMediaType - the MediaType for the page items if the server doesn't specify one.pagingStrategy - the pagination strategy.public final List<org.mule.runtime.api.metadata.TypedValue<String>> getPage(C connection)
getPage in interface org.mule.sdk.api.runtime.streaming.PagingProvider<C extends RestConnection,org.mule.runtime.api.metadata.TypedValue<String>>protected org.mule.runtime.http.api.domain.message.response.HttpResponse send(C connection, org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder)
connection - raw content page as TypedValuerequestBuilder - the HttpRequestBuilder to be executed.HttpResponse which represents the server response.protected abstract List<org.mule.runtime.api.metadata.TypedValue<String>> extractPageItems(org.mule.runtime.api.metadata.TypedValue<String> content, org.mule.runtime.api.metadata.MediaType defaultMediaType)
content - raw content page as TypedValuedefaultMediaType - the MediaType for the page items if the server doesn't specify one.List> which represents a page with items.protected org.mule.runtime.api.metadata.TypedValue<String> postProcess(org.mule.runtime.api.metadata.TypedValue<String> rawPage, org.mule.runtime.api.metadata.MediaType defaultMediaType)
rawPage - the server response as it.defaultMediaType - the MediaType for the page items if the server doesn't specify one.public Optional<Integer> getTotalResults(RestConnection connection)
getTotalResults in interface org.mule.sdk.api.runtime.streaming.PagingProvider<C extends RestConnection,org.mule.runtime.api.metadata.TypedValue<String>>public final void close(RestConnection connection) throws org.mule.runtime.api.exception.MuleException
close in interface org.mule.sdk.api.runtime.streaming.PagingProvider<C extends RestConnection,org.mule.runtime.api.metadata.TypedValue<String>>org.mule.runtime.api.exception.MuleExceptionCopyright © 2022. All rights reserved.