Merged 5.2.N (5.2.2) to HEAD (5.2)

134747 cturlica: REPO-1305: Delete a group
      - restrict delete group to group authority


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@137354 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrei Rebegea
2017-06-14 16:58:48 +00:00
parent 6602788c5c
commit ad7fc8b22e
2 changed files with 19 additions and 1 deletions

View File

@@ -528,6 +528,11 @@ public class GroupsImpl implements Groups
public void delete(String groupId, Parameters parameters)
{
if (!isGroupAuthority(groupId))
{
throw new InvalidArgumentException("Invalid group id: " + groupId);
}
// Get cascade param - default false (if not provided).
boolean cascade = Boolean.valueOf(parameters.getParameter(PARAM_CASCADE));
@@ -741,4 +746,10 @@ public class GroupsImpl implements Groups
return (name != null && authorityService.authorityExists(name));
}
private boolean isGroupAuthority(String authorityName)
{
AuthorityType authorityType = AuthorityType.getAuthorityType(authorityName);
return AuthorityType.GROUP.equals(authorityType) || AuthorityType.EVERYONE.equals(authorityType);
}
}

View File

@@ -1011,7 +1011,14 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
{
setRequestContext(networkOne.getId(), networkAdmin, DEFAULT_ADMIN_PWD);
groupsProxy.deleteGroup("admin", false, HttpServletResponse.SC_CONFLICT);
groupsProxy.deleteGroup("GROUP_EVERYONE", false, HttpServletResponse.SC_CONFLICT);
}
// Trying to delete a person.
{
setRequestContext(networkOne.getId(), networkAdmin, DEFAULT_ADMIN_PWD);
groupsProxy.deleteGroup(user1, false, HttpServletResponse.SC_BAD_REQUEST);
}
{