private static void addError(ErrorCollection errorCollection, String fieldName, String errorKey) { if (errorCollection == null) { return; } if (fieldName == null) { errorCollection.addErrorMessage(getI18nBean().getText(errorKey)); return; } errorCollection.addError(fieldName, getI18nBean().getText(errorKey)); }
/** * Get the translated display name of a workflow transition. * * @param descriptor The action descriptor to get the name of * @return The name of the transition. */ public static String getWorkflowTransitionDisplayName(final ActionDescriptor descriptor) { if(descriptor == null) { return getI18nBean().getText("common.words.unknown"); } final Map<String, Object> metadata = descriptor.getMetaAttributes(); if (metadata.containsKey(JiraWorkflow.JIRA_META_ATTRIBUTE_I18N)) { final String key = (String) metadata.get(JiraWorkflow.JIRA_META_ATTRIBUTE_I18N); final String value = getI18nBean().getText(key); if ((value != null) && !"".equals(value.trim()) && !value.trim().equals(key.trim())) { return value; } } return descriptor.getName(); }
/** * JRA-4429 (prevent invalid characters) */ public static void checkInvalidCharacters(final String fieldValue, final String fieldName, final ErrorCollection errorCollection) { if (fieldValue.indexOf('<') != -1) { errorCollection.addError(fieldName, getI18nBean().getText("admin.errors.invalid.character", "'<'")); errorCollection.addReason(ErrorCollection.Reason.VALIDATION_FAILED); } if (fieldValue.indexOf('&') != -1) { errorCollection.addError(fieldName, getI18nBean().getText("admin.errors.invalid.character", "'&'")); errorCollection.addReason(ErrorCollection.Reason.VALIDATION_FAILED); } // JRA-5733 - '"' is also invalid if (fieldValue.indexOf('"') != -1) { errorCollection.addError(fieldName, getI18nBean().getText("admin.errors.invalid.character", "'\"'")); errorCollection.addReason(ErrorCollection.Reason.VALIDATION_FAILED); } }
/** * Appends "(Draft)" to the end of the workflow name for an draft workflow. * * @param workflow The workflow to create the display name for. * @return A String with the workflow name plus an optional (Draft). */ public static String getWorkflowDisplayName(final JiraWorkflow workflow) { if (workflow == null) { return null; } if (workflow.isDraftWorkflow()) { return workflow.getName() + " (" + getI18nBean().getText("common.words.draft") + ")"; } return workflow.getName(); }