Merged mward/repo-1600-zonesfilter (5.2.1) to 5.2.N (5.2.1)

134688 mward: REPO-1600: slight optimisation to use zone filtering earlier


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@134805 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2017-01-30 10:00:47 +00:00
parent 8d03006825
commit 6f28d39f6c

View File

@@ -314,8 +314,12 @@ public class GroupsImpl implements Groups
{
// Limit the post processing work by using the already loaded
// list of root authorities.
List<AuthorityInfo> authorities = rootAuthorities.stream().
map(this::getAuthorityInfo).
filter(auth -> matchZoneFilter(auth, zoneFilter)).
collect(Collectors.toList());
groupList = new ArrayList<>(rootAuthorities.size());
groupList.addAll(rootAuthorities.stream().map(this::getAuthorityInfo).collect(Collectors.toList()));
groupList.addAll(authorities);
// Post process sorting - this should be moved to service
// layer. It is done here because sorting is not supported at
@@ -330,7 +334,7 @@ public class GroupsImpl implements Groups
// Get authorities using canned query but without using
// the requested paginating now because we need to filter out
// the root authorities.
PagingResults<AuthorityInfo> nonPagingResult = authorityService.getAuthoritiesInfo(authorityType, null, null, sortProp.getFirst(), sortProp.getSecond(),
PagingResults<AuthorityInfo> nonPagingResult = authorityService.getAuthoritiesInfo(authorityType, zoneFilter, null, sortProp.getFirst(), sortProp.getSecond(),
pagingNoMaxItems);
// Post process filtering - this should be moved to service
@@ -351,18 +355,6 @@ public class GroupsImpl implements Groups
}
// Post process paging - this should be moved to service layer.
if (zoneFilter != null)
{
// Only AND (e.g. isRoot=true AND zones IN ('MY.APP')) currently supported,
// as we can easily post-filter for zones.
// If we introduce OR, then a different approach will be needed.
groupList = groupList.stream().
filter(authority -> {
Set<String> zones = authorityService.getAuthorityZones(authority.getAuthorityName());
return zones.contains(zoneFilter);
}).collect(Collectors.toList());
}
pagingResult = Util.wrapPagingResults(paging, groupList);
}
else
@@ -375,6 +367,16 @@ public class GroupsImpl implements Groups
return pagingResult;
}
private boolean matchZoneFilter(AuthorityInfo authority, String zone)
{
if (zone != null)
{
Set<String> zones = authorityService.getAuthorityZones(authority.getAuthorityName());
return zones.contains(zone);
}
return true;
}
private Set<String> getAllRootAuthorities(AuthorityType authorityType)
{
Set<String> authorities;