use of org.openlmis.stockmanagement.util.PageImplRepresentation in project openlmis-stockmanagement by OpenLMIS.
the class BaseCommunicationService method doPageRequest.
private <E> ResponseEntity<PageImplRepresentation<E>> doPageRequest(String url, RequestParameters parameters, Object payload, HttpMethod method, Class<E> type) {
HttpEntity<Object> entity = createEntity(payload);
ParameterizedTypeReference<PageImplRepresentation<E>> parameterizedType = new DynamicPageTypeReference<>(type);
List<PageImplRepresentation<E>> pages = new ArrayList<>();
for (URI uri : RequestHelper.splitRequest(url, parameters, maxUrlLength)) {
pages.add(restTemplate.exchange(uri, method, entity, parameterizedType).getBody());
}
PageImplRepresentation<E> body = Merger.ofPages(pages).withDefaultValue(PageImplRepresentation::new).merge();
return new ResponseEntity<>(body, HttpStatus.OK);
}
Aggregations