cancel
Showing results for 
Search instead for 
Did you mean: 

Using PCD API

Former Member
0 Kudos

Hello,

Can I use the PCD API to do any of the following:

1. search for all iviews that use the appintegrator par file

2. search for all iviews that use a specific system in the portal SLD

I highly appreciate anyones help. Thanks!

Roaa

Accepted Solutions (1)

Accepted Solutions (1)

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

Hi Roaa,

You can search for all iViews based on the app integrator application, like so:

-


Hashtable env = new Hashtable();
 
env.put(Context.INITIAL_CONTEXT_FACTORY, IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
env.put(Constants.REQUESTED_ASPECT, IPcdAttribute.PERSISTENCY_ASPECT);
env.put(Context.SECURITY_PRINCIPAL, request.getUser());
 
InitialContext iCtx = null;
String roleID = "pcd:portal_content/MyFolder";
		
try{
    iCtx = new InitialContext(env);

    IPcdContext attrSet = (IPcdContext) iCtx.lookup(roleID);

    PcdSearchControls cons1 = new PcdSearchControls();
    cons1.setReturningObjFlag(true); 

    cons1.setSearchScope(PcdSearchControls.SUBTREE_SCOPE);
    NamingEnumeration ne1 = attrSet.search("", "(com.sap.portal.private.iview.PropertiesUrl=pcd:com.sap.portal.system/applications/com.sap.portal.appintegrator.sap/components/Generic)", cons1); 

}
catch{}

-


Hope this helps.

Daniel

Former Member
0 Kudos

I dont really understand the code.

Do you know of any documentation about this API?

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

Hi Roaa,

The code:

  • We create a Hashtable of information to tell JNDI (and eventually PCD) what type of lookup we are going to do:

--(1) Lookup in PCD

--(2) Return a generic PCD object (IPcdContext)

--(3) The user, because the lookup requires permissions

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

InitialContext iCtx = null;

PCD address of the object we want

String roleID = "pcd:portal_content/MyFolder";

Do lookup:

try{
    iCtx = new InitialContext(env);
 
    IPcdContext attrSet = (IPcdContext) iCtx.lookup(roleID);

Set some objects that will let us search for other objects within the context we just looked up. Check the PCD Javadocs for more info.

    PcdSearchControls cons1 = new PcdSearchControls();
    cons1.setReturningObjFlag(true); 
 
    cons1.setSearchScope(PcdSearchControls.SUBTREE_SCOPE);

Search the context, and return a NamingEnumeration of objects. The objects depend on the Aspect we defined above. IPcdAttribute.PERSISTENCY_ASPECT returns IPcdContext objects; SEMANTIC_ASPECT would return the corresponding semantic object -- IiView for an iView, IPage for a page, and so forth

NamingEnumeration ne1 = attrSet.search("", "(com.sap.portal.private.iview.PropertiesUrl=pcd:com.sap.portal.system/applications/com.sap.portal.appintegrator.sap/components/Generic)", cons1); 
 
}
catch{}

There is some documentation about doing lookups to find semantic objects at http://help.sap.com/saphelp_nw04/helpdata/en/70/4aa042a5deb611e10000000a155106/frameset.htm.

Check the PCD Javadocs for documentation about the PCD -- there is no other documentation on PCD.

Hope this helps.

Daniel

Former Member
0 Kudos

Thanks for the explanation. I'll try this code out and hopefully it will work for me.

Roaa

Former Member
0 Kudos

I am getting a ClassCastException in this line

IPcdContext attrSet = (IPcdContext) iCtx.lookup(roleID);

Any suggestions to why that is?

Roaa

Former Member
0 Kudos

Hi Roaa Bahran,

Class cast Exception is because you dont have the entry in your portalapp.xml

Add like this..in ur portalapp.xml..

<application-config>

<property name="startup" value="true"/>

<property name="SharingReference" value="htmlb,com.sap.portal.pcd.glservice,com.sap.portal.pcmbuilderservice,usermanagement" />

<property name="ServicesReference" value="com.sap.portal.ivs.api_iview, com.sap.portal.ivs.api_landscape"/>

</application-config>

Let me know if you need more help on this.

Hope it helps.

Regards,

Karthick K Eswaran

Former Member
0 Kudos

Hi,

Actually adding "com.sap.portal.pcd.glservice" in your portalapp.xml is only enough to get rid of the current exception.

Add the other service and sharing references for your future implementations.

Hope it helps.

Regards,

Karthick K Eswaran

Former Member
0 Kudos

Dear Karthick,

i have the same ClassCastException in a WebDynpro-Application but how can i add such a "sharing"-Reference here, cause there is no portalapp.xml-File

Thanks.

Best regards

André

Former Member
0 Kudos

in the project properties go to Web Dynpro References -> Sharing References and enter:

PORTAL:com.sap/com.sap.portal.pcd.glservice

Former Member
0 Kudos

Hi Rui,

thanks. I do this, but in my WebDynpro application this coding:

Object pcdObject = InitialCtx.lookup(strPcdLookupPath);
IPcdContext iPcdObject = (IPcdContext)pcdObject;

throw an ClassCastException.

I the debugger i see that the pcdObject is of Type

com.sapportals.portal.pcd.gl.PcdGlDeltaLink

.

What can i do do solve this problem ?

Thanks.

Best regards

André

Former Member
0 Kudos

Hi,

I got the same exception in my application.

Can you please how did you come out of this exception in your application.

Thank you,

Sandeep kumar b

Former Member
0 Kudos

Hi Sandeep,

i was not able to solve this problem... So it was a hard desission but i have to kick out the webdynpro and created a pure portal-component with an jsp-iView. Much more time to spend on the UI as in WD but the date we have to be finish with our application comes closer and closer.

What's confusing me ist, that in a "normal" portal-application there is no classcast-Exception within the same code....

Best regards,

André

Answers (3)

Answers (3)

Former Member
0 Kudos

Sorry for my "test" above.

I have also problems with "Looking Up Objects" in my Portal Application (http://help.sap.com/saphelp_nw04/helpdata/en/1f/ec5c42da4de92ce10000000a1550b0/content.htm). I get a ClassCastException (IiView - AttributeSetiView). I am using SAP NetWeaver 2004 SP16 (Java TrialVersion). What is the solution?

My portalapp.xml:

<?xml version="1.0" encoding="utf-8"?>

<application>

<application-config>

<property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>

<property name="startup" value="true"/>

<property name="SharingReference" value="htmlb,com.sap.portal.pcd.glservice,com.sap.portal.pcmbuilderservice,usermanagement" />

<property name="ServicesReference" value="com.sap.portal.ivs.api_iview, com.sap.portal.ivs.api_landscape"/>

</application-config>

<components>

<component name="FirstPage">

<component-config>

<property name="ClassName" value="procwp.FirstPage"/>

<property name="ComponentType" value="jspnative"/>

<property name="JSP" value="pagelet/FirstPage.jsp"/>

<property name="ResourceBundleName" value="firstPage"/>

</component-config>

<component-profile/>

</component>

</components>

<services/>

</application>

Martin

Former Member
0 Kudos

I found the solution myself:

<property name="PrivateSharingReference" value="com.sap.portal.ivs.iviewservice, com.sap.portal.htmlb"/>

regards, Martin

Former Member
0 Kudos

test

Former Member
0 Kudos

<a href="https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3057">This blog</a> describes a mechanism for displaying the details of a system in a tree structure, which could help you with part 2 of your question.

For part 1, you could try to use the multiple property replacement function to search for iViews that contain the current value pcd:com.sap.portal.system/applications/com.sap.portal.appintegrator.sap/components/Generic. You will need to pretend to be changing the contents - stop before you actually do the change...

Cheers