/** * {@inheritDoc} */ @Override public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context) { return new SchedulerPluginApi((SchedulerPlugin) plugin, context); }
/** * Give, for a XObject job in a {@link JobState#STATE_NORMAL} state, the next date at which the job will be * executed, according to its cron expression. Errors are returned in the context map. Can be called for example: * <code> #set($firetime = $xwiki.scheduler.getNextFireTime($job)) * #if (!$firetime || $firetime=="") #error($xcontext.get("error") #else #info("Fire time : * $firetime") #end </code> * Where $job is an XObject, instance of the {@link SchedulerPlugin#XWIKI_JOB_CLASS} XClass * * @param object the wrapped XObject for which to give the fire date * @return the date the job will be executed */ public Date getNextFireTime(Object object) { try { return getNextFireTime(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return null; } }
/** * Give, for a XObject job in a {@link JobState#STATE_NORMAL} state, the previous date at which the job has been * executed, the fire time is not computed from the CRON expression, this method will return null if the . * * @param object the wrapped XObject for which to give the fire time * @return the date the job has been executed */ public Date getPreviousFireTime(Object object) { try { return getPreviousFireTime(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return null; } }
/** * Trigger a XObject job (execute it now). * * @param object the wrapped XObject Job to be triggered * @return true on success, false on failure. */ public boolean triggerJob(Object object) { try { return triggerJob(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return false; } }
/** * Pause the given XObject job by pausing all of its current triggers. Can be called the same way as * {@link #scheduleJob(Object)} * * @param object the wrapped XObject Job to be paused * @return true on success, false on failure. */ public boolean pauseJob(Object object) { try { return pauseJob(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return false; } }
/** * Unschedule a XObject job by deleting it from the jobs table. Can be called the same way as * {@link #scheduleJob(Object)} * * @param object the wrapped XObject Job to be paused * @return true on success, false on failure. */ public boolean unscheduleJob(Object object) { try { return unscheduleJob(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return false; } }
/** * Return the trigger state as a ${@link JobState}, that holds both the integer trigger's inner value of the state * and a String as a human readable representation of that state */ public JobState getJobStatus(BaseObject object) throws SchedulerException, SchedulerPluginException { return getProtectedPlugin().getJobStatus(object, this.context); }
public JobState getJobStatus(Object object) throws SchedulerException, SchedulerPluginException { return getProtectedPlugin().getJobStatus(retrieveBaseObject(object), this.context); }
/** * Resume a XObject job that is in a {@link JobState#STATE_PAUSED} state. Can be called the same way as * {@link #scheduleJob(Object)} * * @param object the wrapped XObject Job to be paused * @return true on success, false on failure. */ public boolean resumeJob(Object object) { try { return resumeJob(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return false; } }
/** * Schedule the given XObject to be executed according to its parameters. Errors are returned in the context map. * Scheduling can be called for example: <code> #if($xwiki.scheduler.scheduleJob($job)!=true) * #error($xcontext.get("error") #else #info("Job scheduled") #end </code> * Where $job is an XObject, instance of the {@link SchedulerPlugin#XWIKI_JOB_CLASS} XClass * * @param object the XObject to be scheduled, an instance of the XClass XWiki.SchedulerJobClass * @return true on success, false on failure */ public boolean scheduleJob(Object object) { try { return scheduleJob(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return false; } }
/** * Return the trigger state of the given {@link com.xpn.xwiki.plugin.scheduler.SchedulerPlugin#XWIKI_JOB_CLASS} * XObject job. Possible values are : None (the trigger does not exists yet, or has been deleted), Normal, Blocked, * Complete, Error and Paused * * @param object the XObject job to give the state of * @return a String representing this state */ public String getStatus(Object object) { try { return getJobStatus(object.getXWikiObject()).getValue(); } catch (Exception e) { this.context.put("error", e.getMessage()); return null; } }
/** * Schedule all {@link com.xpn.xwiki.plugin.scheduler.SchedulerPlugin#XWIKI_JOB_CLASS} XObjects stored inside the * given Wiki document, according to each XObject own parameters. * * @param document the document holding the XObjects Jobs to be scheduled * @return true on success, false on failure. */ public boolean scheduleJobs(Document document) { boolean result = true; try { XWikiDocument doc = this.context.getWiki().getDocument(document.getFullName(), this.context); List<BaseObject> objects = doc.getObjects(SchedulerPlugin.XWIKI_JOB_CLASS); for (BaseObject object : objects) { result &= scheduleJob(object); } } catch (Exception e) { this.context.put("error", e.getMessage()); return false; } return result; }
/** * Return the trigger state as a ${@link JobState}, that holds both the integer trigger's inner value of the state * and a String as a human readable representation of that state */ public JobState getJobStatus(BaseObject object) throws SchedulerException { return getProtectedPlugin().getJobStatus(object, this.context); }
public JobState getJobStatus(Object object) throws SchedulerException, SchedulerPluginException { return getProtectedPlugin().getJobStatus(retrieveBaseObject(object), this.context); }
/** * Trigger a XObject job (execute it now). * * @param object the wrapped XObject Job to be triggered * @return true on success, false on failure. */ public boolean triggerJob(Object object) { try { return triggerJob(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return false; } }
/** * Pause the given XObject job by pausing all of its current triggers. Can be called the same way as * {@link #scheduleJob(Object)} * * @param object the wrapped XObject Job to be paused * @return true on success, false on failure. */ public boolean pauseJob(Object object) { try { return pauseJob(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return false; } }
/** * Unschedule a XObject job by deleting it from the jobs table. Can be called the same way as * {@link #scheduleJob(Object)} * * @param object the wrapped XObject Job to be paused * @return true on success, false on failure. */ public boolean unscheduleJob(Object object) { try { return unscheduleJob(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return false; } }
/** * Resume a XObject job that is in a {@link JobState#STATE_PAUSED} state. Can be called the same way as * {@link #scheduleJob(Object)} * * @param object the wrapped XObject Job to be paused * @return true on success, false on failure. */ public boolean resumeJob(Object object) { try { return resumeJob(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return false; } }
/** * Schedule the given XObject to be executed according to its parameters. Errors are returned in the context map. * Scheduling can be called for example: <code> #if($xwiki.scheduler.scheduleJob($job)!=true) * #error($context.get("error") #else #info("Job scheduled") #end </code> * Where $job is an XObject, instance of the {@link SchedulerPlugin#XWIKI_JOB_CLASS} XClass * * @param object the XObject to be scheduled, an instance of the XClass XWiki.SchedulerJobClass * @return true on success, false on failure */ public boolean scheduleJob(Object object) { try { return scheduleJob(retrieveBaseObject(object)); } catch (Exception e) { // we don't need to push the exception message in the context here // as it should already have been pushed by the throwing exception return false; } }
/** * Return the trigger state of the given {@link com.xpn.xwiki.plugin.scheduler.SchedulerPlugin#XWIKI_JOB_CLASS} * XObject job. Possible values are : None (the trigger does not exists yet, or has been deleted), Normal, Blocked, * Complete, Error and Paused * * @param object the XObject job to give the state of * @return a String representing this state */ public String getStatus(Object object) { try { return getJobStatus(object.getXWikiObject()).getValue(); } catch (Exception e) { this.context.put("error", e.getMessage()); return null; } }