cancel
Showing results for 
Search instead for 
Did you mean: 

Read properties of a PCD Folder

former_member248853
Discoverer
0 Kudos

Hi,

I am trying to read properties of PCD folder in my code. However, except the title, the API returns "null" for all other properties Example: property for ID, Merge ID, etc..

I tried using the IAdminBase object, but does not work due to the casting issue from IPCDContext to IAdminBase. Hence I am using IPcdContext for reading values.

I am able to successfully read properties for other objects such as iViews, Worksets, roles.

Is this a standard behavior or am I missing anything in my code.

Existing code:

Hashtable ht = new Hashtable(); 
ht.put(Context.INITIAL_CONTEXT_FACTORY, IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
ht.put(Context.SECURITY_PRINCIPAL, request.getUser());
ht.put(Constants.REQUESTED_ASPECT, IPcdAttribute.PERSISTENCY_ASPECT);

InitialContext initCtx =  new InitialContext(ht);
DirContext dirCtx = (DirContext) initCtx.lookup("<Path to PCD Folder");
dirCtx.addToEnvironment(Constants.APPLY_ASPECT_TO_CONTEXTS, Constants.APPLY_ASPECT_TO_CONTEXTS);
PcdSearchControls pcs = new PcdSearchControls();
pcs.setReturningObjFlag(false);
pcs.setSearchScope(PcdSearchControls.SUBTREE_WITH_UNIT_ROOTS_SCOPE);

NamingEnumeration neSrch1 = dirCtx.search("", "(com.sap.portal.pcd.gl.ObjectClass=com.sap.portal.pcd.gl.GlContext)", pcs); 

while (neSrch1.hasMoreElements()) { 
IPcdSearchResult searchResult = (IPcdSearchResult) neSrch1.nextElement();  
String location = "<existing location>/" + searchResult.getName(); 
IPcdContext pcdCtx = (IPcdContext) initCtx.lookup(location); 
Object obj = pcdCtx.getAttributes("").get("com.sap.portal.pcm.Title"); 
if(obj instanceof IPcdAttribute){ 
IPcdAttribute pcdAttr = (IPcdAttribute) obj;
String folderName = pcdAttr.get(new Locale("EN")); 
response.write("<-->Name of WPC Folder: "+folderName+"<br>"); 
}
}

Accepted Solutions (0)

Answers (2)

Answers (2)

cristiano_mazzotti
Active Participant

Hi Twisha,

Please check this API link: https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/EP/com/sap/portal/pcm/attributes/package-su...

There you will find interfaces that contains constants with the valid attribute names for each type of portal object. There is no specific interface for the folder object, so I believe that IAttrPcmGeneral and IAttrPcmGeneralValues should be used. Maybe IAttrPcmNavigation values could work too.

IAttriViewAn: interface that defines constants for iView attribute names.

IAttriViewValues: An interface that defines the valid values for iView attributes.

IAttrLaunchValues: An interface that defines valid values for the attributes of launchable objects.

IAttrLayout: An interface that defines constants for layout attribute names.

IAttrPage: An interface that defines constants for attribute names for a page.

IAttrPageValues: An interface that defines constants for attribute values for a page.

IAttrPcmGeneral: Defines general PCM object attribute names.

IAttrPcmGeneralValues: Defines valid values for general PCM object attributes.

IAttrPcmLaunch: An interface that defines names of attributes for runnable objects.

IAttrPcmNavigation: An interface that defines constants for navigation-related attribute names.

former_member248853
Discoverer
0 Kudos

Hi Cristiano / Fabio,

Thanks for the reply. I tried using the API IAttrPcmGeneral, but get an error Cannot cast class com.sapportals.portal.pcd.gl.PcdGlContext to interface com.sap.portal.pcm.attributes.IAttrPcmGeneral while using the statement

IAttrPcmGeneral attrGeneral = (IAttrPcmGeneral) initCtx.lookup(location);

I even printed all the attributes which can be read using the IPcdContext and only title and object class properties are retrieved.

My aim is to read the properties such as ID, Merge ID, Sort & Merge Priorities for all PCD objects. But it is working for all other objects except com.sap.portal.pcd.gl.GlContext.

Please let me know if I am missing anything in the approach.

Thanks in advance

fabio_sarmento
Contributor

Hi Twisha Banerjee, I am going to import your code and check. Which property do you need to change in one folder other than the title? Can you clarify your need? A folder doesn't have mutch attributes. Regards, Fabio

former_member214651
Active Contributor
0 Kudos

Hi Fabio,

Sorry for the delay in response. I am trying to achieve the below requirement on SAP portal using Abstract Portal Component:

1. Search for a role within the portal content.

2. Loop thru the role and look for all the objects such as Folders, Worksets and iViews

3. Read individual properties of different type of iViews such as BI, WD ABAP, BSP, URL etc..

However with my existing code, I am only able to read the Title of each Object within the role and other values are displayed as null.

Kindly suggest.

Regards,

Poojith