/** * Called when a {@link Trigger} is loaded into memory and started. * * @param project * given so that the persisted form of this object won't have to have a back pointer. * @param newInstance * True if this may be a newly created trigger first attached to the {@link Project} (generally if the project is being created or configured). * False if this is invoked for a {@link Project} loaded from disk. * @see Items#currentlyUpdatingByXml */ public void start(J project, boolean newInstance) { this.job = project; try {// reparse the tabs with the job as the hash if (spec != null) { this.tabs = CronTabList.create(spec, Hash.from(project.getFullName())); } else { LOGGER.log(Level.WARNING, "The job {0} has a null crontab spec which is incorrect", job.getFullName()); } } catch (ANTLRException e) { // this shouldn't fail because we've already parsed stuff in the constructor, // so if it fails, use whatever 'tabs' that we already have. LOGGER.log(Level.WARNING, String.format("Failed to parse crontab spec %s in job %s", spec, project.getFullName()), e); } }
/** * Performs syntax check. */ public FormValidation doCheckSpec(@QueryParameter String value, @AncestorInPath Item item) { try { CronTabList ctl = CronTabList.create(fixNull(value), item != null ? Hash.from(item.getFullName()) : null); Collection<FormValidation> validations = new ArrayList<>(); updateValidationsForSanity(validations, ctl); updateValidationsForNextRun(validations, ctl); return FormValidation.aggregate(validations); } catch (ANTLRException e) { if (value.trim().indexOf('\n')==-1 && value.contains("**")) return FormValidation.error(Messages.TimerTrigger_MissingWhitespace()); return FormValidation.error(e.getMessage()); } }
/** * Called when a {@link Trigger} is loaded into memory and started. * * @param project * given so that the persisted form of this object won't have to have a back pointer. * @param newInstance * True if this may be a newly created trigger first attached to the {@link Project} (generally if the project is being created or configured). * False if this is invoked for a {@link Project} loaded from disk. * @see Items#currentlyUpdatingByXml */ public void start(J project, boolean newInstance) { this.job = project; try {// reparse the tabs with the job as the hash if (spec != null) { this.tabs = CronTabList.create(spec, Hash.from(project.getFullName())); } else { LOGGER.log(Level.WARNING, "The job {0} has a null crontab spec which is incorrect", job.getFullName()); } } catch (ANTLRException e) { // this shouldn't fail because we've already parsed stuff in the constructor, // so if it fails, use whatever 'tabs' that we already have. LOGGER.log(Level.WARNING, String.format("Failed to parse crontab spec %s in job %s", spec, project.getFullName()), e); } }
/** * Performs syntax check. */ public FormValidation doCheckSpec(@QueryParameter String value, @AncestorInPath Item item) { try { CronTabList ctl = CronTabList.create(fixNull(value), item != null ? Hash.from(item.getFullName()) : null); Collection<FormValidation> validations = new ArrayList<>(); updateValidationsForSanity(validations, ctl); updateValidationsForNextRun(validations, ctl); return FormValidation.aggregate(validations); } catch (ANTLRException e) { if (value.trim().indexOf('\n')==-1 && value.contains("**")) return FormValidation.error(Messages.TimerTrigger_MissingWhitespace()); return FormValidation.error(e.getMessage()); } }