tabMap = userTabMap;
}
// Tabs
request.setAttribute("tabs", tabMap.values());
TabBean selectedTab =
(TabBean) request.getPortletSession().getAttribute(SecurityResources.REQUEST_SELECT_TAB);
if(selectedTab != null && !tabMap.containsKey(selectedTab.getId()))
{
selectedTab = null;
}
if(selectedTab == null)
{
selectedTab = (TabBean) tabMap.values().iterator().next();
}
JetspeedUserBean bean = new JetspeedUserBean(user);
request.setAttribute(VIEW_USER, bean);
if (selectedTab.getId().equals(TAB_USER))
{
request.setAttribute(VIEW_PA_USER_ATTRIBUTES, paUserAttributes);
if ( "true".equals(request.getPreferences().getValue("showPasswordOnUserTab", "false")))
{
request.setAttribute(VIEW_CREDENTIAL, getCredential(userName));
}
}
else if (selectedTab.getId().equals(TAB_ROLE))
{
Collection userRoles = getRoles(userName);
request.setAttribute(VIEW_ROLES, userRoles );
// check for refresh on roles list
String refreshRoles = (String)PortletMessaging.consume(request, SecurityResources.TOPIC_USERS, "roles");
List roles = null;
if (refreshRoles == null)
{
roles = (List) request.getPortletSession().getAttribute(ROLES_CONTROL);
}
// build the roles control and provide it to the view
try
{
if (roles == null)
{
roles = new LinkedList();
Iterator fullRoles = roleManager.getRoles("");
while (fullRoles.hasNext())
{
Role role = (Role)fullRoles.next();
roles.add(role.getPrincipal().getName());
}
request.getPortletSession().setAttribute(ROLES_CONTROL, roles);
}
}
catch (SecurityException se)
{
throw new PortletException(se);
}
ArrayList selectableRoles = new ArrayList(roles);
Iterator rolesIter = userRoles.iterator();
while ( rolesIter.hasNext() )
{
Role role = (Role)rolesIter.next();
int index = selectableRoles.indexOf(role.getPrincipal().getName());
if (index != -1)
{
selectableRoles.remove(index);
}
}
request.setAttribute(ROLES_CONTROL, selectableRoles);
}
else if (selectedTab.getId().equals(TAB_GROUP))
{
Collection userGroups = getGroups(userName);
request.setAttribute(VIEW_GROUPS, userGroups);
// check for refresh on groups list
String refreshGroups = (String)PortletMessaging.consume(request, SecurityResources.TOPIC_USERS, "groups");
List groups = null;
if (refreshGroups == null)
{
groups = (List) request.getPortletSession().getAttribute(GROUPS_CONTROL);
}
// build the groups control and provide it to the view
try
{
if (groups == null)
{
groups = new LinkedList();
Iterator fullGroups = groupManager.getGroups("");
while (fullGroups.hasNext())
{
Group group = (Group)fullGroups.next();
groups.add(group.getPrincipal().getName());
}
request.getPortletSession().setAttribute(GROUPS_CONTROL, groups);
}
}
catch (SecurityException se)
{
throw new PortletException(se);
}
ArrayList selectableGroups = new ArrayList(groups);
Iterator groupsIter = userGroups.iterator();
while ( groupsIter.hasNext() )
{
Group group = (Group)groupsIter.next();
int index = selectableGroups.indexOf(group.getPrincipal().getName());
if (index != -1)
{
selectableGroups.remove(index);
}
}
request.setAttribute(GROUPS_CONTROL, selectableGroups);
}
else if (selectedTab.getId().equals(TAB_PROFILE))
{
request.setAttribute(VIEW_RULES, getRules(user));
request.setAttribute(VIEW_ALL_RULES, getProfilerRules());
}
else if (selectedTab.getId().equals(TAB_CREDENTIAL))
{
request.setAttribute(VIEW_CREDENTIAL, getCredential(userName));
}
request.setAttribute(SecurityResources.REQUEST_SELECT_TAB, selectedTab);