@PublicApi public interface

ConstantsManager

com.atlassian.jira.config.ConstantsManager
Known Indirect Subclasses

@PublicApi

This interface is designed for plugins to consume (call its methods).

Clients of @PublicApi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicApi as per each product's API policy as long as the client does not implement/extend @PublicApi interfaces or classes (refer to each product's API policy for the exact guarantee---usually binary compatibility is guaranteed at least across minor versions).

Note: since @PublicApi interfaces and classes are not designed to be implemented or extended by clients, we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces annotated with @PublicSpi are safe to extend/implement).

Class Overview

Manager for issue types, statuses, priorities and resolutions. This manager is responsible for caching these constants as well as all the usual update, delete, add operations in the database.

Summary

Nested Classes
enum ConstantsManager.CONSTANT_TYPE  
Constants
String ALL_ISSUE_TYPES Used to retrieve all IssueTypes.
String ALL_STANDARD_ISSUE_TYPES Used to retrieve a standard IssueTypes.
String ALL_SUB_TASK_ISSUE_TYPES Used to retrieve a subtask IssueTypes.
Fields
public static final String ISSUE_TYPE_CONSTANT_TYPE This field is deprecated. Use ISSUE_TYPE
public static final String PRIORITY_CONSTANT_TYPE This field is deprecated. Use PRIORITY
public static final String RESOLUTION_CONSTANT_TYPE This field is deprecated. Use RESOLUTION
public static final String STATUS_CONSTANT_TYPE This field is deprecated. Use STATUS
Public Methods
boolean constantExists(String constantType, String name)
Checks if a constant exists.
List<IssueConstant> convertToConstantObjects(String constantType, Collection ids)
This method is deprecated. Use getConstantsByIds(CONSTANT_TYPE, java.util.Collection) instead. Deprecated since v7.0
List<String> expandIssueTypeIds(Collection<String> issueTypeIds)
Converts the 'special' ids of issue types to a list of issue type ids For example, converts a special id to a list of all sub-task issue types Also see ALL_STANDARD_ISSUE_TYPES, ALL_SUB_TASK_ISSUE_TYPES and ALL_ISSUE_TYPES.
List<String> getAllIssueTypeIds()
Returns all issueType Ids.
Collection<IssueType> getAllIssueTypeObjects()
Returns a list of IssueTypes.
IssueConstant getConstantByNameIgnoreCase(String constantType, String name)
Returns a constant by name ignoring the case of the name passed in.
IssueConstant getConstantObject(String constantType, String id)
Returns an IssueConstant object for the given type & id.
Collection getConstantObjects(String constantType)
Returns all IssueConstant objects for the given type.
@Nonnull List<IssueConstant> getConstantsByIds(ConstantsManager.CONSTANT_TYPE constantType, Collection<String> ids)
Converts the list of ids to the objects of appropriate types
Priority getDefaultPriority()
Returns the default priority configured in JIRA.
@Deprecated Priority getDefaultPriorityObject()
This method is deprecated. Since v7.0
List<IssueType> getEditableSubTaskIssueTypes()
Retrieves an mutable list of sub-task issues.
IssueConstant getIssueConstant(GenericValue issueConstantGV)
This method is deprecated. Deprecated since v7.0. You just shouldn't have GVs any more
IssueConstant getIssueConstantByName(String constantType, String name)
Returns a constant by name.
IssueType getIssueType(String id)
Given an IssueType ID this method retrieves that IssueType.
@Deprecated IssueType getIssueTypeObject(String id)
This method is deprecated. Since v7.0
Collection<Priority> getPriorities()
Retrieve all Priorities in JIRA.
String getPriorityName(String id)
Returns the priority Name for a given priority ID.
Priority getPriorityObject(String id)
Given a priority ID, this method retrieves that priority.
@Deprecated Collection<Priority> getPriorityObjects()
This method is deprecated. Since v7.0
Collection<IssueType> getRegularIssueTypeObjects()
Retrieve regular (non-subtask) issue types.
Resolution getResolution(String id)
Given a resolution ID, this method retrieves that resolution.
@Deprecated Resolution getResolutionObject(String id)
This method is deprecated. Use getResolution(String) instead. Since v7.0
@Deprecated Collection<Resolution> getResolutionObjects()
This method is deprecated. Since v7.0
Collection<Resolution> getResolutions()
Retrieve all Resolutions in JIRA.
Status getStatus(String id)
Returns a Status given an id.
Status getStatusByName(String name)
Searches for a given status by name.
Status getStatusByNameIgnoreCase(String name)
Searches for a given status by name ignoring case.
Status getStatusByTranslatedName(String name)
Searches for a given status by its translated name.
@Deprecated Status getStatusObject(String id)
This method is deprecated. Use getStatus(String) instead. Deprecated since v7.0
@Deprecated Collection<Status> getStatusObjects()
This method is deprecated. Since v7.0
Collection<Status> getStatuses()
Returns all statuses
Collection<IssueType> getSubTaskIssueTypeObjects()
Retrieves all the sub-task issue types
@Deprecated IssueType insertIssueType(String name, Long sequence, String style, String description, String iconurl)
This method is deprecated. Use insertIssueType(String, Long, String, String, Long) instead. Since v6.3.
IssueType insertIssueType(String name, Long sequence, String style, String description, Long avatarId)
Creates a new IssueType.
void invalidate(IssueConstant issueConstant)
Clear the cache for this Issue Constant.
void invalidateAll()
void recalculateIssueTypeSequencesAndStore(List<IssueType> issueTypes)
Resequences the supplied issuetypes into sequential order.
void recalculatePrioritySequencesAndStore(List<Priority> priorities)
Resequences the supplied priorities into sequential order.
void recalculateResolutionSequencesAndStore(List<Resolution> resolutions)
Resequences the supplied resolutions into sequential order.
void recalculateStatusSequencesAndStore(List<Status> statuses)
Resequences the supplied statuses into sequential order.
@Deprecated void refresh()
This method is deprecated. since v6.2. Use invalidateAll()
void refreshIssueTypes()
Reloads all IssueTypes from the DB.
void refreshPriorities()
Reloads all priorities from the DB.
void refreshResolutions()
Reloads all resolutions from the DB.
void refreshStatuses()
Reloads all statuses from DB.
void removeIssueType(String id)
This method is deprecated. Since 7.0. Do not use this method!!! Use removeIssueType(String, String).
@Deprecated void storeIssueTypes(List<GenericValue> issueTypes)
@Deprecated void updateIssueType(String id, String name, Long sequence, String style, String description, String iconurl)
This method is deprecated. use updateIssueType(String, String, Long, String, String, Long) since v6.3
void updateIssueType(String id, String name, Long sequence, String style, String description, Long avatarId)
Updates an existing issueType.
void validateCreateIssueType(String name, String style, String description, String iconurl, ErrorCollection errors, String nameFieldName)
Validates creation of a new issuetype.
void validateCreateIssueTypeWithAvatar(String name, String style, String description, String avatarId, ErrorCollection errors, String nameFieldName)
Validates creation of a new issuetype.
Option<Pair<StringErrorCollection.Reason>> validateName(String name, Option<IssueType> issueTypeToUpdate)
Validates the name of issue type.

