Skip to Content
Author's profile photo Sandip Agarwalla

Retrieve Portal Objects from PCD in 7.3 Version !!!

This blog shows how to retrieve PCD Objects (iViews/Pages/Roles etc) from a PCD Folder on the Portal 7.3 version using Custom Java Code.

First some Concepts – The Portal Content Directory (PCD) is the main repository for portal content, both delivered with the portal and created by administrators. The PCD contains a hierarchy of folders, each of which can contain semantic objects, such as iViews, pages and roles. The PCD is stored in the portal database and is accessed via the PCD Generic Layer (GL), and provides APIs to enable applications to perform look ups and modify the PCD Objects.

Each provider defines the logic for returning Java objects when querying a specific portal semantic object. A semantic object is defined by its property.  When a lookup is performed on an object, the PCD checks the object class attribute to determine which object provider to use for creating/Editing a Java object from the set of attributes.Below table shows the respective GL property for different Semantic Objects like iViews, Pages etc

PCD Object GL Property Name
iViews com.sapportals.portal.iview
Roles com.sapportals.portal.role

The below diagram shows the Process Flow when you do a look up on the PCD

18-Jul-12 1-52-35 PM.jpg

Source for the Above Section**: SAP Materials and SAP Help Web Sites

Ok then, enough of Concepts. Lets straight way dive into the source code. Here are the steps.

1) Create the custom DC project

     Create and set up a custom DC thru NWDS. In my case, its a WD Java DC, but you can very well use PDK/JAVA EE DC


2) Add the DC dependency for JAR files for PCD GL, JNDI etc APIs

     Open up Development Infrastructure Perspective, locate your DC and open up the DC Component Properties. Then Click on “Dependecies” Tab.

     Add the required DCs by clicking on ADD button. The JAR DCs you would need for referencing the PCD GL, JNDI etc are highlighted in the right hand side Image.



3) Source Code to retrieve Objects

     Add the following source code in the Java class


          IUser usr = UMFactory.getUserFactory().getUserByLogonID("Test_Admin");         
          Hashtable env = new Hashtable();
          env.put(Context.SECURITY_PRINCIPAL, usr);
          env.put(Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_SEMANTICS);         
          InitialContext ctx = null;         
          List<String> iViewList =null;       
          DirContext dirCtx = null;
          ctx = new InitialContext(env);
          //IAdminBase result =(IAdminBase)ctx.lookup(objectName);
          dirCtx = (DirContext) ctx.lookup("pcd:portal_content/test_pcd");
          //set the search controls to find only the iviews         
          PcdSearchControls pcs = new PcdSearchControls();
          NamingEnumeration<SearchResult> ne;       
          //ne ="","(",pcs);         
          ne ="","(",pcs);
         // fetching iviews       
          iViewList = new ArrayList<String>();
              IPcdSearchResult searchResult = (IPcdSearchResult)ne.nextElement();
              String location = "pcd:portal_content/test_pcd/" + searchResult.getName();
              //Get the full pcd path of the iview.
          } catch (NamingException e) {
//            // TODO Auto-generated catch block
              wdComponentAPI.getMessageManager().reportSuccess("Look Up Error::"+e.getMessage());
          catch (Exception e1){

4) Validation of Results

    A quick check to see if the code really gets all the iViews from the specified folder including sub folders as well


And, here we go – we could successfully fetch the iViews from the specified Folder. The Source Code can be extended to fetch Pages/Roles as well by modifying the ObjectClass property to Page or Role

Hope the blog would be useful to you. Comments/Suggestions are welcome…

Sandip Agarwalla

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Simon Kemp
      Simon Kemp

      Thanks for taking the time to share Sandip. Just one question, what have you used this for in the past? Can you imagine what you might do once you have read the data from the PCD?

      Btw... did you mean to create this as a document or a blog post?


      Author's profile photo Sandip Agarwalla
      Sandip Agarwalla
      Blog Post Author

      Hey Simon

      Initially, I wanted to create this as a Wiki link. However found it difficult to navigate to the proper wiki page where it should be created. so finally created as a blog (simple and easy).

      On the use case - well I didnt have any scenario when I wrote this. In the past, there have occasions where Clients had asked for such functionality to build custom Portal Content Admin screens (dnt exactly remember the scenario). I know there are alternates, this is just one of them..



      Author's profile photo Simon Kemp
      Simon Kemp

      Hi Sandip... I guess I was just a bit confused why your "blog" wasn't showing up in the blog stream I think it is because you created a "document" not a "blog post". No big deal, just wondering if that is what you intended 🙂

      Again thanks for sharing and also for giving some context as to why someone might want to do this. I guess another scenario might be if you wanted to be able to programmatically create PCD content - basically automating the job of the portal admin - OMG!... now I am out of a job! 😛

      Thanks again,


      Author's profile photo Sandip Agarwalla
      Sandip Agarwalla
      Blog Post Author

      Mate, Well - we will not share the code to create/editing/permission objects 😉 ..And introduce few bugs in the code...There by Securing our Jobs !!! Mine is also at stake, am with you 😎

      Ya now I realized what you mean. Looks like I published it as a document instead of a blog..Thats why its not showing in the blog stream..Wondering should I re-create it as a blog again..Or can the moderator move it to the blog section.

      By any chance, are you the Moderator 😕

      Jason Lax - Hey Jason, can you help on this? I intended to post this as a blog but end up doing a document (Tell you man this new SCN Platform)...Is there a way we can migrate this as a Blog..Who is the moderator of this Group?



      Author's profile photo Simon Kemp
      Simon Kemp

      Leave it where it is, no big deal. Not really sure of the difference between a Blog Post and a Document on this new SCN anyway 😆 . I just reflected on the fact that I didn't see it in the Blog stream which I follow.

      Author's profile photo Jason Lax
      Jason Lax

      It's impossible to migrate content between content type. Generally you have to delete and repost.

      However, looking at what you have here, this should be a document and doesn't fit the blog format.  Perhaps you should just change your intro so it doesn't say 'This blog' at the beginning. For more information, please see The Difference Between a Discussion, Blog Post, Document and Wiki.