audit.logAdminUserActivity(actionRequest.getUserPrincipal().getName(), getIPAddress(actionRequest), userName, AuditActivity.USER_CREATE, USER_ADMINISTRATION);
PortletMessaging.publish(actionRequest, SecurityResources.TOPIC_USERS, SecurityResources.MESSAGE_REFRESH, "true");
PortletMessaging.publish(actionRequest, SecurityResources.TOPIC_USERS, SecurityResources.MESSAGE_SELECTED, userName);
User user = userManager.getUser(userName);
PasswordCredential credential = getCredential(user);
if ( credential != null )
{
String updateRequiredStr = actionRequest.getParameter("user_cred_updreq");
if (updateRequiredStr != null)
{
boolean updateRequired = Boolean.valueOf(updateRequiredStr).booleanValue();
if (updateRequired != credential.isUpdateRequired())
{
userManager.setPasswordUpdateRequired(userName,updateRequired);
}
}
}
String requiredRole = actionRequest.getPreferences().getValue("requiredRole", "");
if (!requiredRole.equals("") && user != null)
{
roleManager.addRoleToUser(userName, requiredRole);
}
String role = actionRequest.getParameter(ROLES_CONTROL);
if (!SecurityUtil.isEmpty(role) && user != null)
{
roleManager.addRoleToUser(userName, role);
}
String templateFolder = actionRequest.getPreferences().getValue("newUserTemplateDirectory", "/_user/template/");
String subsite = actionRequest.getParameter(SUBSITES_CONTROL);
if (SecurityUtil.isEmpty(subsite))
{
subsite = Folder.USER_FOLDER + userName;
}
else
{
subsite = subsite + Folder.USER_FOLDER + userName;
Preferences attributes = user.getUserAttributes();
attributes.put(User.USER_INFO_SUBSITE, subsite);
}
// copy the entire dir tree from the template folder
Folder source = pageManager.getFolder(templateFolder);
pageManager.deepCopyFolder(source, subsite, userName);
// TODO: send message that site tree portlet invalidated
String rule = actionRequest.getParameter(RULES_CONTROL);
if (!SecurityUtil.isEmpty(rule) && user != null)
{
Principal principal = SecurityUtil.getPrincipal(user.getSubject(), UserPrincipal.class);
profiler.setRuleForPrincipal(principal, profiler.getRule(rule), "page");
}
}
catch (SecurityException sex)