Skip to Content
0
Former Member
Nov 14, 2011 at 08:24 AM

Finding recursively the iViews assigned to a Role - Portal Component

29 Views

Hi,

I am trying to make a Portal Component where in I need to know what iViews are assigned to any particular role in a recursive manner.

Currently by using the following code I can search the iViews recursively in the portal_content folder structure but not in the roles,

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 = searchResult.getName();
	iViewList.add(location);
}

Iterator i = iViewList.iterator();

while(i.hasNext())
{
	response.write("<br />" + i.next().toString());
}

I need to find the iviews that are currently assigned to a particular role for which PCD path can be given at the time of making the iVIew from this component.

Please let me know how to go about this.

Regards,

Saurabh Agarwal