mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
107010: Merged 5.0.N (5.0.3) to HEAD-BUG-FIX (5.1/Cloud) 106860: MNT-14113: User admin console: sorting users causes some to disappear The behavior of indexed people search has been modified to return the same results as a CQ search. The test for this behavior has been added to 'PeolpleTest'. This test is valid for SOLR1/SOLR4 and "buildonly" (Lucene) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@107049 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -27,7 +27,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||
@@ -718,8 +717,12 @@ public class People extends BaseScopableProcessorExtension implements Initializi
|
||||
// single word with no field will go against _PERSON and expand
|
||||
|
||||
// fts-alfresco property search i.e. location:"maidenhead"
|
||||
query.append(term.substring(0, propIndex + 1)).append('"')
|
||||
.append(term.substring(propIndex + 1));
|
||||
query.append(term.substring(0, propIndex + 1)).append('"');
|
||||
if (propIndex < 0)
|
||||
{
|
||||
query.append('*');
|
||||
}
|
||||
query.append(term.substring(propIndex + 1));
|
||||
if (propIndex > 0)
|
||||
{
|
||||
query.append('"');
|
||||
@@ -753,7 +756,7 @@ public class People extends BaseScopableProcessorExtension implements Initializi
|
||||
{
|
||||
// simple search: first name, last name and username
|
||||
// starting with term
|
||||
query.append("_PERSON:\"");
|
||||
query.append("_PERSON:\"*");
|
||||
query.append(token);
|
||||
query.append("*\" ");
|
||||
}
|
||||
@@ -766,7 +769,7 @@ public class People extends BaseScopableProcessorExtension implements Initializi
|
||||
{
|
||||
token = token.substring(0, token.lastIndexOf("*"));
|
||||
}
|
||||
multiPartNames.append("\"");
|
||||
multiPartNames.append("\"*");
|
||||
multiPartNames.append(token);
|
||||
multiPartNames.append("*\"");
|
||||
if (firstToken)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -18,7 +18,9 @@
|
||||
*/
|
||||
package org.alfresco.repo.jscript;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
@@ -27,6 +29,7 @@ import junit.framework.TestCase;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.security.PersonService.PersonInfo;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
@@ -49,6 +52,12 @@ import org.springframework.context.ApplicationContext;
|
||||
@Category(OwnJVMTestsCategory.class)
|
||||
public class PeopleTest extends TestCase
|
||||
{
|
||||
private static final String SIMPLE_FILTER = "a";
|
||||
|
||||
private static final String CQ_SIMPLE_FILTER = SIMPLE_FILTER + " [hint:useCQ]";
|
||||
|
||||
private static final String DEFAULT_SORT_BY_FIELD = "username";
|
||||
|
||||
|
||||
private static final UserInfo USER_1 = new UserInfo("user1", "john junior", "lewis second");
|
||||
private static final UserInfo USER_2 = new UserInfo("user2", "john senior", "lewis second");
|
||||
@@ -171,6 +180,33 @@ public class PeopleTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for <a href="https://issues.alfresco.com/jira/browse/MNT-14113">MNT-14113</a>. <br />
|
||||
* <br />
|
||||
* This test is also valid for SOLR1 and SOLR4!
|
||||
*/
|
||||
public void testGetPeopleByPatternIndexedAndCQ() throws Exception
|
||||
{
|
||||
ScriptPagingDetails paging = new ScriptPagingDetails(0, 0);
|
||||
List<PersonInfo> unsortedPeople = people.getPeopleImpl(CQ_SIMPLE_FILTER, paging, null, null);
|
||||
assertNotNull("No one person is found!", unsortedPeople);
|
||||
|
||||
Set<NodeRef> expectedUsers = new HashSet<NodeRef>();
|
||||
for (PersonInfo person : unsortedPeople)
|
||||
{
|
||||
expectedUsers.add(person.getNodeRef());
|
||||
}
|
||||
|
||||
List<PersonInfo> sortedPeople = people.getPeopleImpl(SIMPLE_FILTER, paging, DEFAULT_SORT_BY_FIELD, null);
|
||||
assertNotNull("No one person is found and sorted!", sortedPeople);
|
||||
assertEquals(expectedUsers.size(), sortedPeople.size());
|
||||
|
||||
for (PersonInfo person : sortedPeople)
|
||||
{
|
||||
assertTrue(("Unexpected person: '" + person.getUserName() + "[" + person.getNodeRef() + "]'"), expectedUsers.contains(person.getNodeRef()));
|
||||
}
|
||||
}
|
||||
|
||||
private void createUser(UserInfo... userInfo)
|
||||
{
|
||||
for (UserInfo user : userInfo)
|
||||
|
Reference in New Issue
Block a user