diff --git a/source/java/org/alfresco/rest/api/Queries.java b/source/java/org/alfresco/rest/api/Queries.java index d7459a25b3..6319bd99c1 100644 --- a/source/java/org/alfresco/rest/api/Queries.java +++ b/source/java/org/alfresco/rest/api/Queries.java @@ -57,7 +57,7 @@ public interface Queries static int MIN_TERM_LENGTH_NODES = 3; // People query - static String PARAM_USERNAME = ContentModel.PROP_USERNAME.getLocalName(); + static String PARAM_PERSON_ID = "id"; static String PARAM_FIRSTNAME = ContentModel.PROP_FIRSTNAME.getLocalName(); static String PARAM_LASTNAME = ContentModel.PROP_LASTNAME.getLocalName(); static int MIN_TERM_LENGTH_PEOPLE = 2; diff --git a/source/java/org/alfresco/rest/api/impl/QueriesImpl.java b/source/java/org/alfresco/rest/api/impl/QueriesImpl.java index bdb451b875..2a95def539 100644 --- a/source/java/org/alfresco/rest/api/impl/QueriesImpl.java +++ b/source/java/org/alfresco/rest/api/impl/QueriesImpl.java @@ -94,7 +94,7 @@ public class QueriesImpl implements Queries, InitializingBean PARAM_MODIFIEDAT, ContentModel.PROP_MODIFIED); private final static Map PEOPLE_SORT_PARAMS_TO_QNAMES = sortParamsToQNames( - ContentModel.PROP_USERNAME, + PARAM_PERSON_ID, ContentModel.PROP_USERNAME, ContentModel.PROP_FIRSTNAME, ContentModel.PROP_LASTNAME); @@ -447,6 +447,15 @@ public class QueriesImpl implements Queries, InitializingBean T t = convert(nodeRef, includeParam); collection.add(t); } + + if (sort == POST_QUERY_SORT) + { + return listPage(collection, paging); + } + else + { + return CollectionWithPagingInfo.asPaged(paging, collection, queryResults.hasMore(), new Long(queryResults.getNumberFound()).intValue()); + } } finally { @@ -455,15 +464,6 @@ public class QueriesImpl implements Queries, InitializingBean queryResults.close(); } } - - if (sort == POST_QUERY_SORT) - { - return listPage(collection, paging); - } - else - { - return CollectionWithPagingInfo.asPaged(paging, collection, queryResults.hasMore(), new Long(queryResults.getNumberFound()).intValue()); - } } /** diff --git a/source/test-java/org/alfresco/rest/api/tests/QueriesPeopleApiTest.java b/source/test-java/org/alfresco/rest/api/tests/QueriesPeopleApiTest.java index 7792668fa1..6ca44ea58e 100644 --- a/source/test-java/org/alfresco/rest/api/tests/QueriesPeopleApiTest.java +++ b/source/test-java/org/alfresco/rest/api/tests/QueriesPeopleApiTest.java @@ -27,7 +27,10 @@ package org.alfresco.rest.api.tests; import static org.alfresco.rest.api.Queries.PARAM_FIRSTNAME; import static org.alfresco.rest.api.Queries.PARAM_LASTNAME; +import static org.alfresco.rest.api.Queries.PARAM_PERSON_ID; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.ArrayList; @@ -67,7 +70,7 @@ public class QueriesPeopleApiTest extends AbstractSingleNetworkSiteTest // deleting users is hard from from static methods. For the moment do it // in the first and last tests, but we have to get the TEST count right! // If we don't, a test fails or the users get left behind (not too bad). - private static int TEST_COUNT = 13; + private static int TEST_COUNT = 20; private static int testCounter = 0; // Test usernames @@ -246,20 +249,23 @@ public class QueriesPeopleApiTest extends AbstractSingleNetworkSiteTest response = getAll(URL_QUERIES_LSP, paging, params, expectedStatus); - if (expectedPeople != null && expectedStatus == 200) + if (expectedStatus == 200) { people = Person.parsePeople(response.getJsonResponse()).getList(); - StringJoiner actual = new StringJoiner("\n"); - StringJoiner expected = new StringJoiner("\n"); - for (int i=0; i