public List<UserNavigation> getNavigations() throws UserPortalException, NavigationServiceException
{
if (navigations == null)
{
List<UserNavigation> navigations = new ArrayList<UserNavigation>(userName == null ? 1 : 10);
NavigationContext portalNav = service.getNavigationService().loadNavigation(new SiteKey(SiteType.PORTAL, portalName));
if (portalNav != null && portalNav.getState() != null)
{
navigations.add(new UserNavigation(this, portalNav, service.getUserACL().hasEditPermission(portal)));
}
//
if (userName != null)
{
// Add user nav if any
NavigationContext userNavigation = service.getNavigationService().loadNavigation(SiteKey.user(userName));
if (userNavigation != null && userNavigation.getState() != null)
{
navigations.add(new UserNavigation(this, userNavigation, true));
}
//
Collection<?> groups;
try
{
if (service.getUserACL().getSuperUser().equals(userName))
{
groups = service.getOrganizationService().getGroupHandler().getAllGroups();
}
else
{
groups = service.getOrganizationService().getGroupHandler().findGroupsOfUser(userName);
}
}
catch (Exception e)
{
throw new UserPortalException("Could not retrieve groups", e);
}
//
for (Object group : groups)
{
Group m = (Group)group;
String groupId = m.getId().trim();
if (!groupId.equals(service.getUserACL().getGuestsGroup()))
{
NavigationContext groupNavigation = service.getNavigationService().loadNavigation(SiteKey.group(groupId));
if (groupNavigation != null && groupNavigation.getState() != null)
{
navigations.add(new UserNavigation(
this,
groupNavigation,
service.getUserACL().hasEditPermissionOnNavigation(groupNavigation.getKey())));
}
}
}
// Sort the list finally