Pages

Thursday, December 5, 2013

tcProvisioningOperationsIntf API Rejected and Pending Task example

The tcProvisioningOperationsIntf  inteface API being used to retrieve the Rejected and Pending Task, Retrying the Rejected Tasks, and Rejected Task Completed Manually in the Oracle Identity Manager repository.

Pre-Requisite:

Initial Setup.

Please follow the link and setup the OIM client environment to use to create the OIM Objects.


Client Code Setup

tcProvisioningOperationsIntf  API Usage:

1. Retrieving the Rejected and Pending tasks based on the Filter Criteria,
2. Retry the Rejected Tasks
3. Manually Completed the Rejected Tasks.
4. Manually Completed the Pending Tasks.

Tasks Needs to be Performed:

1.    Create the OIMClient Handle


OIMClient client= new OIMClient();
client.login(username,password.toCharArray());

2.    Get tcProvisioningOperationsIntf service object


tcProvisioningOperationsIntf provisioningServiceIntf = client.getService(tcProvisioningOperationsIntf.class);

3.  Retrieve the Rejected or Pending Tasks Based on The Resource Object and Task Name


// Resource Name. My Example Resource Name is AD User
String resourceName = "AD User";
// Failed Task Name. My Example Failed Task Name is Create User.
String taskName = "Create User" ;
String taskStatus = "Rejected"
Map<String, String> filter= new HashMap<String,String>();
filter.put("Objects.Name", resourceName);
filter.put("Process Definition.Tasks.Task Name",taskName);

// Failed Task Status. In my example failed task status is Rejected. If you need pending task, replace Rejected with Pending 
String taskStaus[]= new String[]{"Rejected"};

tcResultSet trs=provisioningServiceIntf.findAllOpenProvisioningTasks(filter,taskStaus);
List<Map<String,Object>> taskLists= new ArrayList<Map<String,Object>>();

int rowCount=trs.getRowCount();
if(rowCount >0){
    for(int i=0;i<rowCount ;i++)
    {
               trs.goToRow(0);
               Map<String,Object> map= new HashMap<String,Object>();
               map.put("Process Instance.Task Details.Key",trs.getLongValue("Process Instance.Task Details.Key"))
               map.put("Process Instance.Task Information.Target User",trs.getStringValue("Process Instance.Task Information.Target User"));
               map.put("Process Instance.Key",trs.getLongValue("Process Instance.Key"));
               map.put("Process Definition.Tasks.Key",trs.getLongValue("Process Definition.Tasks.Key"));
               map.put("Process Definition.Tasks.Task Name",trs.getStringValue("Process Definition.Tasks.Task Name"));

taskLists.add(map);
     }
    
}

4. Retry the Rejected Tasks

for(Map<String,Object> task : taskLists )
{
    long taskKey = (long) map.get("Process Instance.Task Details.Key");

   try
        {
            provisioningServiceIntf.retryTask(taskKey );
        } catch (tcAPIException e)
        {
            System.out.println(" - tcAPIException - Error" + e);
        } catch (tcTaskNotFoundException e)
        {
            System.out.println(" - tcTaskNotFoundException - Error" + e);
        }
}

5.    Rejected or Pending Task Completed Manually



for(Map<String,Object> task : taskLists )
{
    long taskKey = (long) map.get("Process Instance.Task Details.Key");

   try
        {
            provisioningServiceIntf.setTasksCompletedManually(new long[]{taskKey} );
        } catch (tcAPIException e)
        {
            System.out.println(" - tcAPIException - Error" + e);
        } catch (tcTaskNotFoundException e)
        {
            System.out.println(" - tcTaskNotFoundException - Error" + e);
        }
        catch (tcBulkException e)
        {
            System.out.println(" - tcBulkException - Error" + e);
        }
}


6.    Retrieving the Rejected Task History

for(Map<String,Object> task : taskLists )
{
    long taskInstanceKey = (long) map.get("Process Instance.Key");

   try
        {
          tcResultSet trs= provisioningServiceIntf.getProcessDetail(taskInstanceKey );
            int count=trs.getRowCount();
                for(int i=0;i<count;i++)
                {
                    trs.goToRow(i);
                    String taskName=trs.getStringValue("Process Definition.Tasks.Task Name");
                    boolean retryAllowed= trs.getBooleanValue("RETRYALLOWED");
                    long processTask=trs.getLongValue("Process Definition.Tasks.Key");
System.out.println( "taskName - "+taskName + " - retryAllowed - "+retryAllowed+ " - processTask - "+processTask);
                }
        catch (tcAPIException e)
        {
           System.out.println(e);
        }
        catch (tcNotAtomicProcessException e)
        {
           System.out.println(e);
        } catch (tcColumnNotFoundException e)
        {
            System.out.println(e);
        }
}

1 comment: