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

134418 cturlica: REPO-1303: Update a group
      - added update group capabilities.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@137346 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrei Rebegea
2017-06-14 16:57:46 +00:00
parent b74efb3846
commit c708379824
7 changed files with 170 additions and 10 deletions

View File

@@ -114,7 +114,7 @@ public class GroupsImpl implements Groups
public Group create(Group group, Parameters parameters)
{
validateGroup(group);
validateGroup(group, false);
// Create authority with default zones.
final Set<String> authorityZones = authorityService.getDefaultZones();
@@ -136,6 +136,16 @@ public class GroupsImpl implements Groups
return getGroup(authority, parameters);
}
public Group update(String groupId, Group group, Parameters parameters)
{
validateGroupId(groupId);
validateGroup(group, true);
authorityService.setAuthorityDisplayName(groupId, group.getDisplayName());
return getGroup(groupId, parameters);
}
public Group getGroup(String groupId, Parameters parameters) throws EntityNotFoundException
{
AuthorityInfo authorityInfo = getAuthorityInfo(groupId);
@@ -649,21 +659,46 @@ public class GroupsImpl implements Groups
}
}
private void validateGroup(Group group)
private void validateGroup(Group group, boolean isUpdate)
{
if (group == null)
{
throw new InvalidArgumentException("group is null");
}
if (group.getId() == null || group.getId().isEmpty())
if (!isUpdate)
{
throw new InvalidArgumentException("groupId is null or empty");
}
if (group.getId() == null || group.getId().isEmpty())
{
throw new InvalidArgumentException("groupId is null or empty");
}
if (groupAuthorityExists(group.getId()))
if (groupAuthorityExists(group.getId()))
{
throw new ConstraintViolatedException("Group '" + group.getId() + "' already exists.");
}
}
else
{
throw new ConstraintViolatedException("Group '" + group.getId() + "' already exists.");
if (group.wasSet(Group.ID))
{
throw new InvalidArgumentException("Group update does not support field: id");
}
if (group.wasSet(Group.IS_ROOT))
{
throw new InvalidArgumentException("Group update does not support field: isRoot");
}
if (group.wasSet(Group.PARENT_IDS))
{
throw new InvalidArgumentException("Group update does not support field: parentIds");
}
if (group.wasSet(Group.ZONES))
{
throw new InvalidArgumentException("Group update does not support field: zones");
}
}
}