public class

CustomFieldUtils

extends Object
java.lang.Object
   ↳ com.atlassian.jira.issue.customfields.CustomFieldUtils

Summary

Constants
String CUSTOM_FIELD_PREFIX
String PARAM_REQUIRE_PROJECT_IDS This constant is deprecated. since v6.2.3 use getParamKeyRequireProjectIds() instead.
Public Constructors
CustomFieldUtils()
Public Methods
static List<IssueType> buildIssueTypes(ConstantsManager constantsManager, String[] issueTypes)
static List<JiraContextNode> buildJiraIssueContexts(boolean global, Long[] projectCategories, Long[] projects, JiraContextTreeManager treeManager)
static List<JiraContextNode> buildJiraIssueContexts(boolean global, Long[] projects, ProjectManager projectManager)
static Map<StringObject> buildParams(CustomField customField, FieldConfig config, Issue issue, FieldLayoutItem fieldLayoutItem, Object value, Map customFieldValuesHolder, Action action, Map displayParameters)
static List<IssueContext> convertToIssueContexts(Project project, List<String> issueTypeIds)
Converts list of issue type ids to IssueContexts.
static String createSearchParam(String customFieldId, String searchParam)
static Long getCustomFieldId(String key)
Given a custom field key, return its id or null.
static String getCustomFieldKey(String searchParamKey)
static String getDateFormat()
This method is deprecated. Use getDateFormat() instead. Since v5.0.
static String getDateTimeFormat()
This method is deprecated. Use getDateTimeFormat() instead. Since v5.0.
static String getParamKeyPrefixAtl()
The prefix to be used by Atlassian defined custom field parameter names, so that we could avoid naming conflict between Atlassian parameters and parameters used by third party plugin.
static String getParamKeyRequireProjectIds()
Name of the parameter that indicates whether the list of project id's associated with the current context should be loaded, either from the current issue (when editing value of an issue) or from FieldConfig and its FieldConfigScheme (when setting default value).
static Collection<Long> getProjectIdsForUser(ApplicationUser user, Collection<Long> projectIds, PermissionManager permissionManager, UserFilter userFilter)
If projectIds is not empty, return it.
static Collection<Long> getProjectIdsFromIssueOrFieldConfig(Issue issue, FieldConfig config, FieldConfigSchemeManager fieldConfigSchemeManager, ProjectManager projectManager)
Retrieve the list of project id's from issue or field config, in the following order:
  1. If issue is not null and issue.getProjectId() is not null, return a single list with issue.getProjectId()
  2. If config is not null, use it to retrieve the list of project id's associated with the current scheme
  3. Otherwise, return null
static Collection<Long> getProjectIdsFromProjectOrFieldConfig(Long projectIdFromIssue, FieldConfig config, FieldConfigSchemeManager fieldConfigSchemeManager, ProjectManager projectManager)
Retrieve the list of project id's from issue or field config, in the following order:
  1. If issue is not null and issue.getProjectId() is not null, return a single list with issue.getProjectId()
  2. If config is not null, use it to retrieve the list of project id's associated with the current scheme
  3. Otherwise, return null
