/** * Retrieve the job's status of a given {@link com.xpn.xwiki.plugin.scheduler.SchedulerPlugin#XWIKI_JOB_CLASS} job * XObject, by asking the actual job status to the quartz scheduler instance. It's the actual status, as the one * stored in the XObject may be changed manually by users. * * @param object the XObject to give the status of * @return the status of the Job inside the quartz scheduler, as {@link com.xpn.xwiki.plugin.scheduler.JobState} * instance */ public JobState getJobStatus(BaseObject object, XWikiContext context) throws SchedulerException { int state = getScheduler().getTriggerState(getObjectUniqueId(object, context), Scheduler.DEFAULT_GROUP); return new JobState(state); }
/** * Retrieve the job's status of a given {@link com.xpn.xwiki.plugin.scheduler.SchedulerPlugin#XWIKI_JOB_CLASS} job * XObject, by asking the actual job status to the quartz scheduler instance. It's the actual status, as the one * stored in the XObject may be changed manually by users. * * @param object the XObject to give the status of * @return the status of the Job inside the quartz scheduler, as {@link com.xpn.xwiki.plugin.scheduler.JobState} * instance */ public JobState getJobStatus(BaseObject object, XWikiContext context) throws SchedulerException { TriggerState state = getScheduler().getTriggerState(new TriggerKey(getObjectUniqueId(object, context))); return new JobState(state); }
/** * Trigger a job (execute it now) * * @param object the non-wrapped XObject Job to be triggered * @param context the XWiki context */ public void triggerJob(BaseObject object, XWikiContext context) throws SchedulerPluginException { try { getScheduler().triggerJob(getObjectUniqueId(object, context), Scheduler.DEFAULT_GROUP); } catch (SchedulerException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_TRIGGER_JOB, "Error occured while trying to trigger job " + object.getStringValue("jobName"), e); } }
/** * Get Trigger object of the given job * * @param object the unwrapped XObject to be retrieve the trigger for * @param context the XWiki context * @return the trigger object of the given job */ private Trigger getTrigger(BaseObject object, XWikiContext context) throws SchedulerPluginException { String job = getObjectUniqueId(object, context); Trigger trigger; try { trigger = getScheduler().getTrigger(job, Scheduler.DEFAULT_GROUP); } catch (SchedulerException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_JOB_XCLASS_NOT_FOUND, "Error while getting trigger for job " + job, e); } if (trigger == null) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_JOB_DOES_NOT_EXITS, "Job does not exists"); } return trigger; }
/** * Trigger a job (execute it now) * * @param object the non-wrapped XObject Job to be triggered * @param context the XWiki context */ public void triggerJob(BaseObject object, XWikiContext context) throws SchedulerPluginException { String job = getObjectUniqueId(object, context); try { getScheduler().triggerJob(new JobKey(job)); } catch (SchedulerException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_TRIGGER_JOB, "Error occured while trying to trigger job " + object.getStringValue("jobName"), e); } }
/** * Get Trigger object of the given job * * @param object the unwrapped XObject to be retrieve the trigger for * @param context the XWiki context * @return the trigger object of the given job */ private Trigger getTrigger(BaseObject object, XWikiContext context) throws SchedulerPluginException { String job = getObjectUniqueId(object, context); Trigger trigger; try { trigger = getScheduler().getTrigger(new TriggerKey(job)); } catch (SchedulerException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_JOB_XCLASS_NOT_FOUND, "Error while getting trigger for job " + job, e); } if (trigger == null) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_JOB_DOES_NOT_EXITS, "Job does not exists"); } return trigger; }
try { String xjob = getObjectUniqueId(object, context);
/** * Resume the job with the given name (un-pause) * * @param object the non-wrapped XObject Job to be resumed */ public void resumeJob(BaseObject object, XWikiContext context) throws SchedulerPluginException { try { getScheduler().resumeJob(getObjectUniqueId(object, context), Scheduler.DEFAULT_GROUP); saveStatus("Normal", object, context); } catch (SchedulerException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_RESUME_JOB, "Error occured while trying to resume job " + object.getStringValue("jobName"), e); } catch (XWikiException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_RESUME_JOB, "Error occured while trying to save status of job " + object.getStringValue("jobName"), e); } }
/** * Unschedule the given job * * @param object the unwrapped XObject job to be unscheduled */ public void unscheduleJob(BaseObject object, XWikiContext context) throws SchedulerPluginException { try { getScheduler().deleteJob(getObjectUniqueId(object, context), Scheduler.DEFAULT_GROUP); saveStatus("None", object, context); } catch (SchedulerException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_JOB_XCLASS_NOT_FOUND, "Error while unscheduling job " + object.getStringValue("jobName"), e); } catch (XWikiException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_JOB_XCLASS_NOT_FOUND, "Error while saving status of job " + object.getStringValue("jobName"), e); } }
/** * Pause the job with the given name by pausing all of its current triggers. * * @param object the non-wrapped XObject Job to be paused */ public void pauseJob(BaseObject object, XWikiContext context) throws SchedulerPluginException { try { getScheduler().pauseJob(getObjectUniqueId(object, context), Scheduler.DEFAULT_GROUP); saveStatus("Paused", object, context); } catch (SchedulerException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_PAUSE_JOB, "Error occured while trying to pause job " + object.getStringValue("jobName"), e); } catch (XWikiException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_PAUSE_JOB, "Error occured while trying to save status of job " + object.getStringValue("jobName"), e); } }
/** * Unschedule the given job * * @param object the unwrapped XObject job to be unscheduled */ public void unscheduleJob(BaseObject object, XWikiContext context) throws SchedulerPluginException { String job = getObjectUniqueId(object, context); try { getScheduler().deleteJob(new JobKey(job)); saveStatus("None", object, context); } catch (SchedulerException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_JOB_XCLASS_NOT_FOUND, "Error while unscheduling job " + object.getStringValue("jobName"), e); } catch (XWikiException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_JOB_XCLASS_NOT_FOUND, "Error while saving status of job " + object.getStringValue("jobName"), e); } }
/** * Pause the job with the given name by pausing all of its current triggers. * * @param object the non-wrapped XObject Job to be paused */ public void pauseJob(BaseObject object, XWikiContext context) throws SchedulerPluginException { String job = getObjectUniqueId(object, context); try { getScheduler().pauseJob(new JobKey(job)); saveStatus("Paused", object, context); } catch (SchedulerException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_PAUSE_JOB, "Error occured while trying to pause job " + object.getStringValue("jobName"), e); } catch (XWikiException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_PAUSE_JOB, "Error occured while trying to save status of job " + object.getStringValue("jobName"), e); } }
/** * Resume the job with the given name (un-pause) * * @param object the non-wrapped XObject Job to be resumed */ public void resumeJob(BaseObject object, XWikiContext context) throws SchedulerPluginException { String job = getObjectUniqueId(object, context); try { getScheduler().resumeJob(new JobKey(job)); saveStatus("Normal", object, context); } catch (SchedulerException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_RESUME_JOB, "Error occured while trying to resume job " + object.getStringValue("jobName"), e); } catch (XWikiException e) { throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_RESUME_JOB, "Error occured while trying to save status of job " + object.getStringValue("jobName"), e); } }
String xjob = getObjectUniqueId(object, context);