We can update OIM schedule job parameter programmatically using available APIs. Here is the code sample.
public void updateSchedulerParam(String jobName, String paramName, String newValue){
SchedulerService schdulerService = (SchedulerService)oimClientObj.getService(SchedulerService.class);
try {
JobDetails jobDetails = schdulerService.getJobDetail(jobName);
HashMap<String, JobParameter> schParam = jobDetails.getParams();
for (Entry<String, JobParameter> entry : schParam.entrySet()) {
String key = entry.getKey();
JobParameter jobParam = entry.getValue();
Serializable value = jobParam.getValue();
System.out.println("Old key value pair: "+key+" = "+ value);
if (key.equalsIgnoreCase(paramName)){
value = newValue;
System.out.println(value.toString());
jobParam.setValue(value);
System.out.println(jobParam.getValue());
schParam.put(key, jobParam);
break;
}
}
jobDetails.setParams(schParam);
schdulerService.updateJob(jobDetails);
System.out.println("Updated successfully");
} catch (Exception e) {
e.printStackTrace();
}
}
public void updateSchedulerParam(String jobName, String paramName, String newValue){
SchedulerService schdulerService = (SchedulerService)oimClientObj.getService(SchedulerService.class);
try {
JobDetails jobDetails = schdulerService.getJobDetail(jobName);
HashMap<String, JobParameter> schParam = jobDetails.getParams();
for (Entry<String, JobParameter> entry : schParam.entrySet()) {
String key = entry.getKey();
JobParameter jobParam = entry.getValue();
Serializable value = jobParam.getValue();
System.out.println("Old key value pair: "+key+" = "+ value);
if (key.equalsIgnoreCase(paramName)){
value = newValue;
System.out.println(value.toString());
jobParam.setValue(value);
System.out.println(jobParam.getValue());
schParam.put(key, jobParam);
break;
}
}
jobDetails.setParams(schParam);
schdulerService.updateJob(jobDetails);
System.out.println("Updated successfully");
} catch (Exception e) {
e.printStackTrace();
}
}
No comments:
Post a Comment