To execute below code you have to add following jars in classpath:
-
commons-logging.jar
-
eclipselink.jar
-
jrf-api.jar
-
oimclient.jar
-
spring.jar
-
wlfullclient.jar
Stand Alone Code:
import Thor.API.Operations.tcProvisioningOperationsIntf;
import Thor.API.tcResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import javax.security.auth.login.LoginException;
import oracle.iam.platform.OIMClient;
public class ManualCompleteProcessTask {
OIMClient oimClient = null;
//identity self service details
String username = "xelsysadm";
String password = "<password>"; //xelsysadm password
String t3url = "t3://<hostname>:<port>"; //OIM HostName and Port
String authwl_location = "<location of authwl.conf file in your local machine>"; //eg. D:\\authwl.conf
public void getOIMConnection() {
System.out.println("getOIMConnection() : Start");
//set system properties
System.setProperty("java.security.auth.login.config", authwl_location);
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
Hashtable oimenv = new Hashtable();
oimenv.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
oimenv.put(OIMClient.JAVA_NAMING_PROVIDER_URL,t3url);
oimClient = new OIMClient(oimenv);
try {
oimClient.login(username, password.toCharArray());
System.out.println("Connected");
} catch (LoginException e) {
e.printStackTrace();
}
System.out.println("getOIMConnection() : End");
}
public void setTaskCompletedManually(String resourceName, String taskName, String taskStatus) {
try {
System.out.println("setTaskCompletedManually() : Start");
tcProvisioningOperationsIntf tcOp = oimClient.getService(tcProvisioningOperationsIntf.class);
Map<String, String> filter = new HashMap<String, String>();
filter.put("Objects.Name", resourceName);
filter.put("Process Definition.Tasks.Task Name", taskName);
//Failed Task Status
String taskStaus[] = new String[] {taskStatus};
tcResultSet trs = tcOp.findAllOpenProvisioningTasks(filter, taskStaus);
List<Map<String, Object>> taskLists = new ArrayList<Map<String, Object>>();
int rowCount = trs.getRowCount();
System.out.println("Total " + taskStatus + " Task(s) for Application Instance(" + resourceName + ") : " + trs.getRowCount());
if (rowCount > 0) {
for (int i = 0; i < rowCount; i++) {
trs.goToRow(i);
System.out.println(taskName + " Task completed manually for User : " + trs.getStringValue("Process Instance.Task Information.Target User"));
tcOp.setTasksCompletedManually(new long[] {trs.getLongValue("Process Instance.Task Details.Key")} );
}
}
System.out.println("setTaskCompletedManually() : End");
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
ManualCompleteProcessTask manualCompleteProcessTask = new ManualCompleteProcessTask();
//Get OIM Connection
manualCompleteProcessTask.getOIMConnection();
//Resource Object Name
String resourceName = "AD User";
//Failed Task Name
String taskName = "Create User";
// If you want to manual complete pending task, replace Rejected with 'Pending'
String taskStatus = "Rejected";
//Manual Complete
manualCompleteProcessTask.setTaskCompletedManually(resourceName, taskName, taskStatus);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
Happy Learning!!!
No comments:
Post a Comment