Skip to Content
0
Feb 02, 2009 at 06:49 PM

Find the iViews, Pages and Folders assigned to Role

20 Views

Hi,

Does any one has the idea about how to retrieve the worksets, pages and iviews assigned to a role.

I found a piece of code that will retrieve the roles, worksets, pages and iviews from PCD.

Here is the code, that is to retrieve the roles, worksets, pages and iviews from PCD

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);

env.put(Context.SECURITY_PRINCIPAL, WDClientUser.getCurrentUser().getSAPUser());

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

InitialContext initialContext = null;

DirContext dirCtx;

initialContext = new InitialContext(env);

dirCtx = (DirContext) initialContext.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);

// Gets the full path of the iViews from the PCD

NamingEnumeration ne = dirCtx.search("","(com.sap.portal.pcd.gl.ObjectClass=com.sapportals.portal.iview)", pcdSearchControls);

while (ne.hasMoreElements())

{

IPcdSearchResult searchResult = (IPcdSearchResult) ne.nextElement();

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

wdComponentAPI.getMessageManager().reportSuccess("View ="+location);

}

// Gets the full path of the pages from the PCD

NamingEnumeration nePage = dirCtx.search("","(com.sap.portal.pcd.gl.ObjectClass=com.sapportals.portal.page)",pcdSearchControls);

while (nePage.hasMoreElements())

{

IPcdSearchResult searchResult = (IPcdSearchResult) nePage.nextElement();

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

wdComponentAPI.getMessageManager().reportSuccess("Page ="+location);

}

// Gets the full path of the worksets from the PCD

NamingEnumeration neWorkSet = dirCtx.search("","(com.sap.portal.pcd.gl.ObjectClass=com.sapportals.portal.workset)",pcdSearchControls);

while (neWorkSet.hasMoreElements())

{

IPcdSearchResult searchResult = (IPcdSearchResult) neWorkSet.nextElement();

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

wdComponentAPI.getMessageManager().reportSuccess("WorkSet ="+location);

}

But my requirements is, if I have the role as "Sales Role", I want to find the iViews, Pages and worksets assinged to this role.

Your help is really appreciated.

Thanks in Advance,

Chinna.