Constants

public static final String ALL_ISSUE_TYPES

Used to retrieve all IssueTypes.

Constant Value: "-4"

public static final String ALL_STANDARD_ISSUE_TYPES

Used to retrieve a standard IssueTypes.

Constant Value: "-2"

public static final String ALL_SUB_TASK_ISSUE_TYPES

Used to retrieve a subtask IssueTypes.

Constant Value: "-3"

Fields

public static final String ISSUE_TYPE_CONSTANT_TYPE

This field is deprecated.
Use ISSUE_TYPE

Used in the generic getConstantObject(String, String) method

public static final String PRIORITY_CONSTANT_TYPE

This field is deprecated.
Use PRIORITY

Used in the generic getConstantObject(String, String) method

public static final String RESOLUTION_CONSTANT_TYPE

This field is deprecated.
Use RESOLUTION

Used in the generic getConstantObject(String, String) method

public static final String STATUS_CONSTANT_TYPE

This field is deprecated.
Use STATUS

Used in the generic getConstantObject(String, String) method

Public Methods

public boolean constantExists (String constantType, String name)

Checks if a constant exists.

Parameters
constantType See PRIORITY_CONSTANT_TYPE, STATUS_CONSTANT_TYPE, RESOLUTION_CONSTANT_TYPE, ISSUE_TYPE_CONSTANT_TYPE
name The name of the constant.
Returns
  • True if the constant exists. False otherwise

