mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALFCOM-3109 - It's impossible to change role from site manager to any other role on "Search for Site Groups" page
- Now you can chage the last group as long as there's still a user with the manager role. - Last manager check is now sums both groups and users. And added another unit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15044 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1253,14 +1253,17 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
||||
// Check that we are not about to remove the last site manager
|
||||
if (SiteModel.SITE_MANAGER.equals(role) == true)
|
||||
{
|
||||
Set<String> siteMangers = this.authorityService
|
||||
.getContainedAuthorities(
|
||||
AuthorityType.USER,
|
||||
getSiteRoleGroup(shortName, SITE_MANAGER, true),
|
||||
String mgrGroup = getSiteRoleGroup(shortName, SITE_MANAGER, true);
|
||||
Set<String> siteUserMangers = this.authorityService.getContainedAuthorities(AuthorityType.USER,
|
||||
mgrGroup,
|
||||
true);
|
||||
if (siteMangers.size() == 1)
|
||||
Set<String> siteGroupManagers = this.authorityService.getContainedAuthorities(AuthorityType.GROUP,
|
||||
mgrGroup,
|
||||
true);
|
||||
|
||||
if (siteUserMangers.size() + siteGroupManagers.size() == 1)
|
||||
{
|
||||
throw new SiteServiceException(MSG_DO_NOT_REMOVE_MGR, new Object[]{authorityName});
|
||||
throw new SiteServiceException(MSG_DO_NOT_CHANGE_MGR, new Object[]{authorityName});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1358,10 +1361,15 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
||||
// Check that we are not about to remove the last site manager
|
||||
if (SiteModel.SITE_MANAGER.equals(currentRole) == true)
|
||||
{
|
||||
Set<String> siteMangers = this.authorityService.getContainedAuthorities(AuthorityType.USER,
|
||||
getSiteRoleGroup(shortName, SITE_MANAGER, true),
|
||||
String mgrGroup = getSiteRoleGroup(shortName, SITE_MANAGER, true);
|
||||
Set<String> siteUserMangers = this.authorityService.getContainedAuthorities(AuthorityType.USER,
|
||||
mgrGroup,
|
||||
true);
|
||||
if (siteMangers.size() == 1)
|
||||
Set<String> siteGroupManagers = this.authorityService.getContainedAuthorities(AuthorityType.GROUP,
|
||||
mgrGroup,
|
||||
true);
|
||||
|
||||
if (siteUserMangers.size() + siteGroupManagers.size() == 1)
|
||||
{
|
||||
throw new SiteServiceException(MSG_DO_NOT_CHANGE_MGR, new Object[]{authorityName});
|
||||
}
|
||||
|
@@ -1097,6 +1097,75 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a site with a USER manager.
|
||||
* Add Group manager membership.
|
||||
*
|
||||
* Lower User membership - should be O.K. because of Group Membership
|
||||
* Lower Group membership - should be prevented (last manager)
|
||||
*
|
||||
* Reset User membership to Manager
|
||||
*
|
||||
* Lower Group membership - should be O.K. because of User Membership
|
||||
* Lower User membership - should be prevented (last manager)
|
||||
*
|
||||
*/
|
||||
public void testALFCOM_3109()
|
||||
{
|
||||
// USER_ONE - SiteManager
|
||||
// GROUP_TWO - Manager
|
||||
|
||||
String siteName = "testALFCOM_3019";
|
||||
|
||||
// Create a site as user one
|
||||
this.siteService.createSite(TEST_SITE_PRESET, siteName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.MODERATED);
|
||||
|
||||
Map<String, String> members = this.siteService.listMembers(siteName, null, null, 0);
|
||||
String managerName = members.keySet().iterator().next();
|
||||
|
||||
/**
|
||||
* Add a group (GROUP_TWO) with role Manager
|
||||
*/
|
||||
this.siteService.setMembership(siteName, this.groupTwo, SiteModel.SITE_MANAGER);
|
||||
|
||||
// Should be allowed
|
||||
this.siteService.setMembership(siteName, managerName, SiteModel.SITE_CONTRIBUTOR);
|
||||
|
||||
/**
|
||||
* Should not be allowed to delete last group
|
||||
*/
|
||||
try
|
||||
{
|
||||
this.siteService.setMembership(siteName, this.groupTwo, SiteModel.SITE_CONTRIBUTOR);
|
||||
fail();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Should go here
|
||||
}
|
||||
|
||||
this.siteService.setMembership(siteName, managerName, SiteModel.SITE_MANAGER);
|
||||
|
||||
this.siteService.setMembership(siteName, this.groupTwo, SiteModel.SITE_CONTRIBUTOR);
|
||||
|
||||
/**
|
||||
* Should not be allowed to delete last user
|
||||
*/
|
||||
try
|
||||
{
|
||||
this.siteService.setMembership(siteName, managerName, SiteModel.SITE_CONTRIBUTOR);
|
||||
fail();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Should go here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// == Test the JavaScript API ==
|
||||
|
||||
public void testJSAPI() throws Exception
|
||||
|
Reference in New Issue
Block a user