cancel
Showing results for 
Search instead for 
Did you mean: 

Get iViews from Role

Former Member
0 Kudos
152

Hi

I want to find out on which page a specific iViews is used, that means, where in the (user specific) navigation the iView will be displayed.

When I traverse the navigation nodes, I get with getName() something like "ROLES://portal_content/folder/page". The problem is, I don't know which iViews lie on that page. How can I get them?

When I find a role (IPortalRole object) in the PCD, I don't know what to do with it - is has no method I can use to get access to its content. Is there any way to do so?

Thank you!

Tobias

Accepted Solutions (1)

Accepted Solutions (1)

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

Hi Tobias,

If you have the pcd address of the page, you can do a JNDI lookup of the page and return the semantic object IPage.

-


Hashtable env = new Hashtable();

env.put(Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_SEMANTICS);

env.put(Context.SECURITY_PRINCIPAL, user);

try

{

com.sapportals.portal.prt.jndisupport.InitialContext iCtx = new InitialContext(env);

IPage page = (IPage)iCtx.lookup(name);

}

catch (NamingException e)

{

// ...

}

-


The IPage interface has a method getiViews(), which returns an Enumeration of the iViews within the page.

Enumeration en = page.getiViews();

while (en.hasMoreElements())

{

Binding bind = (Binding)en.nextElement();

Object obj = bind.getObject();

if (obj instanceof IPage)

{

// a page child

}

if (obj instanceof IiView)

{

// an iView child

}

}

Hope this helps.

Daniel

Former Member
0 Kudos

Well, I tried different ways, but I always have 1 problem: when I get a role, I can't get "in". Only when using the navigation nodes, I get content from within the roles, but I can't use this user-specific approach.

Is there a way to read the content of a role? I need to get access to the pages and iViews that lie in it.

So, what do I have to do to read a role's content?

I'm quite desperate...

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

Hi Tobias,

In your posts there seems 2 things you want to do:

(1) Find objects in a role.

The objects are just subcontexts within the role context, so you can do something like this:

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, Context.PCD_INITIAL_CONTEXT_FACTORY);

env.put(Context.SECURITY_PRINCIPAL, request.getUser());

env.put(Constants.REQUESTED_ASPECT, IPcdAttribute.PERSISTENCY_ASPECT);

InitialContext iCtx = null;

try {

iCtx = new InitialContext(env);

IPcdContext myPcdContext = (IPcdContext) iCtx.lookup("");

javax.naming.NamingEnumeration myEnum = myPcdContext.search("portal_content/DanielContent/DanRole",null);

}

This returns an enumeration of javax.naming.SearchResult objects, which are the worksets, pages and iViews in the role. You would have to continue to traverse the PCD tree -- that is, do a search of each of these objects to get all the pages and iViews inside these.

(2) Find all objects based on a specific portal component. You could do a similar thing by searching but with attribute filters, something like this:

javax.naming.directory.Attributes myAttrs = new javax.naming.directory.BasicAttributes();

myAttrs.put("com.sap.portal.private.iview.PropertiesUrl","pcd:com.sap.portal.system/applications/HelloWorldProject/components/HelloWorld");

myEnum = myPcdContext.search("portal_content",myAttrs);

The first problem with this is that it only searches the current level. There are other standard JNDI search methods that allow you to specify that you want to search all subnodes, but I have not been able to get it to work for PCD.

The second problem is that I cannot search on CodeLink (which is a PCM attribute) -- I can only search on PCD attributes. So I searched on com.sap.portal.private.iview.PropertiesUrl, but I am not sure this is reliable.

Daniel

Former Member
0 Kudos

Hi Daniel,

I didn't know IPcdContext - and therefor not its "search" method - thank you!

But I don't understand the entries in the hashtable. They seem to influence what kind of an object I get, but the PCD documentation doesn't tell me anything concrete. Where did you get the information about its usage?

Now my problem ist, that I get strange objects from your myEnum Enumeration. When I cast them to IPcdSearchResult and then do searchResult.getClassName(), it says IPortalIview. That would be great, but I don't get that IPortalIview object! I can't cast it and searchResult.getObject() always returns null. The searchResult has Attributes which contain some, but not all properties of the iView! For example, CodeLink is missing as well as one of my own properties (only its description is available!).

How do I get the real iView objects (IPortalIview)?

And if someone has knows about some real documentation, I would be very grateful!

(

https://media.sdn.sap.com/javadocs/NW04/SP12/pcd/com/sapportals/portal/pcd/gl/IPcdAttribute.html#PER... doesn't help... how am I supposed to learn this?)

Tobias

Answers (1)

Answers (1)

Former Member
0 Kudos

When I access a page in the role directly via jndi-lookup, I find its iViews.

The problem is: when I traverse the PCD, I never get that deep, for roles block the access to their children.

Is there a way to get all iViews with a specific CodeLink from the PCD without traversing it?