Skip to Content
0
Former Member
Dec 03, 2008 at 07:05 AM

Fetching all iviews from PCD

48 Views

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);

}

}

}

}