package com.scheduler; import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.Date; import com.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 R2PS2/PS3/12C) is a highly flexible and scalable enterprise identity administration system that provides operational and business efficiency by providing centralized administration & complete automation of identity and user provisioning events across enterprise as well as extranet applications.
API Code to Update Scheduled Job Parameter & Schedule Job Using Cron trigger
Subscribe to:
Posts (Atom)
About OIM
Oracle Identity Management enables organizations to effectively manage the end - to - end life - cycle of user ide...
Popular Posts
-
OIM API's Sample Code : Videos: Massive Gaze Videos Connection Related API's : OIM DB Connection/ Data Source connection ...
-
Videos: Massive Gaze Videos 1. Basic OIM Information 2. MDS Export/Import 3. Steps For R2PS2 / R2PS3 Custom Pre-processor Ev...
-
Videos: Massive Gaze Videos 1. Query to get OIM Provsioned/provisioning Account details 2. Query to get usr keys For Rejected / ...
No comments:
Post a Comment