REPO-1884: Don't allow adding a sub-group with memberType:"PERSON"

- Added validation and tests

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@134777 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Raluca Munteanu
2017-01-26 15:46:03 +00:00
parent 2372dfc5eb
commit 66b0cbbb69
2 changed files with 49 additions and 8 deletions

View File

@@ -623,6 +623,12 @@ public class GroupsImpl implements Groups
throw new EntityNotFoundException("Group member with id " + groupMember.getId() + " does not exists");
}
AuthorityType existingAuthorityType = AuthorityType.getAuthorityType(groupMember.getId());
if (existingAuthorityType != authorityType)
{
throw new IllegalArgumentException("Incorrect group member type, " + existingAuthorityType + " exists with the given id");
}
authorityService.addAuthority(groupId, groupMember.getId());
String authority = authorityService.getName(authorityType, groupMember.getId());
@@ -728,7 +734,7 @@ public class GroupsImpl implements Groups
throw new EntityNotFoundException(groupId);
}
}
private void validateGroup(Group group, boolean isUpdate)
{
if (group == null)