private void validateSingleLabel(final String theLabel) { final String label = theLabel.trim(); if (StringUtils.isBlank(label)) { throw new IllegalArgumentException("Labels cannot be blank!"); } if (!LabelParser.isValidLabelName(label)) { throw new IllegalArgumentException("The label '" + label + "' contained spaces which is invalid."); } if (label.length() > LabelParser.MAX_LABEL_LENGTH) { throw new IllegalArgumentException("The label '" + label + "' exceeds the maximum length allowed for labels of " + LabelParser.MAX_LABEL_LENGTH + " characters."); } } }
public MappedCustomFieldValue getMappedImportValue(final ProjectImportMapper projectImportMapper, final ExternalCustomFieldValue customFieldValue, final FieldConfig fieldConfig) { final String label = customFieldValue.getValue(); // strip out invalid labels if (LabelParser.isValidLabelName(label)) { return new MappedCustomFieldValue(label); } return new MappedCustomFieldValue(null); } }
private ErrorCollection validateForSuggestion(final ApplicationUser user, final String token) { final ErrorCollection errors = new SimpleErrorCollection(); //check if the token contains any invalid characters. If it does return this to the client if(StringUtils.isNotEmpty(token) && !LabelParser.isValidLabelName(token)) { errors.addErrorMessage(beanFactory.getInstance(user).getText("label.service.error.label.invalid", token)); } return errors; }
if(!com.atlassian.jira.issue.label.LabelParser.isValidLabelName(labelString))
public MessageSet canMapImportValue(final ProjectImportMapper projectImportMapper, final ExternalCustomFieldValue customFieldValue, final FieldConfig fieldConfig, final I18nHelper i18n) { //add warnings for invalid labels final MessageSet messageSet = new MessageSetImpl(); final String label = customFieldValue.getValue(); if (!LabelParser.isValidLabelName(label)) { messageSet.addWarningMessage(i18n.getText("label.project.import.error", label)); messageSet.addWarningMessageInEnglish("Dropping label '" + label + "' because it contains invalid characters."); } return messageSet; }
public void validateParams(final ApplicationUser user, final SearchContext searchContext, final FieldValuesHolder fieldValuesHolder, final I18nHelper i18nHelper, final ErrorCollection errors) { final String url = SystemSearchConstants.forLabels().getUrlParameter(); final Collection<String> labels = (Collection<String>) fieldValuesHolder.get(url); if (labels != null) { for (String label : labels) { if (!LabelParser.isValidLabelName(label)) { errors.addErrorMessage(i18nHelper.getText("label.service.error.label.invalid", label)); } if (label.length() > LabelParser.MAX_LABEL_LENGTH) { errors.addErrorMessage(i18nHelper.getText("label.service.error.label.toolong", label)); } } } }
public void validateParams(OperationContext operationContext, ErrorCollection errorCollectionToAddTo, I18nHelper i18n, Issue issue, FieldScreenRenderLayoutItem fieldScreenRenderLayoutItem) { final Map fieldValuesHolder = operationContext.getFieldValuesHolder(); @SuppressWarnings("unchecked") final Set<Label> labels = (Set<Label>) fieldValuesHolder.get(getId()); if(labels != null && !labels.isEmpty()) { for (Label theLabel : labels) { final String label = theLabel.getLabel().trim(); if (!LabelParser.isValidLabelName(label)) { errorCollectionToAddTo.addError(IssueFieldConstants.LABELS, i18n.getText("label.service.error.label.invalid", label)); break; } if (label.length() > LabelParser.MAX_LABEL_LENGTH) { errorCollectionToAddTo.addError(IssueFieldConstants.LABELS, i18n.getText("label.service.error.label.toolong", label)); break; } } } else if (fieldScreenRenderLayoutItem.isRequired()) { errorCollectionToAddTo.addError(getId(), i18n.getText("issue.field.required", i18n.getText(getNameKey()))); } }
@Override public Label getSingularObjectFromString(final String string) throws FieldValidationException { if (string == null) { return null; } final int labelLength = StringUtils.length(string.trim()); if (LabelParser.isValidLabelName(string) && labelLength <= LabelParser.MAX_LABEL_LENGTH) { return new Label(null, null, string); } else { if (labelLength > LabelParser.MAX_LABEL_LENGTH) { throw new FieldValidationException(authContext.getI18nHelper().getText("label.service.error.label.toolong", string)); } else { throw new FieldValidationException(authContext.getI18nHelper().getText("label.service.error.label.invalid", string)); } } }
if (!LabelParser.isValidLabelName(label))
if (!LabelParser.isValidLabelName(label))