static String getSearchParamSuffix(String searchParamKey)
static String getTimeFormat()
This method is deprecated. Use getTimeFormat() instead. Since v5.0.
static boolean isCollectionNotEmpty(Collection stringCollection)
static boolean isShownAndVisible(CustomField customField, ApplicationUser user, SearchContext searchContext, FieldVisibilityManager fieldVisibilityManager)
Checks if the custom field is in the search context scope (using isShown(com.atlassian.jira.issue.Issue)) and visible in all field schemes (using com.atlassian.jira.web.FieldVisibilityManager#isFieldHiddenInAllSchemes(String, SearchContext, User))
static boolean isUserHasPermissionToProjects(CustomField customField, ApplicationUser user)
Does the user have permission to at least one project that falls under this custom field.
static Map<CustomFieldObject> parseCustomFieldValuesFromActionParams(Map actionParameters, List<CustomField> customFields)
Parses action parameters (Map of Collections of Strings with [:]> as key)
static String prettyPrintOptions(Options options)
Protected Methods
static I18nHelper getI18nBean()
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String CUSTOM_FIELD_PREFIX

Constant Value: "customfield_"

public static final String PARAM_REQUIRE_PROJECT_IDS

This constant is deprecated.
since v6.2.3 use getParamKeyRequireProjectIds() instead.

See Also
  • {@link #getParamKeyRequireProjectIds()}
Constant Value: "requireProjectIds"

Public Constructors

public CustomFieldUtils ()

Public Methods

public static List<IssueType> buildIssueTypes (ConstantsManager constantsManager, String[] issueTypes)

public static List<JiraContextNode> buildJiraIssueContexts (boolean global, Long[] projectCategories, Long[] projects, JiraContextTreeManager treeManager)

public static List<JiraContextNode> buildJiraIssueContexts (boolean global, Long[] projects, ProjectManager projectManager)

public static Map<StringObject> buildParams (CustomField customField, FieldConfig config, Issue issue, FieldLayoutItem fieldLayoutItem, Object value, Map customFieldValuesHolder, Action action, Map displayParameters)

public static List<IssueContext> convertToIssueContexts (Project project, List<String> issueTypeIds)

Converts list of issue type ids to IssueContexts.

Parameters
project The project (may be null).
issueTypeIds Type ids as strings, eg. ["3", "4"]. May be null or empty.
Returns
  • a list of issue contexts, never null

public static String createSearchParam (String customFieldId, String searchParam)

public static Long getCustomFieldId (String key)

Given a custom field key, return its id or null.

Parameters
key eg. "customfield_10000"
Returns
  • Id, eg. 10000

public static String getCustomFieldKey (String searchParamKey)

public static String getDateFormat ()

This method is deprecated.
Use getDateFormat() instead. Since v5.0.

Returns the configured Javascript date picker format.

ie the format stored in the "jira.date.picker.javascript.format" application property.

Returns
  • the configured Javascript date picker format.

public static String getDateTimeFormat ()

This method is deprecated.
Use getDateTimeFormat() instead. Since v5.0.

Returns the configured Javascript date-time picker format.

ie the format stored in the "jira.date.time.picker.javascript.format" application property.

Returns
  • the configured Javascript date-time picker format.

public static String getParamKeyPrefixAtl ()

The prefix to be used by Atlassian defined custom field parameter names, so that we could avoid naming conflict between Atlassian parameters and parameters used by third party plugin.

public static String getParamKeyRequireProjectIds ()

Name of the parameter that indicates whether the list of project id's associated with the current context should be loaded, either from the current issue (when editing value of an issue) or from FieldConfig and its FieldConfigScheme (when setting default value).

This parameter could be used in two places now:

public static Collection<Long> getProjectIdsForUser (ApplicationUser user, Collection<Long> projectIds, PermissionManager permissionManager, UserFilter userFilter)

If projectIds is not empty, return it. Otherwise, return the list of project id's that the user could browse.

If projectIds is not provided and userFilter contains no roleIds, the list of browsable project ids will not be computed. An empty list will be returned instead.

public static Collection<Long> getProjectIdsFromIssueOrFieldConfig (Issue issue, FieldConfig config, FieldConfigSchemeManager fieldConfigSchemeManager, ProjectManager projectManager)

Retrieve the list of project id's from issue or field config, in the following order:

  1. If issue is not null and issue.getProjectId() is not null, return a single list with issue.getProjectId()
  2. If config is not null, use it to retrieve the list of project id's associated with the current scheme
  3. Otherwise, return null

public static Collection<Long> getProjectIdsFromProjectOrFieldConfig (Long projectIdFromIssue, FieldConfig config, FieldConfigSchemeManager fieldConfigSchemeManager, ProjectManager projectManager)

Retrieve the list of project id's from issue or field config, in the following order:

  1. If issue is not null and issue.getProjectId() is not null, return a single list with issue.getProjectId()
  2. If config is not null, use it to retrieve the list of project id's associated with the current scheme
  3. Otherwise, return null

public static String getSearchParamSuffix (String searchParamKey)

public static String getTimeFormat ()

This method is deprecated.
Use getTimeFormat() instead. Since v5.0.

Returns "12" or "24" from the Javascript date-time picker format.

Returns
  • "12" or "24" from the Javascript date-time picker format.

public static boolean isCollectionNotEmpty (Collection stringCollection)

public static boolean isShownAndVisible (CustomField customField, ApplicationUser user, SearchContext searchContext, FieldVisibilityManager fieldVisibilityManager)

Checks if the custom field is in the search context scope (using isShown(com.atlassian.jira.issue.Issue)) and visible in all field schemes (using com.atlassian.jira.web.FieldVisibilityManager#isFieldHiddenInAllSchemes(String, SearchContext, User))

Parameters
customField customfield to check visibility of
user current user
searchContext search context
fieldVisibilityManager field visibility bean
Returns
  • true if the customfield is in scope and visibile in all schemes in the specified search context
See Also

public static boolean isUserHasPermissionToProjects (CustomField customField, ApplicationUser user)

Does the user have permission to at least one project that falls under this custom field. If the custom field has not been configured for anything, it won't return true either

Parameters
customField custom field
user user
Returns
  • true if user has permission to at least one project that falls under this custom field, false otherwise

public static Map<CustomFieldObject> parseCustomFieldValuesFromActionParams (Map actionParameters, List<CustomField> customFields)

Parses action parameters (Map of Collections of Strings with [:]> as key)

Parameters
actionParameters map of action parameters
customFields a list of custom fields
Returns
  • a map of custom field to its value, never null

public static String prettyPrintOptions (Options options)

Protected Methods

protected static I18nHelper getI18nBean ()