Skip to Content
Having watched the Enterprise Portal Content Development forum for over a year, I’ve noticed that one of the biggest topics is the PCD (Portal Content Directory). Developers ask such things as:

  • How do I create PCD objects?
  • How do I check a user’s permission for a specific PCD object?
  • What Java interfaces can I get for a PCD object?
  • How do I create a portal page, or change a page’s layout?
  • How do I retrieve a PCD object’s attributes, and how do I change them?
  • How do I get a personalized view of a PCD object?

This is just a sample of the questions I’ve read here. One reason there are so many questions is that there never has been complete documentation for the PCD (except for the Javadocs), as well as for related topics like PCM — more on PCM later. In response, I’ve decided to do 2 things: create formal documentation on the PCD, and to write a series of blogs highlighting some of the key features and perhaps lesser-known tips.

What Happens During a PCD Lookup?

When I was a kid, I loved taking things apart (but, like Humpty Dumpty’s men and horses, I wasn’t so great at putting things back together again). With the PCD, I wanted to see what happens under the hood. So the first thing I asked the developers here was, “What actually happens when I do a lookup?” Here is a standard piece of code for looking up an iView object in the PCD:


import com.sap.portal.directory.Constants; import com.sap.portal.pcm.admin.PcmConstants; import com.sap.portal.pcm.iview.IiView; import com.sapportals.portal.pcd.gl.IPcdContext; import com.sapportals.portal.prt.jndisupport.InitialContext; Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,    IPcdContext.PCD_INITIAL_CONTEXT_FACTORY); env.put(Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_SEMANTICS); env.put(Context.SECURITY_PRINCIPAL, request.getUser()); //env.put(IPcdContext.PCD_PERSONALIZATION_PRINCIPAL, request.getUser()); InitialContext iCtx = null; String myObject = "portal_content/MyFolder/MyObject"; try {    iCtx = new InitialContext(env);    IiView myIView = (IiView)iCtx.lookup(myObject); catch (Exception e) { }


What I learned was that when executing this code, the following occurs: image

  1. Making the Call: A component makes a JNDI call, specifying the PCD as the intial context, the aspect, a user, and a PCD name or address. A personalization principal may also be specified, so that the information returned is the personalized information for a specific user (in the sample above, the environment variable for setting a personalization principal is shown in comments).
  2. Validating the PCD Name: The PCD generic layer checks whether the user has permission to execute the lookup, and whether the PCD name is valid. If the aspect is the PCD persistency aspect, then the PCD returns an IPcdContext object, and the process ends.
  3. Getting the Object Factory: Otherwise, the PCD checks the object class of the object, and gets the object factory for the object class.
  4. Checking the Aspect: Though an object factory is not required to check the aspect, the object factories for standard portal objects (such as roles, pages and iViews) return different objects based on the aspect. If the administration aspect is specified, than an IAdminBase object is created. If the semantic aspect is specified, than the Java object for the specified PCD object is created, such as an IiView object for an iView and an IPage object for a page.
  5. Returning the Object: Finally, the object is returned to the caller, who must cast it to the correct object type.

PCD Generic Layer (GL)

The PCD GL is a JNDI provider for the PCD, but with several special features, for example, delta links, which enable a PCD context to inherit its attributes from another context. Personalization, which works similarly to delta links, enables a user to have a special view of PCD objects. For a specific object, the PCD can store a different set of attributes for each user.

Aspects

An aspect is, essentially, a parameter that you can pass to the object factory when performing a lookup, and that the object factory can use to determine the type of object to return. If you pass the PCD persistency aspect, then the PCD returns an IPcdContext object and does not turn to the object factory. Any other aspect is passed to the object factory. For portal objects, there are two main aspects:

  • Semantic: Returns the corresponding Java object for the PCD object. An iView returns IiView, a page IPage, a layout ILayout, and so forth.
  • Administration: This aspect returns a generic interface — IAdminBase — for all portal objects. From this interface can be derived other generic interfaces.

Units

PCD objects are grouped into units — mostly for internal and performance reasons, for example, database access is done in units. And, therefore, many activities can only be performed on units. A unit is a semantic object that is not contained in any other semantic object. Or put another way, a unit is a semantic object whose parent hierarchy only contains folders. A unit contains the semantic object, plus all the semantic objects inside it. So a page in a standard PCD folder is a unit, and the unit includes the page and all the iViews inside it. Only unit objects can be given permissions. All non-unit objects inherit permissions from their unit object. For example, an iView in a page inherits its permission from the page. Delta links can only be created from unit objects, and you can only transport unit objects.

What’s Coming Up …

This series will include the following additional blogs:

  • Creating Portal Objects: A short tutorial on how to create basic portal objects, like iViews and pages.
  • Portal Content Model (PCM): A set of administration interfaces that provides a single generic layer for working with all portal objects — even if they do not reside in the PCD.
  • Permissions: How to check and set permissions, and what types of permissions exist.
  • Delta Links and Personalization: What are delta links and personalzied objects, and what APIs exist to work with them.

The new PCD documentation, Accessing the PCD, will be available on the Help Portal in the portal developer guide, starting with SAP NetWeaver 2004 SP Stack 18 in late August. For those who can’t wait, click here for a version now available on SDN. Also check out the very good PCD Javadocs, especially the package description for the com.sapportals.portal.pcd.gl. And, finally, look at the PCD Knoweldge Center for additional resources.  

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply