Using BEPL APIs one can programmatically perform actions on a OIM request. Below is an example of the same.
1. Create a project in eclipse.
2. Copy the below jars from servers
[WL_HOME]/server/lib/weblogic.jar
[SOA_HOME]/soa/modules/oracle.soa.fabric_11.1.1/bpm-infra.jar
[SOA_HOME]/soa/modules/oracle.soa.fabric_11.1.1/fabric-runtime.jar
[SOA_HOME]/soa/modules/oracle.soa.workflow_11.1.1/bpm-services.jar
[WL_HOME]/server/lib/wlfullclient.jar
[OIM_HOME]/server/ext/spml/wsclient_extended.jar
3. Set the above jars in your project classpath
4. Use the below code in your project.
import java.util.logging.Logger;
import oracle.bpel.services.workflow.client.config.RemoteClientType;
import oracle.bpel.services.workflow.client.config.RemoteClientType.Password;
import oracle.bpel.services.workflow.client.config.ServerType;
import oracle.bpel.services.workflow.client.config.WorkflowServicesClientConfigurationType;
import oracle.bpel.services.workflow.client.IWorkflowServiceClient;
import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory;
import oracle.bpel.services.workflow.query.ITaskQueryService;
import oracle.bpel.services.workflow.query.ITaskQueryService.AssignmentFilter;
import oracle.bpel.services.workflow.repos.TableConstants;
import oracle.bpel.services.workflow.task.ITaskService;
import oracle.bpel.services.workflow.task.model.Task;
import oracle.bpel.services.workflow.verification.IWorkflowContext;
*/
*/
* service located remotely from the client.
*
ITaskQueryService qService = wfsc.getTaskQueryService();
*/
* the columns are all from WFTASK table in SOAINFRA schema.
*/
*/
*/
*/
* if the status is not APPROVED and request id gets matched, then
* perform update task like APPROVE the task
*/
String taskId = task.getSystemAttributes().getTaskId();
String taskOutcome = task.getSystemAttributes().getOutcome();
String identificationKey = task.getIdentificationKey();
e.printStackTrace();
1. Create a project in eclipse.
2. Copy the below jars from servers
[WL_HOME]/server/lib/weblogic.jar
[SOA_HOME]/soa/modules/oracle.soa.fabric_11.1.1/bpm-infra.jar
[SOA_HOME]/soa/modules/oracle.soa.fabric_11.1.1/fabric-runtime.jar
[SOA_HOME]/soa/modules/oracle.soa.workflow_11.1.1/bpm-services.jar
[WL_HOME]/server/lib/wlfullclient.jar
[OIM_HOME]/server/ext/spml/wsclient_extended.jar
3. Set the above jars in your project classpath
4. Use the below code in your project.
import java.util.ArrayList;
import java.util.List;import java.util.logging.Logger;
import com.bea.security.providers.xacml.entitlement.parser.Predicate;
import oracle.bpel.services.workflow.WorkflowException;import oracle.bpel.services.workflow.client.config.RemoteClientType;
import oracle.bpel.services.workflow.client.config.RemoteClientType.Password;
import oracle.bpel.services.workflow.client.config.ServerType;
import oracle.bpel.services.workflow.client.config.WorkflowServicesClientConfigurationType;
import oracle.bpel.services.workflow.client.IWorkflowServiceClient;
import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory;
import oracle.bpel.services.workflow.query.ITaskQueryService;
import oracle.bpel.services.workflow.query.ITaskQueryService.AssignmentFilter;
import oracle.bpel.services.workflow.repos.TableConstants;
import oracle.bpel.services.workflow.task.ITaskService;
import oracle.bpel.services.workflow.task.model.Task;
import oracle.bpel.services.workflow.verification.IWorkflowContext;
public class ApproveOIMRequest {
public void approveRequest(String reqId) throws Exception{
Logger logger = Logger.getLogger(ApproveOIMRequest.class.getName());
/**
* Adding SOA server and its properties into the WorkflowServicesClientConfigurationType*/
WorkflowServicesClientConfigurationType wssst = new WorkflowServicesClientConfigurationType();
List<ServerType> servers = wssst.getServer();
ServerType server = new ServerType();
server.setDefault(true);
server.setName("soa");
servers.add(server);
/**
* Creating remote client with all the SOA server connection parameters including login user as xelsysadm.*/
RemoteClientType rct = new RemoteClientType();
rct.setServerURL("t3://ess.com:8001");
rct.setUserName("xelsysadm");
Password weblogicPWD = new Password();
weblogicPWD.setValue("Welcome1");
rct.setPassword(weblogicPWD);
rct.setInitialContextFactory("weblogic.jndi.WLInitialContextFactory");
rct.setParticipateInClientTransaction(false);
server.setRemoteClient(rct);
/**
* Creating remote enterprise java bean interface to invoke workflow * service located remotely from the client.
*
* After creating IWorkflowServiceClient object, get the Query Service.
*/
IWorkflowServiceClient wfsc = WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.REMOTE_CLIENT,wssst,logger);
ITaskQueryService qService = wfsc.getTaskQueryService();
/**
* Authenticating using xelsysadm*/
String xelsysadmPassword = "Welcome1";
IWorkflowContext wctx = qService.authenticate("xelsysadm", xelsysadmPassword.toCharArray(), null);
/**
* List the column name to get the value from query service.* the columns are all from WFTASK table in SOAINFRA schema.
*/
List queryColumns = new ArrayList();
queryColumns.add("TASKID");
queryColumns.add("TASKNUMBER");
queryColumns.add("TITLE");
queryColumns.add("OUTCOME");
queryColumns.add("IDENTIFICATIONKEY");
/**
* Assigning filter for selecting assigned tasks*/
AssignmentFilter assignmentFilter = AssignmentFilter.ALL;
/**
* List all the assignd tasks for logged in user.*/
List tasks = qService.queryTasks(wctx, queryColumns, null, assignmentFilter, null, null, null, 0, 0);
/**
* get the object of task service in order to perform actions on tasks.*/
ITaskService taskService = wfsc.getTaskService();
System.out.println("tasks.size() :"+tasks.size());
/**
* Iterate the list of tasks and check for the request id and status.* if the status is not APPROVED and request id gets matched, then
* perform update task like APPROVE the task
*/
for (int i=0; i<tasks.size(); i++){
//System.out.println("Task found for request id: "+reqId);
Task task = (Task) tasks.get(i);
int taskNumber = task.getSystemAttributes().getTaskNumber();
String taskTitle = task.getTitle();String taskId = task.getSystemAttributes().getTaskId();
String taskOutcome = task.getSystemAttributes().getOutcome();
String identificationKey = task.getIdentificationKey();
//System.out.println(taskNumber+" "+taskTitle+" "+taskOutcome+" "+identificationKey);
if (identificationKey.equalsIgnoreCase(reqId) && taskOutcome == null){
System.out.println(taskNumber+" "+""+" "+taskOutcome+" "+identificationKey);
taskOutcome = "APPROVE";
taskService.updateTaskOutcome(wctx, taskId, taskOutcome);
}
}
System.out.println("Done");
}
public static void main(String[] args) {
ApproveOIMRequest a = new ApproveOIMRequest();
try {
a.approveRequest("32001"); //Request Id is the input parameter.
} catch (Exception e) {
e.printStackTrace();
}
}
}
Hello!
ReplyDeleteThis example shows us that we can approve tasks which are assigned to user 'xelsysadm'. Is it possible to approve tasks which are assigned to the group like 'SYSTEM ADMINISTRATORS'?
As per my understanding, XELSYSADM can act on any request, irrespective of where it is assigned. The above code same is tested on the requested which was assigned to normal end user.
DeleteThis comment has been removed by the author.
DeleteUse below code to approve request for any enduser
DeleteIWorkflowContext retval =qService.authenticateOnBehalfOf(wctx, "AGNET5");
if (retval == null)
{
System.out.println("Failed to authenticate on behalf of user : ");
}
if (identificationKey.equalsIgnoreCase(reqId) ){
System.out.println(taskNumber+" "+taskTitle+" "+taskOutcome+" "+identificationKey+" " +state + " " +taskId);
taskOutcome = "APPROVE";
taskService.updateTaskOutcome(retval, taskId, taskOutcome);
System.out.println(taskNumber+" "+""+" "+taskOutcome+" "+identificationKey +" " +state);
}
This comment has been removed by the author.
ReplyDeleteThanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle SOA Interview Questions and Answers
ReplyDelete. Actually, I was looking for the same information on internet for
Oracle SOA Training and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more about Oracle SOA Tutorial also.
Thanks for sharing this blog. The content is beneficial and useful. Very informative post. Visit here to learn more about Data Mining companies and Data analytics Companies.
ReplyDeleteIt's really a great and helpful piece of info. I'm glad that you just shared this useful information with us. Please keep us up to date like this. Thank you for sharing.Here is the right place to Submit Guest Post Big Data.
ReplyDelete