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/BRANCHES/DEV/5.2.N/root@129162 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Martin Muller
2016-08-05 13:46:26 +00:00
parent 5e6bc0ae99
commit 750adc141c
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;

View File

@@ -74,27 +74,15 @@ import java.util.Map;
* @author janv
*/
@RelationshipResource(name = "versions", entityResource = NodesEntityResource.class, title = "Node Versions")
public class NodeVersionsRelation implements
public class NodeVersionsRelation extends AbstractNodeRelation implements
RelationshipResourceAction.Read<Node>,
RelationshipResourceAction.ReadById<Node>,
RelationshipResourceBinaryAction.Read,
RelationshipResourceAction.Delete,
InitializingBean
{
protected ServiceRegistry sr;
protected Nodes nodes;
protected VersionService versionService;
public void setNodes(Nodes nodes)
{
this.nodes = nodes;
}
public void setServiceRegistry(ServiceRegistry sr)
{
this.sr = sr;
}
@Override
public void afterPropertiesSet()
{
@@ -118,8 +106,7 @@ public class NodeVersionsRelation implements
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
List<String> includeParam = parameters.getInclude();
// TODO fixme - add paging etc
List<Node> collection = null;
if (vh != null)
{
@@ -131,9 +118,8 @@ public class NodeVersionsRelation implements
collection.add(node);
}
}
Paging paging = parameters.getPaging();
return CollectionWithPagingInfo.asPaged(paging, collection, false, (collection != null ? collection.size() : 0));
return listPage(collection, parameters.getPaging());
}
private void mapVersionInfo(Version v, Node aNode)