if (!isEmpty(userName) && !isEmpty(password))
{
try
{
userManager.addUser(userName, password);
TreeControl control = (TreeControl) actionRequest.getPortletSession().getAttribute(TREE_CONTROL);
Iterator users = userManager.getUsers(USER_FILTER);
control = buildTree(users, actionRequest.getLocale());
actionRequest.getPortletSession().setAttribute(TREE_CONTROL, control);
selectNode(actionRequest, control, userName);
User user = userManager.getUser(userName);
String role = actionRequest.getParameter(ROLES_CONTROL);
if (!isEmpty(role) && user != null)
{
roleManager.addRoleToUser(userName, role);
}
String rule = actionRequest.getParameter(RULES_CONTROL);
if (!isEmpty(rule) && user != null)
{
Principal principal = getPrincipal(user.getSubject(), UserPrincipal.class);
profiler.setRuleForPrincipal(principal, profiler.getRule(rule), "page");
}
}
catch (SecurityException se)
{
PortletMessaging.publish(actionRequest, "user.error", se.getMessage());
}
}
return;
}
TreeControl control = (TreeControl) actionRequest.getPortletSession().getAttribute(TREE_CONTROL);
//assert control != null
if (control != null)
{
// expand or contact non-leaf nodes
String node = actionRequest.getParameter(SecurityResources.REQUEST_NODE);
if (node != null)
{
TreeControlNode controlNode = control.findNode(node);
if (controlNode != null)
{
controlNode.setExpanded(!controlNode.isExpanded());
}
}