Pages

Monday, July 2, 2012

tcSchedulerOperationsIntf API example

The tcSchedulerOperationsIntf inteface API being used to add, update, and delete the Scheduler Task attribute from 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


tcSchedulerOperationsIntf API Usage:

The following tasks needs to be performed to add, update, and delete the schedule task Attributes from Oracle Identity Manager. They are

1.    Create the OIMClient Handle


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

2.    Get tcSchedulerOperationsIntf service object


tcSchedulerOperationsIntf scheduler= client.getService(tcSchedulerOperationsIntf.class);

3.    Find the Scheduler Task Key

String schedulerName = "A D User Target Recon"
Map<String, String> params= new HashMap<String, String>();
params.put("Task Scheduler.Name", schedulerName);
tcResultSet rs= schedulerOperationsIntf.findScheduleTasks(params);
int count=rs.getRowCount();
long schedulerKey=0;
if(count >0)
{
    rs.goToRow(0);
schedulerKey=codes.put(rs.getStringValue("Task Scheduler.Name"), rs.getLongValue("Task Scheduler.Key"));
}


4.    Getting Scheduler Task Attributes


Map<String,Long> attributes= new HashMap<String,Long> ()
tcResultSet attrrs= schedulerOperationsIntf.getScheduleTaskAttributes(schedulerKey);
int scount= attrrs.getRowCount();
for(int i=0;i<count;i++)
{
    attrrs.goToRow(i);
    map.put(attrrs.getStringValue("Task Scheduler.Task Attributes.Name"),
    attrrs.getLongValue("Task Scheduler.Task Attributes.Key"));
}
   

5.    Updating the Schedule Task Attribute


If(attributes.ContainsKey("Search Base"))
{
Map<String, String> updateattributes= new HashMap<String, String>();
updateattributes.put("Task Scheduler.Task Attributes.Name","Search Base"),
updateattributes.put("Task Scheduler.Task Attributes.Value","dc=test,dc=com");
schedulerOperationsIntf.updateScheduleTaskAttribute(schedulerkey, attributes.get("Search Base"), updateattributes);

}


6.    Adding the Schedule Task Attribute


If(!attributes.ContainsKey("Search Base"))
{
Map<String, String> addattributes= new HashMap<String, String>();
addattributes.put("Task Scheduler.Task Attributes.Name","Search Base"),
addattributes.put("Task Scheduler.Task Attributes.Value","dc=test,dc=com");
schedulerOperationsIntf. addScheduleTaskAttribute (schedulerkey, addattributes);
}


7.    Remove the Schedule Task Attribute


If(attributes.ContainsKey("Search Base"))
{
Map<String, String> addattributes= new HashMap<String, String>();
addattributes.put("Task Scheduler.Task Attributes.Name","Search Base"),
addattributes.put("Task Scheduler.Task Attributes.Value","dc=test,dc=com");
schedulerOperationsIntf. deleteScheduleTaskAttribute(attributes.get("Search Base"));
}

No comments:

Post a Comment