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 com.sap.portal.pcd.gl.ObjectClass 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
The below diagram shows the Process Flow when you do a look up on the PCD
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
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
com.sap.portal.pcd.gl.ObjectClass=com.sapportals.portal.page
Hope the blog would be useful to you. Comments/Suggestions are welcome…
Sandip Agarwalla
Hi Sandip,
I am trying to run the code in NWDS 7.3 SP07 with Portal 7.3 , But I have got some problem with the code at line
PcdSearchControls pcs = new PcdSearchControls();
So I have also opend a blog http://scn.sap.com/thread/3245283,
Can you please help. I would like to see your program works for me.
I am actually trying to retrieve the worksets, Pages assigned to any given Portal role.
Appreciate you help with code so I can use.
Thank you
Regards
Maruti
Hi Sandip,
thank you for this article!
I tried your code in an Abstract Portal Component, but have currently several problems:
I can't use IPcdContext, PcdSearchControls and IPcdSearchResult, due to missing/ not recognized class-file.
Which JAR have you imported to use these classes?
I thought they are part of gl_api.jar (when I unzip it, there are such class-files inside), but NWDS cannot resolve it..
When i try to import the classes I get the following errors:
import com.sapportals.portal.pcd.gl.IPcdContext cannot be resolved
import com.sapportals.portal.pcd.gl.PcdSearchControls cannot be resolved
import com.sapportals.portal.pcd.gl.IPcdSearchResult cannot be resolved
Why can't they be resolved? Any ideas?
Regards,
Patrick
Patrick
which versiion of server you are using? Also have you created a local project (versions older to 7.3) or DC based project
if its a DC based development - you need the dc tc\epbc\pcd\gl\api
Thanks
Sandip
Hi Sandip,
thx for reply.
I am using 7.3 and want to deploy the project as an Abstract Portal Component. Might this be the problem?
Regards,
Patrick
Patrick
You can create an APC as well, shouldnt be a problem..
Just make sure you reference the correct DCs..with 7.3 - you need to use dc based projects..
Thanks for this great tutorial,
but when I use this code under a webDynPro application to display all folders under portal_content directory: I haven't all folders just few of them>
can you tell me why please
thanks in advance
Cheers
Bilel