public List<IssueConstant> convertToConstantObjects (String constantType, Collection ids)

This method is deprecated.
Use getConstantsByIds(CONSTANT_TYPE, java.util.Collection) instead. Deprecated since v7.0

Converts the list of ids to the objects of appropriate types

Parameters
constantType the constant type. Case insenstive
ids list of constant ids or GenericValues
Returns
  • List of IssueConstant subclasses. Null if constantType is null or the ids are empty

public List<String> expandIssueTypeIds (Collection<String> issueTypeIds)

Converts the 'special' ids of issue types to a list of issue type ids For example, converts a special id to a list of all sub-task issue types Also see ALL_STANDARD_ISSUE_TYPES, ALL_SUB_TASK_ISSUE_TYPES and ALL_ISSUE_TYPES.

Parameters
issueTypeIds A collection of the issuetype Ids to retrieve.
Returns
  • A list of "actual" IssueType ID's expanded from the macro constants (or a new copy of the original list if it doesn't contain macros).

public List<String> getAllIssueTypeIds ()

Returns all issueType Ids.

Returns
  • A list of all the IssueType Ids.

public Collection<IssueType> getAllIssueTypeObjects ()

Returns a list of IssueTypes.

Returns

public IssueConstant getConstantByNameIgnoreCase (String constantType, String name)

Returns a constant by name ignoring the case of the name passed in.

Parameters
constantType See PRIORITY_CONSTANT_TYPE, STATUS_CONSTANT_TYPE, RESOLUTION_CONSTANT_TYPE, ISSUE_TYPE_CONSTANT_TYPE
name The Name of the constant, case-insensitive.
Returns
  • An IssueConstant (or null if not found)

public IssueConstant getConstantObject (String constantType, String id)

Returns an IssueConstant object for the given type & id.

Parameters
constantType See PRIORITY_CONSTANT_TYPE, STATUS_CONSTANT_TYPE, RESOLUTION_CONSTANT_TYPE, ISSUE_TYPE_CONSTANT_TYPE
id The id of the constant.
Returns

public Collection getConstantObjects (String constantType)

Returns all IssueConstant objects for the given type.

Returns

@Nonnull public List<IssueConstant> getConstantsByIds (ConstantsManager.CONSTANT_TYPE constantType, Collection<String> ids)

Converts the list of ids to the objects of appropriate types

Parameters
constantType Type of constant
ids list of constant ids
Returns
  • List of IssueConstant subclasses.

public Priority getDefaultPriority ()

Returns the default priority configured in JIRA.

Returns
  • The default priority

@Deprecated public Priority getDefaultPriorityObject ()

This method is deprecated.
Since v7.0

Returns the default priority configured in JIRA.

Returns
  • The default priority.

public List<IssueType> getEditableSubTaskIssueTypes ()

Retrieves an mutable list of sub-task issues. The list is mutable, that is its elements can be reordered added to or removed. The elements of the list, that is the issue types themselves, are not mutable.

Returns
  • A List of editable sub-task

public IssueConstant getIssueConstant (GenericValue issueConstantGV)

This method is deprecated.
Deprecated since v7.0. You just shouldn't have GVs any more

Converts a constant GenericValue to an IssueConstant object.

Parameters
issueConstantGV the constant GenericValue.
Returns

public IssueConstant getIssueConstantByName (String constantType, String name)

Returns a constant by name.

Parameters
constantType See PRIORITY_CONSTANT_TYPE, STATUS_CONSTANT_TYPE, RESOLUTION_CONSTANT_TYPE, ISSUE_TYPE_CONSTANT_TYPE
name The Name of the constant.
Returns
  • The IssueConstant

public IssueType getIssueType (String id)

Given an IssueType ID this method retrieves that IssueType.

Parameters
id The ID of the IssueType.
Returns
  • An IssueType

@Deprecated public IssueType getIssueTypeObject (String id)

This method is deprecated.
Since v7.0

Given an IssueType ID this method retrieves that IssueType.

Parameters
id The ID of the IssueType.
Returns

public Collection<Priority> getPriorities ()

Retrieve all Priorities in JIRA.

Returns

public String getPriorityName (String id)

Returns the priority Name for a given priority ID.

