Class PaginationServiceImpl
- java.lang.Object
-
- com.atlassian.confluence.api.impl.pagination.PaginationServiceImpl
-
- All Implemented Interfaces:
PaginationServiceInternal
,PaginationService
public class PaginationServiceImpl extends Object implements PaginationServiceInternal
-
-
Constructor Summary
Constructors Constructor Description PaginationServiceImpl(org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <F,T>
Paginated<T>newPaginated(PaginationBatch<F> fetchBatch, Function<Iterable<F>,Iterable<T>> modelConverter, int maxLimit)
Constructs a Paginated implementation backed by the given PaginationBatch.<F,T>
PagingIterator<T>newPagingIterator(PaginationBatch<F> fetchBatch, int resultsPerPage, Function<Iterable<F>,Iterable<T>> modelConverter)
Constructs a PagingIterator backed by the given PaginationBatch.<H,M>
PageResponse<M>performPaginationListRequest(LimitedRequest initialRequest, PaginationBatch<H> fetchPage, Function<Iterable<H>,Iterable<M>> modelConverter)
Perform a pagination request, this will execute the fetchBatch function as many times as necessary to retrieve the page of results.<H,M>
PageResponse<M>performPaginationListRequestWithCursor(LimitedRequest initialRequest, Function<LimitedRequest,PageResponse<H>> fetchBatch, Function<Iterable<H>,Iterable<M>> modelConverter, BiFunction<H,Boolean,Cursor> cursorCalculator)
Perform a pagination request, this will execute the fetchBatch function as many times as to retrieve the page of results.<H,M>
PageResponse<M>performPaginationRequest(LimitedRequest initialRequest, PaginationBatch<H> fetchPage, Function<? super H,M> modelConverter)
Perform a pagination request, this will execute the fetchBatch function as many times as necessary to retrieve the page of results.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.confluence.api.service.pagination.PaginationService
doPaginationListRequest, doPaginationRequest
-
Methods inherited from interface com.atlassian.confluence.api.impl.pagination.PaginationServiceInternal
createPaginated, createPagingIterator
-
-
-
-
Method Detail
-
performPaginationRequest
public <H,M> PageResponse<M> performPaginationRequest(LimitedRequest initialRequest, PaginationBatch<H> fetchPage, Function<? super H,M> modelConverter)
Description copied from interface:PaginationService
Perform a pagination request, this will execute the fetchBatch function as many times as necessary to retrieve the page of results. Each execution of the fetch page function will pull at mostLimitedRequest.getMaxLimit()
results from the datasource. FetchBatch will be executed in a new transaction for each batch to prevent excessive memory usage. It is expected that any permission checking is performed in the PaginationBatch.The PaginationService is responsible for ensuring that enough results are returned from the PaginationBatch to fulfill the request. The PaginationBatch should not treat the pageRequest getStart and getLimit values as user specific indexes, only results the user can see should be returned. If a user does not have permission to see any results in the requested range an empty list should be returned in the response and the hasMore flag set if there are more results still to check. The pagination service will call again if more results are required.
- Specified by:
performPaginationRequest
in interfacePaginationService
- Parameters:
initialRequest
- - a request for a range of datafetchPage
- - the function to supply the resultsmodelConverter
- - a function to convert from the supplied object to a model object, this will be executed within a transaction.- Returns:
- a PageResponse of model objects, with results that the user is allowed to see.
-
performPaginationListRequest
public <H,M> PageResponse<M> performPaginationListRequest(LimitedRequest initialRequest, PaginationBatch<H> fetchPage, Function<Iterable<H>,Iterable<M>> modelConverter)
Description copied from interface:PaginationService
Perform a pagination request, this will execute the fetchBatch function as many times as necessary to retrieve the page of results. Each execution of the fetch page function will pull at mostLimitedRequest.getMaxLimit()
results from the datasource. FetchBatch will be executed in a new transaction for each batch to prevent excessive memory usage. It is expected that any permission checking is performed in the PaginationBatch.The PaginationService is responsible for ensuring that enough results are returned from the PaginationBatch to fulfill the request. The PaginationBatch should not treat the pageRequest getStart and getLimit values as user specific indexes, only results the user can see should be returned. If a user does not have permission to see any results in the requested range an empty list should be returned in the response and the hasMore flag set if there are more results still to check. The pagination service will call again if more results are required.
- Specified by:
performPaginationListRequest
in interfacePaginationService
- Parameters:
initialRequest
- - a request for a range of datafetchPage
- - the function to supply the resultsmodelConverter
- - a function to convert from the supplied object to a model object, this will be executed within a transaction.- Returns:
- a PageResponse of model objects, with results that the user is allowed to see.
-
performPaginationListRequestWithCursor
public <H,M> PageResponse<M> performPaginationListRequestWithCursor(LimitedRequest initialRequest, Function<LimitedRequest,PageResponse<H>> fetchBatch, Function<Iterable<H>,Iterable<M>> modelConverter, BiFunction<H,Boolean,Cursor> cursorCalculator)
Description copied from interface:PaginationService
Perform a pagination request, this will execute the fetchBatch function as many times as to retrieve the page of results. Each execution of the fetch page function will pull at mostLimitedRequest.getMaxLimit()
results from the datasource. FetchBatch will be executed in a new transaction for each batch to prevent excessive memory usage. It is expected that any permission checking is performed in the PaginationBatch.The PaginationService is responsible for ensuring that enough results are returned from the fetchBatch to fulfill the request. Only results the user can see should be returned.
- Specified by:
performPaginationListRequestWithCursor
in interfacePaginationService
- Parameters:
initialRequest
- - a request for a range of datafetchBatch
- - the function to supply the results. Results should be sorted in order which match cursor fields ordering.modelConverter
- - a function to convert from the supplied object to a model object, this will be executed within a transaction.cursorCalculator
- - a function to calculate next cursor.- Returns:
- a PageResponseWithCursor of model objects, with results that the user is allowed to see.
-
newPagingIterator
public <F,T> PagingIterator<T> newPagingIterator(PaginationBatch<F> fetchBatch, int resultsPerPage, Function<Iterable<F>,Iterable<T>> modelConverter)
Description copied from interface:PaginationServiceInternal
Constructs a PagingIterator backed by the given PaginationBatch. The Iterator is guaranteed to yield all results provided by the PaginationBatch. No more than resultsPerPage are fetched from the PaginationBatch at one time, and each batch of data is only kept live for the time it takes callers to iterate through it.- Specified by:
newPagingIterator
in interfacePaginationServiceInternal
- Parameters:
fetchBatch
- - a request for a range of dataresultsPerPage
- - number of results to request from PaginationBatch each invocation.modelConverter
- - a function to convert from the supplied object to a model object, this will be executed within a transaction.- Returns:
- a PagingIterator of model objects, with results that the user is allowed to see.
- See Also:
PagingIterator
-
newPaginated
public <F,T> Paginated<T> newPaginated(PaginationBatch<F> fetchBatch, Function<Iterable<F>,Iterable<T>> modelConverter, int maxLimit)
Description copied from interface:PaginationServiceInternal
Constructs a Paginated implementation backed by the given PaginationBatch.- Specified by:
newPaginated
in interfacePaginationServiceInternal
- Parameters:
fetchBatch
- - a request for a range of datamodelConverter
- - a function to convert from the supplied object to a model object, this will be executed within a transaction.maxLimit
- - the max limit to apply when creating LimitedRequests for paged requests from the Paginated.- See Also:
Paginated
-
-