- package com.oimacademy.scheduler;
- import java.io.Serializable;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Date;
- import com.oimacademy.connection.Platform;
- import oracle.iam.scheduler.api.SchedulerService;
- import oracle.iam.scheduler.vo.CronTrigger;
- import oracle.iam.scheduler.vo.JobDetails;
- import oracle.iam.scheduler.vo.JobParameter;
- import oracle.iam.scheduler.vo.Trigger;
- public class UpdateScheduledJobParameter {
- public static void main(String[] args){
- new UpdateScheduledJobParameter().updateScheduledJobParameter("Retry Task1", "Recurring Interval", "MONTHLY");
- }
- public void updateScheduledJobParameter(String jobName, String paramName, String paramValue) {
- final String logp = " :: updateScheduledJobParameter - ";
- System.out.println(logp + "START");
- SchedulerService schedulerService = null;
- try{
- //get scheduler service
- schedulerService = Platform.getService(SchedulerService.class);
- JobDetails jobDetail = schedulerService.getJobDetail(jobName);
- HashMap jobAttributes = jobDetail.getAttributes();
- System.out.println("JobDetails Object Getting Params ");
- HashMap<String, JobParameter> jobParameters = jobDetail.getParams();
- System.out.println( " name : " + jobDetail.getName());
- System.out.println( " class name : " + jobDetail.getTaskClassName());
- System.out.println( " task key : " + jobDetail.getTaskKey());
- System.out.println( " task name : " + jobDetail.getTaskName());
- System.out.println( " method : " + jobDetail.getMethod());
- System.out.println( " job schedule type : " + jobDetail.getJobScheduleType());
- System.out.println( " job listener : " + jobDetail.getJobListener());
- System.out.println( " cron schedule type : " + jobDetail.getCronScheduleType());
- System.out.println( " retry count : " + jobDetail.getRetrycount());
- if(null!=jobParameters && jobParameters.size()>0){
- Iterator itrJobParams = jobParameters.keySet().iterator();
- while (itrJobParams.hasNext()) {
- String hashKey=itrJobParams.next().toString();
- Object obj = jobParameters.get(hashKey);
- JobParameter jp = null;
- if (null != obj && obj instanceof JobParameter) {
- jp = (JobParameter) obj;
- System.out.println( " data type : " + jp.getDataType());
- System.out.println( " name : " + jp.getName());
- System.out.println( " parameter key : " + jp.getParameterKey());
- Serializable val = jp.getValue();
- System.out.println( " value : " + val);
- System.out.println();
- }
- }
- }else{
- System.out.println(" jobParameters Null in the task Name -> "+jobDetail.getTaskName());
- }
- JobParameter jbParam = new JobParameter();
- jbParam.setName(paramName);
- jbParam.setValue(paramValue);
- jobAttributes.put(paramName, jbParam);
- jobDetail.setAttributes(jobAttributes);
- System.out.println(logp + "Updated job attributes - " + jobAttributes);
- //
- Trigger[] triggers= schedulerService.getTriggersOfJob("Retry Task1");
- for(Trigger trigg : triggers ){
- schedulerService.deleteTrigger(trigg.getName());
- }
- JobDetails jb = new JobDetails();
- jb.setName(jobDetail.getName());
- jb.setJobScheduleType(jobDetail.getJobScheduleType());
- jb.setCronScheduleType(jobDetail.getCronScheduleType());
- jb.setRetrycount(jobDetail.getRetrycount());
- schedulerService.updateJob(jobDetail);
- schedulerService.scheduleJob(jobDetail.getName(), new CronTrigger(jobDetail.getName(),new Date(),null, "8 46 15 ? * 3,4,5,6,7,1 *"));
- System.out.println(logp + "Job updated successfully");
- }catch(Exception e){
- System.out.println(logp + "Exception occured while updating scheduled job parameters - " + e);
- }
- System.out.println(logp + "END");
- }
- }
Oracle Identity Manager(OIM) is the Provisioning Solution from oracle. This page contains an index with references to all OIM related posts in the oracle identity manager Academy blog. The posts included herein are intended to provide oracle identity management customers and developers with technical information about best practices for implementing OIM based solutions.
API Code to Update Scheduled Job Parameter & Schedule Job Using Cron trigger
Subscribe to:
Post Comments (Atom)
-
Connection Related API's : OIM DB Connection/ Data Source connection OIMClient API / OIMConnection API OIM Platform API to getSer...
-
Error : Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframewor...
-
In this post, we set the middle name as “MiddleName” if user does not provide middle name during user create operation. Below are high...
No comments:
Post a Comment