mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
127218 arebegea: Merged 5.0.N (5.0.4) to 5.1.N (5.1.2) 127187 cturlica: MNT-15630: CLONE - people rest api does not accept the skipCount param - merged initial solution with some changes required for 5.0.N, because the people web script was split in people.get.js and people-enterprise.get.js git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127253 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -4,21 +4,24 @@ function main()
|
||||
// Get the args
|
||||
var filter = args["filter"];
|
||||
var maxResults = args["maxResults"];
|
||||
var skipCountStr = args["skipCount"];
|
||||
var skipCount = skipCountStr != null ? parseInt(skipCountStr) : -1;
|
||||
var sortBy = args["sortBy"];
|
||||
var sortAsc = args["dir"] != "desc";
|
||||
|
||||
// Get the sorted collection of people
|
||||
var peopleCollection = people.getPeople(filter, maxResults != null ? parseInt(maxResults) : -1, sortBy, sortAsc);
|
||||
// Get the collection of people
|
||||
var paging = utils.createPaging(maxResults != null ? parseInt(maxResults) : 0, skipCount);
|
||||
var peopleCollection = people.getPeoplePaging(filter, paging, sortBy, sortAsc);
|
||||
|
||||
var skipCount = args["startIndex"] != null ? parseInt(args["startIndex"]) : 0;
|
||||
var startIndex = args["startIndex"] != null ? parseInt(args["startIndex"]) : 0;
|
||||
var pageSize = args["pageSize"] != null ? parseInt(args["pageSize"]) : peopleCollection.length
|
||||
|
||||
// Pass the queried sites to the template
|
||||
model.maxItems = pageSize;
|
||||
model.totalItems = peopleCollection.length;
|
||||
model.skipCount = skipCount;
|
||||
model.skipCount = skipCount > 0 ? (skipCount + startIndex) : startIndex;
|
||||
|
||||
model.peoplelist = peopleCollection.slice(skipCount, skipCount + pageSize);
|
||||
model.peoplelist = peopleCollection.slice(startIndex, startIndex + pageSize);
|
||||
|
||||
}
|
||||
main();
|
||||
|
@@ -245,6 +245,27 @@ public class PersonServiceTest extends BaseWebScriptTest
|
||||
response = sendRequest(new GetRequest(URL_PEOPLE + "/" + userName), 200);
|
||||
}
|
||||
|
||||
public void testGetPeopleSkipCount() throws Exception
|
||||
{
|
||||
// Test case for MNT-15357 skipCount
|
||||
int skipCount = 1;
|
||||
|
||||
// Ensure that the REST call with no filter will always be routed to a DB canned query rather than a FTS
|
||||
// (see ALF-18876 for details)
|
||||
String filter = "*%20[hint:useCQ]";
|
||||
|
||||
Response response = sendRequest(new GetRequest(URL_PEOPLE + "?filter=" + filter), 200);
|
||||
JSONObject res = new JSONObject(response.getContentAsString());
|
||||
|
||||
int peopleFound = res.getJSONArray("people").length();
|
||||
assertTrue("No people found", peopleFound > 0);
|
||||
|
||||
response = sendRequest(new GetRequest(URL_PEOPLE + "?filter=" + filter + "&skipCount=" + skipCount), 200);
|
||||
|
||||
res = new JSONObject(response.getContentAsString());
|
||||
assertTrue("skipCount ignored", res.getJSONArray("people").length() < peopleFound);
|
||||
}
|
||||
|
||||
public void testUpdatePerson() throws Exception
|
||||
{
|
||||
// Create a new person
|
||||
|
Reference in New Issue
Block a user