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
This commit is contained in:
Kevin Roast
2006-05-24 13:08:01 +00:00
parent 8abc4a6e95
commit 893f45e1a8
2 changed files with 17 additions and 6 deletions

View File

@@ -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

View File

@@ -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;
}