Parameters
id The id of a priority
Returns
  • The name of the priority with the given ID, or an i18n'd String indicating that no priority is set (e.g. "None") if the ID is null.

public Priority getPriorityObject (String id)

Given a priority ID, this method retrieves that priority.

Parameters
id The id of the priority
Returns

@Deprecated public Collection<Priority> getPriorityObjects ()

This method is deprecated.
Since v7.0

Retrieve all Priorities in JIRA.

Returns

public Collection<IssueType> getRegularIssueTypeObjects ()

Retrieve regular (non-subtask) issue types.

Returns

public Resolution getResolution (String id)

Given a resolution ID, this method retrieves that resolution.

Parameters
id The id of the resolution
Returns
  • A resolution

@Deprecated public Resolution getResolutionObject (String id)

This method is deprecated.
Use getResolution(String) instead. Since v7.0

Given a resolution ID, this method retrieves that resolution.

Parameters
id The id of the resolution
Returns

@Deprecated public Collection<Resolution> getResolutionObjects ()

This method is deprecated.
Since v7.0

Retrieve all Resolutions in JIRA.

Returns

public Collection<Resolution> getResolutions ()

Retrieve all Resolutions in JIRA.

Returns

public Status getStatus (String id)

Returns a Status given an id.

Parameters
id The id of a status
Returns
  • Returns a status

public Status getStatusByName (String name)

Searches for a given status by name. This is not the most efficient implementation. If the name is not found, or the given name is null, then it returns null.

Parameters
name The name of the status.
Returns
  • A Status object with the given name, or null if none found.

public Status getStatusByNameIgnoreCase (String name)

Searches for a given status by name ignoring case. This is not the most efficient implementation. If the name is not found, or the given name is null, then it returns null.

Parameters
name The name of the status.
Returns
  • A Status object with the given name, or null if none found.

public Status getStatusByTranslatedName (String name)

Searches for a given status by its translated name. If no matching translated name is found the true (untranslated) name will be tried. If the name is not found, or the given name is null, then it returns null.

Parameters
name The name of the status.
Returns
  • A Status object with the given name, or null if none found.

@Deprecated public Status getStatusObject (String id)

This method is deprecated.
Use getStatus(String) instead. Deprecated since v7.0

Returns a Status given an id.

Parameters
id The id of a status
Returns

@Deprecated public Collection<Status> getStatusObjects ()

This method is deprecated.
Since v7.0

Returns all statuses

Returns
  • Returns a Collection of Status objects

public Collection<Status> getStatuses ()

Returns all statuses

Returns
  • Returns a Collection of status Statuss.

public Collection<IssueType> getSubTaskIssueTypeObjects ()

Retrieves all the sub-task issue types

Returns

@Deprecated public IssueType insertIssueType (String name, Long sequence, String style, String description, String iconurl)

This method is deprecated.
Use insertIssueType(String, Long, String, String, Long) instead. Since v6.3.

Creates a new IssueType.

Note this method does not validate the input - i.e. It does not check for duplicate names etc. Use this method in conjunction with validateCreateIssueType(String, String, String, String, com.atlassian.jira.util.ErrorCollection, String)

Parameters
name Name of the new IssueType
sequence Sequence number used for ordering the issuetypes in the UI.
style Used to record the type of issue, such as SUBTASK. Null for regular issues.
description A short description of the new issue type.
iconurl A URL to an icon to be used for the new issueType.
Returns
  • The newly created IssueType
Throws
CreateException If there is an error creating this Issue Type.

public IssueType insertIssueType (String name, Long sequence, String style, String description, Long avatarId)

Creates a new IssueType.

Note this method does not validate the input - i.e. It does not check for duplicate names etc. Use this method in conjunction with validateCreateIssueType(String, String, String, String, com.atlassian.jira.util.ErrorCollection, String)

Parameters
name Name of the new IssueType
sequence Sequence number used for ordering the issuetypes in the UI.
style Used to record the type of issue, such as SUBTASK. Null for regular issues.
description A short description of the new issue type.
avatarId Avatar id,
Returns
  • The newly created IssueType
Throws
CreateException If there is an error creating this Issue Type.

public void invalidate (IssueConstant issueConstant)

Clear the cache for this Issue Constant. Implementations may clear additional IssueConstants at their discretion.

public void invalidateAll ()

