OIM API to Retry Failed/Rejected Provisioning Tasks


  1. package com.oimacademy.provision;
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. import java.sql.ResultSet;
  5. import java.sql.Statement;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. import java.util.Hashtable;
  9. import java.util.List;
  10. import java.util.Map;
  11. import java.util.Properties;
  12. import oracle.iam.identity.rolemgmt.api.RoleManager;
  13. import oracle.iam.identity.usermgmt.api.UserManager;
  14. import oracle.iam.platform.OIMClient;
  15. import Thor.API.tcResultSet;
  16. import Thor.API.Operations.tcProvisioningOperationsIntf;
  17. import com.oimacademy.connection.Platform;
  18. import com.thortech.xl.util.LocalConfiguration;
  19. public class processFailedTasksModified 
  20. {
  21.  public static void main(String[] args) { 
  22.   try{    
  23.    tcProvisioningOperationsIntf provOperIntf  = 
  24.      (tcProvisioningOperationsIntf) Platform.getService(Thor.API.Operations.tcProvisioningOperationsIntf.class);
  25.    //Retry the Rejected Tasks
  26.    //In query itself we are filtering based on osi_assigned_date attribute.
  27.    //JDBC API starts.
  28.    String query="select sch.sch_key,usr.usr_key, usr.usr_login, oiu.oiu_key,orc.orc_key,sch.sch_create,sch.sch_data,obj.obj_name,mil.mil_name,mil.mil_key,ost.ost_status  from usr,oiu, obi, obj, orc, osi, sch, mil, tos, pkg,ost ost where usr.usr_key=oiu.usr_key and oiu.obi_key=obi.obi_key and obi.obj_key=obj.obj_key and oiu.orc_key=orc.orc_key and osi.orc_key=orc.orc_key and osi.sch_key=sch.sch_key and  obj.obj_key=pkg.obj_key and pkg.pkg_key=tos.pkg_key and  tos.tos_key=mil.tos_key and  oiu.ost_key = ost.ost_key and obj.obj_name='OID User' and mil.mil_name ='Create User' and ost_status in ('Provisioning','Provisioned','Enabled') and sch.sch_status='R' ";
  29.    System.out.println("-------- Oracle JDBC Connection Testing ------");
  30.     List<String> taskKeys= new ArrayList<String>();
  31.    try {  
  32.     Class.forName("oracle.jdbc.driver.OracleDriver");
  33.     System.out.println("Oracle JDBC Driver Registered!");     
  34.     Connection connection = null;
  35.     connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:sid", "userSchema","password");
  36.     Statement stmt = connection.createStatement();
  37.     stmt.execute(query);
  38.     ResultSet rs=stmt.getResultSet();    
  39.      while ( rs.next() )  
  40.      {  
  41.       taskKeys.add(rs.getString("sch_key"));
  42.      }  
  43.    } 
  44.    catch (ClassNotFoundException e) {  
  45.     System.out.println("Where is your Oracle JDBC Driver?");
  46.     e.printStackTrace();
  47.     return;  
  48.    }
  49.    for(String taskKey : taskKeys )
  50.    {    
  51.     System.out.println("Task retrying using API..... " + Long.parseLong(taskKey));
  52.       try {
  53.      provOperIntf.retryTask(Long.parseLong(taskKey));
  54.      System.out.println("Task retrying Done.... ");
  55.     } catch (Exception e) {
  56.      System.out.println(" - tcAPIException - Error" + e);
  57.     } 
  58.    }
  59.    System.out.println("...Completed.."); 
  60.   }catch (Exception e){ 
  61.    e.printStackTrace(); 
  62.   } 
  63.  }
  64. }

No comments:

Post a Comment