cancel
Showing results for 
Search instead for 
Did you mean: 

Portal role lookup based on iView?

Former Member
0 Kudos

Hi,

Does anyone know which Java statements to use in order to lookup the portal role to which a particular Java iView is attached?

com.sapportals.portal.navigation.INavigationService does not seem to do the trick (with this class, I am able to get all the roles assigned to a user, however I need the specific role on which the Java iView resides).

Thanks in advance,

Rasmus Ørtoft

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you have the iView directly assigned to the role (or workset) and not inside a page, you can get all top level navigation nodes and then go down from there until you find the iView.

Then compare the url you get to the roles the user has. One of the roles is contained in the iView url.

If you have the iView inside a page.... take it out?

Former Member
0 Kudos

Hi Rui,

This is sort of what I'm doing at the moment. However, the iView may be placed under various roles and I need a way to identify the specific role without hardcoding search teams or similar into the application. I think that I <i>should</i> be able to lookup the exact role to which the iView is attached (actually role -> workset -> page -> iView) but I don't know the exact statement :o(

Kind regards,

Rasmus

Former Member
0 Kudos

I've never tried to get an iview that's inside a page, so I can't help you much with that. However, if you want to get an iView that is a navigation node of the user do this:


NavigationEventsHelperService navHelperService = (NavigationEventsHelperService)PortalRuntime.getRuntimeResources().getService("com.sap.portal.navigation.helperservice.navigation_events_helper");

NavigationNodes initialNodes = navHelperService.getRealInitialNodes(request);

//get the user's roles
Iterator userRoles = request.getUser().getRoles(true);
PrincipalIterator pIterator = new PrincipalIterator(userRoles, PrincipalIterator.ITERATOR_TYPE_PRINCIPALS);

for(Iterator it = initialNodes.iterator(); it.hasNext();)
{
INavigationNode initialNode = (INavigationNode)it.next();
// initialNode.getChildren() will give you all the children. do this recursively...

while (pIterator.hasNext())
{
   IRole tmpRole = (IRole)pIterator.next();

   if (initialNode.getName().indexOf(tmpRole.getDisplayName()) != -1 )
   { //compare the node to the roles
      // tmpRole is the role you want
   }
   else {
     // compare to next role
   }
}
}

Former Member
0 Kudos

Hi Rui,

Thank you for your answer. I cannot seem to find the NavigationEventsHelperService class other than the SAP reference describing it:

<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/43/0029d0e7371aa2e10000000a422035/content.htm">http://help.sap.com/saphelp_nw2004s/helpdata/en/43/0029d0e7371aa2e10000000a422035/content.htm</a>

Kind regards,

Rasmus

Former Member
0 Kudos

Hi,

I'm afraid I can't help you much with that. I don't have any more info on that class (I think it's not listed in the Javadocs). Only that it's needed to get the initial navigation nodes and that's the way to get them (at least the only one I know). Then you can find the INavigationNode in the Javadocs.

Regards,

Rui

Answers (0)