/** * 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; } }
/** * 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; } }
/** * 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; }
/** * 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.getXObjects(SchedulerPlugin.XWIKI_JOB_CLASSREFERENCE); for (BaseObject object : objects) { result &= scheduleJob(object); } } catch (Exception e) { this.context.put("error", e.getMessage()); return false; } return result; }