From 893f45e1a8649487a4ae5a6676d288c4023d1a4a Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Wed, 24 May 2006 13:08:01 +0000 Subject: [PATCH] Fix for AWC-613 - Groups UI now checks for duplicate existing group IDs when creating new/sub groups git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2968 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 1 + .../org/alfresco/web/bean/GroupsBean.java | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 4129e64e67..d3b53defa4 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -413,6 +413,7 @@ add_user_group_description=Add an existing User to a Group select_users=Select Users to add to this Group selected_users=Selected Users groups_err_group_name=Group ID cannot contain the characters: {0} +groups_err_exists=A group ID with the same name already exists, group identifiers must be unique. # Invite Users Wizard messages invite_title=Invite Users Wizard diff --git a/source/java/org/alfresco/web/bean/GroupsBean.java b/source/java/org/alfresco/web/bean/GroupsBean.java index 4cda51792a..58b5c1de4a 100644 --- a/source/java/org/alfresco/web/bean/GroupsBean.java +++ b/source/java/org/alfresco/web/bean/GroupsBean.java @@ -65,11 +65,12 @@ public class GroupsBean implements IContextListener { private static final String FILTER_CHILDREN = "children"; private static final String FILTER_ALL = "all"; - + private static final String DEFAULT_OUTCOME = "finish"; - + + private static final String MSG_ERR_EXISTS = "groups_err_exists"; private static final String MSG_GROUPS = "root_groups"; - + private static Logger logger = Logger.getLogger(GroupsBean.class); /** The NodeService to be used by the bean */ @@ -648,15 +649,24 @@ public class GroupsBean implements IContextListener { String outcome = DEFAULT_OUTCOME; + FacesContext context = FacesContext.getCurrentInstance(); UserTransaction tx = null; try { - FacesContext context = FacesContext.getCurrentInstance(); tx = Repository.getUserTransaction(context); tx.begin(); // create new Group using Authentication Service - this.authService.createAuthority(AuthorityType.GROUP, getActionGroup(), this.name); + String groupName = this.authService.getName(AuthorityType.GROUP, this.name); + if (this.authService.authorityExists(groupName) == false) + { + this.authService.createAuthority(AuthorityType.GROUP, getActionGroup(), this.name); + } + else + { + Utils.addErrorMessage(Application.getMessage(context, MSG_ERR_EXISTS)); + outcome = null; + } // commit the transaction tx.commit(); @@ -666,7 +676,7 @@ public class GroupsBean implements IContextListener // rollback the transaction try { if (tx != null) {tx.rollback();} } catch (Exception tex) {} Utils.addErrorMessage(MessageFormat.format(Application.getMessage( - FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err); + context, Repository.ERROR_GENERIC), err.getMessage()), err); outcome = null; }