Sunday, 1 April 2018

OIM API - Code Snippet to Update Scheduled Job Parameter.

public void updateScheduledJobParameter(String jobName, String paramName, String paramValue) {
    final String logp = CN + " :: updateScheduledJobParameter - ";
    LOGGER.debug(logp + "START");
    SchedulerService schedulerService = null;

    try{
        //get scheduler service
        schedulerService = Platform.getService(SchedulerService.class);
       
        JobDetails jbDetails = schedulerService.getJobDetail(jobName);

        HashMap jobAttributes = jbDetails.getAttributes();
        LOGGER.debug(logp + "Existing job attributes - " + jobAttributes);

        JobParameter jbParam = new JobParameter();
        jbParam.setName(paramName);
        jbParam.setValue(paramValue);

        jobAttributes.put(paramName, jbParam);

        jbDetails.setAttributes(jobAttributes);
        LOGGER.debug(logp + "Updated job attributes - " + jobAttributes);

        schedulerService.updateJob(jbDetails);
        LOGGER.debug(logp + "Job updated successfully");

    }catch(Exception e){
        LOGGER.error(logp + "Exception occured while updating scheduled job parameters - " + e, e);
    }
   
    LOGGER.debug(logp + "END");
}


Happy Learning!!!

No comments:

Post a Comment