private void scheduleJob(final ScheduledJobDetail scheduledJobDetails) {
   if (!scheduledJobDetails.isActiveSchedular()) {
     scheduledJobDetails.updateNextRunTime(null);
     scheduledJobDetails.updateCurrentlyRunningStatus(false);
     return;
   }
   try {
     final JobDetail jobDetail = createJobDetail(scheduledJobDetails);
     final Trigger trigger = createTrigger(scheduledJobDetails, jobDetail);
     final Scheduler scheduler = getScheduler(scheduledJobDetails);
     scheduler.scheduleJob(jobDetail, trigger);
     scheduledJobDetails.updateJobKey(getJobKeyAsString(jobDetail.getKey()));
     scheduledJobDetails.updateNextRunTime(trigger.getNextFireTime());
     scheduledJobDetails.updateErrorLog(null);
   } catch (final Throwable throwable) {
     scheduledJobDetails.updateNextRunTime(null);
     final String stackTrace = getStackTraceAsString(throwable);
     scheduledJobDetails.updateErrorLog(stackTrace);
     logger.error("Could not schedule job: " + scheduledJobDetails.getJobName(), throwable);
   }
   scheduledJobDetails.updateCurrentlyRunningStatus(false);
 }
 public void rescheduleJob(final ScheduledJobDetail scheduledJobDetail) {
   try {
     final String jobIdentity = scheduledJobDetail.getJobKey();
     final JobKey jobKey = constructJobKey(jobIdentity);
     final String schedulername = getSchedulerName(scheduledJobDetail);
     final Scheduler scheduler = this.schedulers.get(schedulername);
     if (scheduler != null) {
       scheduler.deleteJob(jobKey);
     }
     scheduleJob(scheduledJobDetail);
     this.schedularWritePlatformService.saveOrUpdate(scheduledJobDetail);
   } catch (final Throwable throwable) {
     final String stackTrace = getStackTraceAsString(throwable);
     scheduledJobDetail.updateErrorLog(stackTrace);
     this.schedularWritePlatformService.saveOrUpdate(scheduledJobDetail);
   }
 }