cancel
Showing results for 
Search instead for 
Did you mean: 

Fetching all iviews from PCD

Former Member
0 Kudos

Hi, I am using the following code to fetch all iviews from pcd but still getting errors in the bold lines.

1. I have imported the following jars

import java.util.Hashtable;

import java.util.List;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingEnumeration;

import javax.naming.directory.DirContext;

import com.sapportals.htmlb.page.DynPage;

import com.sapportals.htmlb.page.PageException;

import com.sapportals.portal.htmlb.page.PageProcessorComponent;

import com.sapportals.portal.pcd.gl.IPcdContext;

import com.sapportals.portal.pcd.gl.IPcdSearchResult;

import com.sapportals.portal.pcd.gl.PcdSearchControls;

import com.sapportals.portal.prt.component.IPortalComponentProfile;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.prt.component.IPortalComponentResponse;

import com.sapportals.portal.prt.component.IPortalComponentSession;

import com.sapportals.htmlb.*;

2.Modified the portalapps.xml as

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

<application>

<application-config>

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

<property name="SharingReference" value="com.sap.portal.pcd.glservice"/>

</application-config>

<components>

<component name="pcdtest">

<component-config>

<property name="ClassName" value="com.shell.epp.pcdtest.pcdtest"/>

</component-config>

<component-profile/>

</component>

</components>

<services/>

</application>

but still getting errors in the highlighted lines

-


dirCtx.addToEnvironment(

Constants.APPLY_ASPECT_TO_CONTEXTS,

Constants.APPLY_ASPECT_TO_CONTEXTS

)

-


env.put(

com.sap.portal.directory.Constants.REQUESTED_ASPECT,

PcmConstants.ASPECT_SEMANTICS

)

-


public void doProcessBeforeOutput() throws PageException {

Form myForm = this.getForm();

IPortalComponentRequest request =

(IPortalComponentRequest) this.getRequest();

IPortalComponentSession session = request.getComponentSession();

IPortalComponentProfile prof =

request.getComponentContext().getProfile();

IPortalComponentResponse response =

(IPortalComponentResponse) this.getResponse();

}

public List getPCDContents(IPortalComponentRequest request)

throws Exception {

try {

Hashtable env = new Hashtable();

env.put(IPcdContext.SECURITY_PRINCIPAL, request.getUser());

env.put(

Context.INITIAL_CONTEXT_FACTORY,

IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);

env.put(

com.sap.portal.directory.Constants.REQUESTED_ASPECT,

PcmConstants.ASPECT_SEMANTICS);

InitialContext ctx = null;

DirContext dirCtx;

List iViewList = null;

ctx = new InitialContext(env);

dirCtx = (DirContext) ctx.lookup("pcd:portal_content/");

PcdSearchControls pcdSearchControls = new PcdSearchControls();

pcdSearchControls.setReturningObjFlag(false);

pcdSearchControls.setSearchScope(

PcdSearchControls.SUBTREE_WITH_UNIT_ROOTS_SCOPE);

dirCtx.addToEnvironment(

Constants.APPLY_ASPECT_TO_CONTEXTS,

Constants.APPLY_ASPECT_TO_CONTEXTS*);

NamingEnumeration ne =

dirCtx.search(

"",

"(com.sap.portal.pcd.gl.ObjectClass=com.sapportals.portal.iview)",

pcdSearchControls);

iViewList = new ArrayList();

while (ne.hasMoreElements()) {

IPcdSearchResult searchResult =

(IPcdSearchResult) ne.nextElement();

String location =

"pcd:portal_content/" + searchResult.getName();

// Get the full pcd path of the iview.

iViewList.add(location);

}

return iViewList;

} catch (Exception e) {

throw new Exception(e);

}

}

}

}

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Nikhil,

I searched for this particular .jar in the browser but couldn't find it.Can you let me know where from can I download this .jar.

Thanks:-)

Former Member
0 Kudos

Hi Ranjan,

You can dowload tcepbcpcmadminapijava.jar file from the given location on portal server.

\j2ee\cluster\server0\bin\ext\tcepbcpcmadminapijava

I didn't got where you are browsing to download the file.

Regards,

Nikhil

Former Member
0 Kudos

Hi Nikhil,

Thanks for ur help,the second error is gone but I am not getting the jar for the ist error.Can u help me pls.?

Former Member
0 Kudos

Hi Ranjan,

Add tcepbcpcmadminapijava.jar file to project.

You can find jar on the server at \j2ee\cluster\server0\bin\ext\tcepbcpcmadminapijava.

Regards,

Nikhil

PS: Do not forget to award points

Former Member
0 Kudos

Hi Nikhil,

Thanks for your reply,pls. chk the import packages as under,the error that iam getting is "constants can not be resolved","pcmConstant can not be resolved"

import java.util.Hashtable;

import java.util.List;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingEnumeration;

import javax.naming.directory.DirContext;

import com.sap.portal.directory.Constants;

import com.sapportals.htmlb.page.DynPage;

import com.sapportals.htmlb.page.PageException;

import com.sapportals.portal.htmlb.page.PageProcessorComponent;

import com.sapportals.portal.pcd.gl.IPcdContext;

import com.sapportals.portal.pcd.gl.IPcdSearchResult;

import com.sapportals.portal.pcd.gl.PcdSearchControls;

import com.sapportals.portal.prt.component.IPortalComponentProfile;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.prt.component.IPortalComponentResponse;

import com.sapportals.portal.prt.component.IPortalComponentSession;

import com.sapportals.htmlb.*;

ERROR LINES:

1.env.put(com.sap.portal.directory.Constants.REQUESTED_ASPECT,PcmConstants..ASPECT_SEMANTICS);

2.dirCtx.addToEnvironment(Constants.APPLY_ASPECT_TO_CONTEXTS,Constants.APPLY_ASPECT_TO_CONTEXTS);

Former Member
0 Kudos

Hi Rajan,

Solution for error Line 1: import com.sap.portal.pcm.admin.PcmConstants; in your file.

Solution for error Line 2: Replace dirCtx.addToEnvironment(Constants.APPLY_ASPECT_TO_CONTEXTS,Constants.APPLY_ASPECT_TO_CONTEXTS);

with

dirCtx.addToEnvironment(com.sap.portal.directory.Constants.APPLY_ASPECT_TO_CONTEXTS,com.sap.portal.directory.Constants.APPLY_ASPECT_TO_CONTEXTS);

Please check this and let me know if it works.

Regards,

Nikhil

Former Member
0 Kudos

Hi Nikhil,

I downloaded the jar that u have mentioned but still I am getting errors in the above highlighted lines.Pls. help me in this regard.

Former Member
0 Kudos

Hi Ranjan,

After dowloading the jar file, I hope you have followed these steps:

1. In NWDS add the Jar file file to your project from Java Build Path-> Libraries -> Add Jars.

2. Then go to code and import com.sap.portal.directory.Constants

This should resolve your problem. If it will not resolve then let me know the exact error message you are getting on those highlighted lines.

Good Luck

Nikhil

Former Member
0 Kudos

Hi Ranjan,

You have to use prtjndisupport.jar to resolve Constants.

import com.sap.portal.directory.Constants;

You can find this Jar on Server at location

/usr/sap/J2E/JC00/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-inf/lib/prtjndisupport.jar

Download it and add it to your local project.

Check and revert back.

Regards,

Nikhil