* @throws UserPortalException any user portal exception
*/
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));
}
// Add group navigations
if (service.getUserACL().getSuperUser().equals(userName)) {
List<NavigationContext> navCtxs = service.getNavigationService().loadNavigations(SiteType.GROUP);
for (NavigationContext navCtx : navCtxs) {
if (!navCtx.getKey().getName().equals(service.getUserACL().getGuestsGroup())) {
navigations.add(new UserNavigation(this, navCtx, true));
}
}
} else {
Collection<?> groups;
try {
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())));
}
}
}
}