mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/V4.1-BUG-FIX to HEAD
43795: Fix for ALF-16254 - "Leave Site" behaviour for group based site membership: The API - "api/sites/<siteid>/memberships/<authority>" now returns additional json boolean value "isMemberOfGroup" to indicate if the specified user has an implied group membership of a site or a direct membership. This is the same information that is also returned by the full site membership "api/sites/<siteid>/memberships" API - so makes them more consistent also. Share now takes the additional value into account when making the decision on whether to render the "Leave Site" button on the site title component. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@43801 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1561,7 +1561,10 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
String roleFilter, int size, boolean collapseGroups)
|
||||
{
|
||||
NodeRef siteNodeRef = getSiteNodeRef(shortName);
|
||||
if (siteNodeRef == null) { throw new SiteDoesNotExistException(shortName); }
|
||||
if (siteNodeRef == null)
|
||||
{
|
||||
throw new SiteDoesNotExistException(shortName);
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -1760,6 +1763,57 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.site.SiteService#getMembersRoleInfo(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public SiteMemberInfo getMembersRoleInfo(String shortName, String authorityName)
|
||||
{
|
||||
NodeRef siteNodeRef = getSiteNodeRef(shortName);
|
||||
if (siteNodeRef == null)
|
||||
{
|
||||
throw new SiteDoesNotExistException(shortName);
|
||||
}
|
||||
|
||||
SiteMemberInfo membership = null;
|
||||
|
||||
QName siteType = directNodeService.getType(siteNodeRef);
|
||||
Set<String> permissions = this.permissionService.getSettablePermissions(siteType);
|
||||
for (String role : permissions)
|
||||
{
|
||||
if (membership == null)
|
||||
{
|
||||
String roleGroup = getSiteRoleGroup(shortName, role, true);
|
||||
Set<String> authorities = this.authorityService.getContainedAuthorities(null, roleGroup, true);
|
||||
if (authorities.contains(authorityName))
|
||||
{
|
||||
// found a direct membership for this user - return this role info
|
||||
membership = new SiteMemberInfoImpl(authorityName, role, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// else test each group returned to see if the user is contained within it
|
||||
for (String authority : authorities)
|
||||
{
|
||||
switch (AuthorityType.getAuthorityType(authority))
|
||||
{
|
||||
case GROUP:
|
||||
Set<String> users = this.authorityService.getContainedAuthorities(AuthorityType.USER, authority, false);
|
||||
if (users.contains(authorityName))
|
||||
{
|
||||
membership = new SiteMemberInfoImpl(authorityName, role, true);
|
||||
// skip out - one confirmed role membership is enough information
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return membership;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.site.SiteService#getMembersRole(java.lang.String,
|
||||
* java.lang.String)
|
||||
|
Reference in New Issue
Block a user