/** * 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()); } }
@Restricted(NoExternalUse.class) public FormValidation doCheckLabelExpr(@AncestorInPath AbstractProject<?,?> project, @QueryParameter String value) { if (Util.fixEmptyAndTrim(value) == null) return FormValidation.error("No expressions provided"); List<FormValidation> validations = new ArrayList<FormValidation>(); for (String expr: getExprValues(value)) { final FormValidation validation = AbstractProjectDescriptor.validateLabelExpression(expr, project); validations.add(validation); } return FormValidation.aggregate(validations); } }
/** * Parses the example message with the specified regular expression and script. * * @param example * example that should be resolve to a warning * @param regexp * the regular expression * @param script * the script * @return the validation result */ public FormValidation doCheckExample(@QueryParameter final String example, @QueryParameter final String regexp, @QueryParameter final String script) { if (!canRunScripts()) { return NO_RUN_SCRIPT_PERMISSION_WARNING; } if (StringUtils.isNotBlank(example) && StringUtils.isNotBlank(regexp) && StringUtils.isNotBlank(script)) { FormValidation response = parseExample(script, example, regexp, containsNewline(regexp)); if (example.length() <= MAX_EXAMPLE_SIZE) { return response; } return FormValidation.aggregate(Arrays.asList(FormValidation.warning(Messages.GroovyParser_long_examples_will_be_truncated()), response)); } else { return FormValidation.ok(); } }
/** * Check the template's name. Name must conform to restrictions on VM * naming * * @param value Current name * @param templateDisabled Is the template disabled * @param osType OS type * @return The validation result */ public FormValidation doCheckTemplateName( @QueryParameter String value, @QueryParameter boolean templateDisabled, @QueryParameter String osType) { List<FormValidation> errors = new ArrayList<>(); // Check whether the template name is valid, and then check // whether it would be shortened on VM creation. if (!AzureUtil.isValidTemplateName(value)) { errors.add(FormValidation.error(Messages.Azure_GC_Template_Name_Not_Valid())); } if (templateDisabled) { errors.add(FormValidation.warning(Messages.Azure_GC_TemplateStatus_Warn_Msg())); } if (errors.size() > 0) { return FormValidation.aggregate(errors); } return FormValidation.ok(); }
/** * Parses the example message with the specified regular expression and script. * * @param example * example that should be resolve to a warning * @param regexp * the regular expression * @param script * the script * * @return the validation result */ public FormValidation doCheckExample(@QueryParameter final String example, @QueryParameter final String regexp, @QueryParameter final String script) { if (isNotAllowedToRunScripts()) { return NO_RUN_SCRIPT_PERMISSION_WARNING; } if (StringUtils.isNotBlank(example) && StringUtils.isNotBlank(regexp) && StringUtils.isNotBlank(script)) { FormValidation response = parseExample(script, example, regexp, containsNewline(regexp)); if (example.length() <= MAX_EXAMPLE_SIZE) { return response; } return FormValidation.aggregate(Arrays.asList( FormValidation.warning(Messages.GroovyParser_long_examples_will_be_truncated()), response)); } else { return FormValidation.ok(); } }
return FormValidation.aggregate(formValidations);
/** * 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()); } }