mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
REPO-2117: Deleted nodes pagination returns incorrect properties
- fix paging call (in API impl) & add a sanity test (to JUnit test suite) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137827 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -118,6 +118,9 @@ public class DeletedNodesImpl implements DeletedNodes
|
|||||||
|
|
||||||
// Query the DB
|
// Query the DB
|
||||||
PagingResults<NodeRef> result = nodeArchiveService.listArchivedNodes(queryBuilder);
|
PagingResults<NodeRef> result = nodeArchiveService.listArchivedNodes(queryBuilder);
|
||||||
|
|
||||||
|
Integer totalItems = result.getTotalResultCount().getFirst();
|
||||||
|
|
||||||
List<Node> nodesFound = new ArrayList<Node>(result.getPage().size());
|
List<Node> nodesFound = new ArrayList<Node>(result.getPage().size());
|
||||||
Map mapUserInfo = new HashMap<>();
|
Map mapUserInfo = new HashMap<>();
|
||||||
for (NodeRef nRef:result.getPage())
|
for (NodeRef nRef:result.getPage())
|
||||||
@@ -126,7 +129,8 @@ public class DeletedNodesImpl implements DeletedNodes
|
|||||||
mapArchiveInfo(foundNode,mapUserInfo);
|
mapArchiveInfo(foundNode,mapUserInfo);
|
||||||
nodesFound.add(foundNode);
|
nodesFound.add(foundNode);
|
||||||
}
|
}
|
||||||
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodesFound);
|
|
||||||
|
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodesFound, result.hasMoreItems(), (totalItems == null ? null : totalItems.intValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -111,6 +111,22 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
|||||||
assertNotNull(nodes);
|
assertNotNull(nodes);
|
||||||
assertEquals(numOfNodes+3,nodes.size());
|
assertEquals(numOfNodes+3,nodes.size());
|
||||||
|
|
||||||
|
//The list is ordered with the most recently deleted node first
|
||||||
|
checkDeletedNodes(now, createdFolder, createdFolderNonSite, document, nodes);
|
||||||
|
|
||||||
|
// sanity check paging
|
||||||
|
paging = getPaging(1, 1);
|
||||||
|
response = getAll(URL_DELETED_NODES, paging, 200);
|
||||||
|
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||||
|
assertNotNull(nodes);
|
||||||
|
assertEquals(1, nodes.size());
|
||||||
|
PublicApiClient.ExpectedPaging expectedPaging = RestApiUtil.parsePaging(response.getJsonResponse());
|
||||||
|
assertEquals(numOfNodes+3, expectedPaging.getTotalItems().intValue());
|
||||||
|
assertEquals(1, expectedPaging.getCount().intValue());
|
||||||
|
assertEquals(1, expectedPaging.getSkipCount().intValue());
|
||||||
|
assertEquals(1, expectedPaging.getMaxItems().intValue());
|
||||||
|
assertTrue(expectedPaging.getHasMoreItems().booleanValue());
|
||||||
|
|
||||||
Map<String, String> params = Collections.singletonMap("include", "path");
|
Map<String, String> params = Collections.singletonMap("include", "path");
|
||||||
response = getSingle(URL_DELETED_NODES, document.getId(), params, 200);
|
response = getSingle(URL_DELETED_NODES, document.getId(), params, 200);
|
||||||
Document node = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
Document node = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||||
@@ -142,9 +158,6 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
|||||||
assertEquals("/Company Home/User Homes/"+user1, path.getName());
|
assertEquals("/Company Home/User Homes/"+user1, path.getName());
|
||||||
assertTrue(path.getIsComplete());
|
assertTrue(path.getIsComplete());
|
||||||
|
|
||||||
//The list is ordered with the most recently deleted node first
|
|
||||||
checkDeletedNodes(now, createdFolder, createdFolderNonSite, document, nodes);
|
|
||||||
|
|
||||||
//User 2 can't get it but user 1 can.
|
//User 2 can't get it but user 1 can.
|
||||||
setRequestContext(user2);
|
setRequestContext(user2);
|
||||||
getSingle(URL_DELETED_NODES, createdFolderNonSite.getId(), Status.STATUS_FORBIDDEN);
|
getSingle(URL_DELETED_NODES, createdFolderNonSite.getId(), Status.STATUS_FORBIDDEN);
|
||||||
@@ -156,6 +169,7 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
|||||||
|
|
||||||
//Now as admin
|
//Now as admin
|
||||||
setRequestContext(networkAdmin);
|
setRequestContext(networkAdmin);
|
||||||
|
paging = getPaging(0, 100);
|
||||||
response = publicApiClient.get(getScope(), URL_DELETED_NODES, null, null, null, createParams(paging, null));
|
response = publicApiClient.get(getScope(), URL_DELETED_NODES, null, null, null, createParams(paging, null));
|
||||||
checkStatus(200, response.getStatusCode());
|
checkStatus(200, response.getStatusCode());
|
||||||
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||||
|
Reference in New Issue
Block a user