Get list of Roles and users using the below code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.raylabs.bpm; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import oracle.bpel.services.bpm.common.IBPMContext; | |
import oracle.bpel.services.workflow.client.IWorkflowServiceClientConstants; | |
import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory; | |
import oracle.bpm.client.BPMServiceClientFactory; | |
import oracle.bpm.services.client.IBPMServiceClient; | |
import oracle.bpm.services.organization.IBPMOrganizationService; | |
import oracle.bpm.services.organization.model.ApplicationRoleType; | |
import oracle.bpm.services.organization.model.ApplicationRoles; | |
import oracle.bpm.services.organization.model.Organization; | |
import oracle.bpm.services.organization.model.PrincipleRefType; | |
public class Class1 { | |
private static String username; | |
private static String password; | |
private static String environment; | |
private static String serverPort; | |
private Class1() { | |
super(); | |
} | |
public static void main(String[] args) { | |
username="xxx"; | |
password="xxx"; | |
environment="dev"; | |
serverPort="7009"; | |
BPMServiceClientFactory wfSvcClient = null; | |
IBPMContext bpmCtx = null; | |
IBPMServiceClient bPMServiceClient = null; | |
try { | |
final Map connectionProperty = getConnProp(); | |
wfSvcClient = | |
BPMServiceClientFactory.getInstance(connectionProperty, | |
null, null); | |
bPMServiceClient = wfSvcClient.getBPMServiceClient(); | |
IBPMOrganizationService bpmOrgSvc = | |
bPMServiceClient.getBPMOrganizationService(); | |
bpmCtx = | |
(IBPMContext)wfSvcClient.getWorkflowServiceClient().getTaskQueryService().authenticate(null, | |
null, | |
null); | |
Organization org = bpmOrgSvc.exportOrganization(bpmCtx); | |
ApplicationRoles applicationRoles = org.getApplicationRoles(); | |
List<ApplicationRoleType> roleList = | |
applicationRoles.getApplicationRole(); | |
for (ApplicationRoleType role : roleList) { | |
System.out.println("Role name :" + role.getName()); | |
System.out.println("Identity context :"+role.getIdentityContext()); | |
System.out.println("List of users for the role :"); | |
List<PrincipleRefType> list = role.getMember(); | |
for(PrincipleRefType users:list){ | |
System.out.println(users.getType()+"-->"+users.getName()); | |
} | |
System.out.println("------------------------------------------"); | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} finally { | |
} | |
} | |
public static Map getConnProp() throws Exception { | |
final Map connProp = new HashMap(); | |
try { | |
connProp.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_INITIAL_CONTEXT_FACTORY, | |
"weblogic.jndi.WLInitialContextFactory"); | |
connProp.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL, | |
"t3://"+environment+".abc.com:"+serverPort); | |
connProp.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_PRINCIPAL, | |
username); | |
connProp.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_CREDENTIALS, | |
password); | |
connProp.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.CLIENT_TYPE, | |
WorkflowServiceClientFactory.REMOTE_CLIENT); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
return connProp; | |
} | |
} |
Libraries
No comments:
Post a Comment