Merged 5.2.N (5.2.1) to HEAD (5.2)

129162 mmuller: Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1)
      128479 jvonka: V1 REST API: Node Version History - add basic paging
      REPO-313


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129336 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alexandru Epure
2016-08-09 14:11:52 +00:00
parent 801f50689c
commit 6a7984c98f
3 changed files with 86 additions and 32 deletions

View File

@@ -157,9 +157,8 @@ public class AbstractNodeRelation implements InitializingBean
collection.add(node);
}
}
Paging paging = parameters.getPaging();
return CollectionWithPagingInfo.asPaged(paging, collection, false, collection.size());
return listPage(collection, parameters.getPaging());
}
protected CollectionWithPagingInfo<Node> listNodeChildAssocs(List<ChildAssociationRef> childAssocRefs, Parameters parameters, Boolean isPrimary, boolean returnChild)
@@ -170,7 +169,7 @@ public class AbstractNodeRelation implements InitializingBean
List<String> includeParam = parameters.getInclude();
List<Node> result = new ArrayList<Node>(childAssocRefs.size());
List<Node> collection = new ArrayList<Node>(childAssocRefs.size());
for (ChildAssociationRef childAssocRef : childAssocRefs)
{
if (isPrimary == null || (isPrimary == childAssocRef.isPrimary()))
@@ -192,25 +191,27 @@ public class AbstractNodeRelation implements InitializingBean
}
node.setAssociation(new AssocChild(assocType, childAssocRef.isPrimary()));
result.add(node);
collection.add(node);
}
}
}
Paging paging = parameters.getPaging();
return listPage(collection, parameters.getPaging());
}
protected CollectionWithPagingInfo listPage(List result, Paging paging)
{
// return 'page' of results (note: depends on in-built/natural sort order of results)
int skipCount = paging.getSkipCount();
int pageSize = paging.getMaxItems();
int pageEnd = skipCount + pageSize;
final List<Node> page = new ArrayList<>(pageSize);
Iterator<Node> it = result.iterator();
final List page = new ArrayList<>(pageSize);
Iterator it = result.iterator();
for (int counter = 0; counter < pageEnd && it.hasNext(); counter++)
{
Node element = it.next();
Object element = it.next();
if (counter < skipCount)
{
continue;