REPO-1304: Create a group

- updated error message when creating a group with the same name

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@134395 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Cristian Turlica
2017-01-17 13:01:01 +00:00
parent 93fc6fe945
commit 868f0029d3

View File

@@ -49,6 +49,7 @@ import org.alfresco.rest.antlr.WhereClauseParser;
import org.alfresco.rest.api.Groups;
import org.alfresco.rest.api.model.Group;
import org.alfresco.rest.api.model.GroupMember;
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
@@ -588,7 +589,7 @@ public class GroupsImpl implements Groups
throw new InvalidArgumentException("groupId is null or empty");
}
if (!authorityService.authorityExists(groupId))
if (!groupAuthorityExists(groupId))
{
throw new EntityNotFoundException(groupId);
}
@@ -605,5 +606,22 @@ public class GroupsImpl implements Groups
{
throw new InvalidArgumentException("groupId is null or empty");
}
if (groupAuthorityExists(group.getId()))
{
throw new ConstraintViolatedException("Group '" + group.getId() + "' already exists.");
}
}
private boolean groupAuthorityExists(String shortName)
{
return authorityExists(AuthorityType.GROUP, shortName);
}
private boolean authorityExists(AuthorityType authorityType, String shortName)
{
String name = authorityService.getName(authorityType, shortName);
return (name != null && authorityService.authorityExists(name));
}
}