mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.N (5.2.2) to HEAD (5.2)
134805 mward: 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/HEAD/root@137364 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user