From b7ef06d97c519b7eb7e78b373788263c19ac9eda Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Wed, 14 Jan 2009 14:05:43 +0000 Subject: [PATCH] Merged V3.0 to HEAD 12734: Fix for ETHREEOH-1007 12735: Fix for ALFCOM-2326 (applied to 3.0E original code location) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12739 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/repo/site/SiteServiceImpl.java | 46 ++++++++----------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/source/java/org/alfresco/repo/site/SiteServiceImpl.java b/source/java/org/alfresco/repo/site/SiteServiceImpl.java index 1f93fb11e5..a0b9405146 100644 --- a/source/java/org/alfresco/repo/site/SiteServiceImpl.java +++ b/source/java/org/alfresco/repo/site/SiteServiceImpl.java @@ -792,31 +792,24 @@ public class SiteServiceImpl implements SiteService, SiteModel // If ... // -- the current user has change permissions rights on the site // or - // -- the site is public and - // -- the user is ourselves and - // -- the users current role is consumer - if ((permissionService.hasPermission(siteNodeRef, - PermissionService.CHANGE_PERMISSIONS) == AccessStatus.ALLOWED) - || (isPublic == true - && currentUserName.equals(userName) == true && role - .equals(SiteModel.SITE_CONSUMER) == true)) + // -- the user is ourselves + if ((currentUserName.equals(userName) == true) || + (permissionService.hasPermission(siteNodeRef, PermissionService.CHANGE_PERMISSIONS) == AccessStatus.ALLOWED)) { // Run as system user AuthenticationUtil.runAs( - new AuthenticationUtil.RunAsWork() + new AuthenticationUtil.RunAsWork() + { + public Object doWork() throws Exception { - public Object doWork() throws Exception - { - // Remove the user from the current permission - // group - String currentGroup = getSiteRoleGroup( - shortName, role, true); - authorityService.removeAuthority(currentGroup, - userName); - - return null; - } - }, AuthenticationUtil.SYSTEM_USER_NAME); + // Remove the user from the current permission + // group + String currentGroup = getSiteRoleGroup(shortName, role, true); + authorityService.removeAuthority(currentGroup, userName); + + return null; + } + }, AuthenticationUtil.SYSTEM_USER_NAME); // Raise events if (AuthorityType.getAuthorityType(userName) == AuthorityType.USER) @@ -824,14 +817,15 @@ public class SiteServiceImpl implements SiteService, SiteModel activityService.postActivity( ActivityType.SITE_USER_REMOVED, shortName, ACTIVITY_TOOL, getActivityData(userName, "")); - } else + } + else { // TODO - update this, if sites support groups - logger - .error("setMembership - failed to post activity: unexpected authority type: " - + AuthorityType.getAuthorityType(userName)); + logger.error("setMembership - failed to post activity: unexpected authority type: " + + AuthorityType.getAuthorityType(userName)); } - } else + } + else { // Throw a permission exception throw new AlfrescoRuntimeException(