public void recalculateIssueTypeSequencesAndStore (List<IssueType> issueTypes)

Resequences the supplied issuetypes into sequential order.

public void recalculatePrioritySequencesAndStore (List<Priority> priorities)

Resequences the supplied priorities into sequential order.

public void recalculateResolutionSequencesAndStore (List<Resolution> resolutions)

Resequences the supplied resolutions into sequential order.

public void recalculateStatusSequencesAndStore (List<Status> statuses)

Resequences the supplied statuses into sequential order.

@Deprecated public void refresh ()

This method is deprecated.
since v6.2. Use invalidateAll()

Sets all cached copies of constant to null. This will cause them to be re-loaded from the DB the next time they are accessed.

public void refreshIssueTypes ()

Reloads all IssueTypes from the DB.

public void refreshPriorities ()

Reloads all priorities from the DB.

public void refreshResolutions ()

Reloads all resolutions from the DB.

public void refreshStatuses ()

Reloads all statuses from DB.

public void removeIssueType (String id)

This method is deprecated.
Since 7.0. Do not use this method!!! Use removeIssueType(String, String).

Removes an existing issueType. This will cause a invalidate of all issue types (i.e. reload from the DB).

THIS METHOD IS BROKEN AND SHOULD NEVER BE USED SINCE v5.0.

Parameters
id ID of an existing issueType
Throws
RemoveException if the issueType with id doesn't exist, or an error occurred removing the issue.

@Deprecated public void storeIssueTypes (List<GenericValue> issueTypes)

This method is deprecated.
Deprecated since v7.0. Use $updateIssueType(String, String, Long, String, String, Long) or $recalculateIssueTypeSequencesAndStore(java.util.List) instead.

Bulk operation to store a list of issueTypes.

Parameters
issueTypes A list of IssueType GenericValues
Throws
DataAccessException indicates an error in the Data Access Layer

@Deprecated public void updateIssueType (String id, String name, Long sequence, String style, String description, String iconurl)

This method is deprecated.
use updateIssueType(String, String, Long, String, String, Long) since v6.3

Updates an existing issueType. This will cause a invalidate of all issue types (i.e. reload from the DB).

Parameters
id ID of the existing issuetype.
name Name of the new IssueType
sequence Sequence number used for ordering the issuetypes in the UI.
style Used to record the type of issue, such as SUBTASK. Null for regular issues.
description A short description of the new issue type.
iconurl A URL to an icon to be used for the new issueType.
Throws
DataAccessException indicates an error in the Data Access Layer

public void updateIssueType (String id, String name, Long sequence, String style, String description, Long avatarId)

Updates an existing issueType. This will cause a invalidate of all issue types (i.e. reload from the DB).

Parameters
id ID of the existing issuetype.
name Name of the new IssueType
sequence Sequence number used for ordering the issuetypes in the UI.
style Used to record the type of issue, such as SUBTASK. Null for regular issues.
description A short description of the new issue type.
avatarId avatarid of new issueType.
Throws
DataAccessException indicates an error in the Data Access Layer

public void validateCreateIssueType (String name, String style, String description, String iconurl, ErrorCollection errors, String nameFieldName)

Validates creation of a new issuetype. In particular, this function checks that a name has been submitted, no other issueTypes with the same name exist, and that the icon URL exists.

Parameters
name Name of the new IssueType
style Used to record the type of issue, such as SUBTASK. Null for regular issues.
description A short description of the new issue type.
iconurl A URL to an icon to be used for the new issueType.
errors A collection of errors used to pass back any problems.
nameFieldName The field to which the errors should be added.

public void validateCreateIssueTypeWithAvatar (String name, String style, String description, String avatarId, ErrorCollection errors, String nameFieldName)

Validates creation of a new issuetype. In particular, this function checks that a name has been submitted, no other issueTypes with the same name exist and correct avatarId is passed.

Parameters
name Name of the new IssueType
style Used to record the type of issue, such as SUBTASK. Null for regular issues.
description A short description of the new issue type.
avatarId An avatar id.
errors A collection of errors used to pass back any problems.
nameFieldName The field to which the errors should be added.

public Option<Pair<StringErrorCollection.Reason>> validateName (String name, Option<IssueType> issueTypeToUpdate)

Validates the name of issue type. If the validation passes returns Option.none, else returns na Option with a pair of error message and reason.