Hi all,
While working on PWA apps for Manufacturing, I encountered the same REST
pagination logic in a few places. Since the need itself is generic and not
really manufacturing-specific, I thought it might make sense to move that
logic into RestApiUtil as reusable helpers.
I’m thinking about adding these four methods to:
framework/restapi/src/main/java/org/apache/ofbiz/ws/rs/util/RestApiUtil.java:
Here are the 4 methods:
1) getPagingParameters(Map<String, ?> parameters):
This would normalize paging inputs into a standard pageIndex and
pageSize, including defaults and support for both pageIndex/pageSize and
VIEW_INDEX/VIEW_SIZE.
2) getPartialList(EntityQuery query, int pageIndex, int pageSize):
This would wrap the usual EntityListIterator.getPartialList(...) usage
so services avoid repeating paging calculations and iterator handling.
3) getPagedResult(int pageIndex, int pageSize, long totalCount, String
listName, List<?> rows) :
This would create a standard paged REST response map with metadata like
page index, page size, total count, and the actual result list.
4) getParameterValueIgnoreCase(Map<String, ?> parameters, String... names) :
This would help look up request parameters by accepted aliases
case-insensitively.
The main goal is to avoid repeating the same small pieces of logic in REST
services and to keep pagination handling more consistent across endpoints.
Although I first needed this while building Manufacturing PWAs, the methods
themselves are generic, so I think RestApiUtil is the right place for them.
If this sounds reasonable, I can prepare a Jira ticket and contribute the
code.
Thanks
--
Divesh Dutta
www.hotwaxsystems.com