From 069da2af2961e30db7401b01a2a1f2e4c637f317 Mon Sep 17 00:00:00 2001 From: Martin Muller Date: Fri, 5 Aug 2016 13:49:53 +0000 Subject: [PATCH] Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1) 129052 adavis: REPO-232,REPO-883 V1 REST API: Sites Live Search (/queries/live-search-sites) - As part of code review: Added generics to listPage method and moved it inside AbstractQuery. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@129196 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/rest/api/impl/QueriesImpl.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/source/java/org/alfresco/rest/api/impl/QueriesImpl.java b/source/java/org/alfresco/rest/api/impl/QueriesImpl.java index 87a190d52f..bc8a5f79bb 100644 --- a/source/java/org/alfresco/rest/api/impl/QueriesImpl.java +++ b/source/java/org/alfresco/rest/api/impl/QueriesImpl.java @@ -610,40 +610,40 @@ public class QueriesImpl implements Queries, InitializingBean } return nodeRefs; } - } - // note: see also AbstractNodeRelation - protected static CollectionWithPagingInfo listPage(List result, Paging paging) - { - // return 'page' of results (based on full result set) - int skipCount = paging.getSkipCount(); - int pageSize = paging.getMaxItems(); - int pageEnd = skipCount + pageSize; - - final List page = new ArrayList<>(pageSize); - if (result == null) + // note: see also AbstractNodeRelation + protected static CollectionWithPagingInfo listPage(List result, Paging paging) { - result = Collections.emptyList(); - } + // return 'page' of results (based on full result set) + int skipCount = paging.getSkipCount(); + int pageSize = paging.getMaxItems(); + int pageEnd = skipCount + pageSize; - Iterator it = result.iterator(); - for (int counter = 0; counter < pageEnd && it.hasNext(); counter++) - { - Object element = it.next(); - if (counter < skipCount) + final List page = new ArrayList<>(pageSize); + if (result == null) { - continue; + result = Collections.emptyList(); } - if (counter > pageEnd - 1) + + Iterator it = result.iterator(); + for (int counter = 0; counter < pageEnd && it.hasNext(); counter++) { - break; + T element = it.next(); + if (counter < skipCount) + { + continue; + } + if (counter > pageEnd - 1) + { + break; + } + page.add(element); } - page.add(element); + + int totalCount = result.size(); + boolean hasMoreItems = ((skipCount + page.size()) < totalCount); + + return CollectionWithPagingInfo.asPaged(paging, page, hasMoreItems, totalCount); } - - int totalCount = result.size(); - boolean hasMoreItems = ((skipCount + page.size()) < totalCount); - - return CollectionWithPagingInfo.asPaged(paging, page, hasMoreItems, totalCount); } }