mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ALF-9098 - Handle trailing wildcards in the new (canned query powered) getPerson call
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28456 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1195,7 +1195,20 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
|
||||
filterProps = new ArrayList<FilterProp>(stringPropFilters.size());
|
||||
for (Pair<QName, String> filterProp : stringPropFilters)
|
||||
{
|
||||
filterProps.add(new FilterPropString(filterProp.getFirst(), filterProp.getSecond(), (filterIgnoreCase ? FilterTypeString.STARTSWITH_IGNORECASE : FilterTypeString.STARTSWITH)));
|
||||
String filterStr = filterProp.getSecond();
|
||||
if("*".equals(filterStr))
|
||||
{
|
||||
// The wildcard means no filtering is needed on this property
|
||||
continue;
|
||||
}
|
||||
else if(filterStr.endsWith("*"))
|
||||
{
|
||||
// The trailing * is implicit
|
||||
filterStr = filterStr.substring(0, filterStr.length()-1);
|
||||
}
|
||||
|
||||
// Turn this into a canned query filter
|
||||
filterProps.add(new FilterPropString(filterProp.getFirst(), filterStr, (filterIgnoreCase ? FilterTypeString.STARTSWITH_IGNORECASE : FilterTypeString.STARTSWITH)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -598,6 +598,17 @@ public class PersonTest extends TestCase
|
||||
filters.clear();
|
||||
filters.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, "a"));
|
||||
assertEquals(1, personService.getPeople(filters, true, null, pr).getPage().size()); // includes "admin"
|
||||
|
||||
// a* is the same as a
|
||||
filters.clear();
|
||||
filters.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, "a*"));
|
||||
assertEquals(1, personService.getPeople(filters, true, null, pr).getPage().size()); // includes "admin"
|
||||
|
||||
// * means everyone
|
||||
filters.clear();
|
||||
filters.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, "*"));
|
||||
assertEquals(5, getPeopleCount());
|
||||
assertEquals(5, personService.getPeople(filters, true, null, pr).getPage().size());
|
||||
}
|
||||
|
||||
public void testPeopleSortingPaging()
|
||||
|
Reference in New Issue
Block a user