cancel
Showing results for 
Search instead for 
Did you mean: 

Find the iViews, Pages and Folders assigned to Role

chinna_babu2
Active Participant
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

sanyev
Active Participant
0 Kudos

Hi Chinna Babu,

I guess what you need is there in this blog. [https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2080] [original link is broken] [original link is broken] [original link is broken];. The blog is for a portal application. I should not be difficult to refactor it for Webdynpro application. Here he uses the user initially to get the roles assinged to the user. Once he gets the roles then its your requirement.

Regards,

Sanyev

Answers (0)