ALF-10001 Update SiteService.listMembers to check group display names as well as group names, plus test

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30225 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2011-09-05 14:22:01 +00:00
parent 32b756a7f9
commit f694b1c928
2 changed files with 24 additions and 4 deletions

View File

@@ -1447,7 +1447,8 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
// Build an array of name filter tokens pre lowercased to test against person properties
// We require that matching people have at least one match against one of these on
// either their firstname or last name
// For groups, we require a match against the whole filter on the group name
// For groups, we require a match against the whole filter on the group name or display name
String nameFilterLower = null;
String[] nameFilters = new String[0];
if (nameFilter != null && nameFilter.length() != 0)
{
@@ -1457,6 +1458,7 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
{
nameFilters[i] = t.nextToken().toLowerCase();
}
nameFilterLower = nameFilter.toLowerCase();
}
Map<String, String> members = new HashMap<String, String>(32);
@@ -1503,10 +1505,19 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
if (nameFilter != null && nameFilter.length() != 0)
{
// found a filter - does it match Group name part?
if (authority.substring(GROUP_PREFIX_LENGTH).toLowerCase().contains(nameFilter.toLowerCase()))
if (authority.substring(GROUP_PREFIX_LENGTH).toLowerCase().contains(nameFilterLower))
{
members.put(authority, permission);
}
else
{
// Does it match on the Group Display Name part instead?
String displayName = authorityService.getAuthorityDisplayName(authority);
if(displayName != null && displayName.toLowerCase().contains(nameFilterLower))
{
members.put(authority, permission);
}
}
}
else
{

View File

@@ -87,6 +87,8 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest
private static final String GROUP_TWO = "GrpTwo_SiteServiceImplTest";
private static final String GROUP_THREE = "GrpThree_SiteServiceImplTest";
private static final String GROUP_FOUR = "GrpFour_SiteServiceImplTest";
private static final String GROUP_ONE_DISPLAY = "DisplayOfGrpOne-SiteServiceImplTest";
private static final String GROUP_TWO_DISPLAY = "DisplayOfGrpTwo-SiteServiceImplTest";
private CopyService copyService;
private ScriptService scriptService;
@@ -146,10 +148,10 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest
createUser(USER_FOUR, "UsRFoUr");
// Create the test groups
this.groupOne = this.authorityService.createAuthority(AuthorityType.GROUP, GROUP_ONE);
this.groupOne = this.authorityService.createAuthority(AuthorityType.GROUP, GROUP_ONE, GROUP_ONE_DISPLAY, null);
this.authorityService.addAuthority(this.groupOne, USER_TWO);
this.groupTwo = this.authorityService.createAuthority(AuthorityType.GROUP, GROUP_TWO);
this.groupTwo = this.authorityService.createAuthority(AuthorityType.GROUP, GROUP_TWO, GROUP_TWO_DISPLAY, null);
this.authorityService.addAuthority(this.groupTwo, USER_TWO);
this.authorityService.addAuthority(this.groupTwo, USER_THREE);
@@ -1323,6 +1325,13 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest
assertEquals(1, members.size());
assertTrue(members.containsKey(this.groupTwo));
assertEquals(SiteModel.SITE_CONSUMER, members.get(this.groupTwo));
// - filter by name - group display name
members = this.siteService.listMembers("testMembership", GROUP_TWO_DISPLAY, null, 0, false);
assertNotNull(members);
assertEquals(1, members.size());
assertTrue(members.containsKey(this.groupTwo));
assertEquals(SiteModel.SITE_CONSUMER, members.get(this.groupTwo));
// - filter by name - group name with expansion
// (won't match anyone as the group name won't hit people too)