Showing results for 
Search instead for 
Did you mean: 

How to get the Roles list?

Former Member
0 Kudos

Hi all,

I want to get the all Roles that existing on my portal.

Thanks a lot for your help!

Maya Shtibel.

View Entire Topic
Former Member
0 Kudos

Sorry, I meant how can I sort the list?

Active Contributor
0 Kudos

Hi Maya,

	IWDMessageManager messageManager = wdComponentAPI.getMessageManager();
    try {
		IRoleFactory roles = UMFactory.getRoleFactory();
		IRoleSearchFilter filter = roles.getRoleSearchFilter();
		filter.setUniqueName("*", ISearchAttribute.LIKE_OPERATOR, false);
		ISearchResult sresult  = roles.searchRoles(filter) ;

		TreeSet visibleRoles = new TreeSet(new RoleNameComparator());

		if ( sresult.getState() == ISearchResult.SEARCH_RESULT_OK ) {
			while(sresult.hasNext()) {
				String id = (String);
				IRole role = roles.getRole(id);
    } catch (Exception e) {
		messageManager.reportException(new WDNonFatalException(e), false);
public class RoleNameComparator
    implements Comparator

    public RoleNameComparator()

    public int compare(Object o1, Object o2)
        IPrincipal role1 = (IPrincipal)o1;
        IPrincipal role2 = (IPrincipal)o2;
        int res = role1.getDisplayName().compareToIgnoreCase(role2.getDisplayName());
        if(0 == res)
            return role1.getUniqueID().compareToIgnoreCase(role2.getUniqueID());
            return res;

Mark usefull answers and close the thread in case your problem is solved.

Best regards, Maksim Rashchynski.