How to develop a Scheduler in OIM

Below steps help us in developing a new Scheduler in OIM 11G R2 PS3.
  1. Create a new Java project in Eclipse and add external jars from design console(you can add whatever Jars required for your scheduler)
  2. Create a new class which extends oracle.iam.scheduler.vo.TaskSupport as super class
Write your business logic in Execute method
Below is the basic structure of the Scheduler


package com.ghr;

import java.util.HashMap;

import oracle.iam.scheduler.vo.TaskSupport;

public class UpdateTCADRemovalDate extends TaskSupport {

@Override
public void execute(HashMap taskparams) throws Exception {
// TODO Auto-generated method stub

}

@Override
public HashMap getAttributes() {
// TODO Auto-generated method stub
return null;
}

@Override
public void setAttributes() {
// TODO Auto-generated method stub
}

}

3. Reading Task input parameters

All the task input parameters available in taskparams variable which is of type HashMap which is input parameter for execute method

Example:
lastRunTime = (String)taskparams.get("Last Run Time");

4. Setting Scheduler task parameters using code(this is optional)

Using SchedulerService Interface we can modify Scheduler task parameters


Below is the sample code to update task parameter

private void updateJobTimeStamp() {
String methodName = "updateJobTimeStamp";
logger.setMethodStartLog(className, methodName);
String newTimeStamp = null; Date date = new Date(); 
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMM-yy");
                newTimeStamp = simpleDateFormat.format(date); 
                logger.info(className, methodName, "newTimeStamp::" + newTimeStamp);

SchedulerService schedulerService = Platform.getService(SchedulerService.class);
try {
JobDetails jobdetails=schedulerService.getJobDetail("Automatic User Profile Data Correction");
HashMap<String, JobParameter> params= jobdetails.getParams();
String parameterValue = newTimeStamp;
JobParameter jobParam= params.get("Last Updated TimeStamp");
jobParam.setValue(parameterValue);
params.put("Last Updated TimeStamp", jobParam);
schedulerService.updateJob(jobdetails);
jobParam.setValue(parameterValue);
logger.debug(className, methodName, "Last Updated TimeStamp updated to "+newTimeStamp);
} catch (SchedulerException e) {
e.printStackTrace();
} catch (IncorrectScheduleTaskDefinationException e) {
e.printStackTrace();
} catch (LastModifyDateNotSetException e) {
e.printStackTrace();
} catch (StaleDataException e) {
e.printStackTrace();
} catch (RequiredParameterNotSetException e) {
e.printStackTrace();
} catch (ParameterValueTypeNotSupportedException e) {
e.printStackTrace();
} catch (SchedulerAccessDeniedException e) {
e.printStackTrace();
}
logger.setMethodFinishLog(className, methodName);
}


5. Build your source code into Jar by exporting(right click on class and select export)
6. Create plugin structure











Lib should contain you Jar file which you created in step 5

plugin.xml should contain below format, replace highlighted values as per your requirement

<?xml version="1.0" encoding="UTF-8"?>
<oimplugins xmlns:targetNamespace="http://www.oracle.com/schema/oim/plugin" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mds="http://xmlns.oracle.com/mds" xmlns:md="http://xmlns.oracle.com/bali/xml/metadata">
    <plugins pluginpoint="oracle.iam.scheduler.vo.TaskSupport">
        <plugin pluginclass="ts.idm.base.schedulers.UpdateTCADRemovalDate" version="1.0" name="UpdateTCADRemovalDate"></plugin>
</plugins>
</oimplugins>


META-INF folder should contain xml with your plugin name
Example:
metadata_UpdateTCADRemovalDate.xml
provide input parameters and task name details in this file

<?xml version='1.0' encoding='UTF-8'?>
<scheduledTasks xmlns="http://xmlns.oracle.com/oim/scheduler">
<task>
<name>TS Update TCAD Removal Date</name>
<class>ts.idm.base.schedulers.UpdateTCADRemovalDate</class>
<description>TS Update TCAD Removal Date</description>
<retry>5</retry>
<parameters>
<string-param required="true" encrypted="false" helpText="Last Run Time with Format : dd-MMM-yy">Last Run Time</string-param>
</parameters>
</task>
</scheduledTasks>


with all above create a zip file

7. Register your plugin
please refer below post for plugin register steps

8. Create Scheduler task in Admin console

Navigate System Configuration -> Scheduler

Click on Create scheduler















Provide scheduler task information
Task: which you have provided in the xml file















That's all now we have created new Scheduler task

Comments

  1. can we edit scheduler and assign variables with scheduler.

    ReplyDelete

Post a Comment

Popular posts from this blog

Rules in Sailpoint

Sailpoint Installation Steps (IdentityIQ 7.3 Installation in Windows Machine)

How to create provisioning plan in Sailpoint