Package com.atlassian.jira.config
Class DefaultConstantsManager
java.lang.Object
com.atlassian.jira.config.DefaultConstantsManager
- All Implemented Interfaces:
ConstantsManager
,InitializingComponent
public class DefaultConstantsManager
extends Object
implements ConstantsManager, InitializingComponent
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.config.ConstantsManager
ConstantsManager.CONSTANT_TYPE
-
Field Summary
FieldsFields inherited from interface com.atlassian.jira.config.ConstantsManager
ALL_ISSUE_TYPES, ALL_STANDARD_ISSUE_TYPES, ALL_SUB_TASK_ISSUE_TYPES, ISSUE_CONSTANT_NAME_SEARCH_PATTERN, ISSUE_TYPE_CONSTANT_TYPE, PRIORITY_CONSTANT_TYPE, RESOLUTION_CONSTANT_TYPE, STATUS_CONSTANT_TYPE
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultConstantsManager
(JiraAuthenticationContext authenticationContext, OfBizDelegator ofBizDelegator, DbConnectionManager dbConnectionManager, IssueConstantFactory issueConstantFactory, com.atlassian.cache.CacheManager cacheManager, com.atlassian.event.api.EventPublisher eventPublisher) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called after all the beans are constructed and the ApplicationContext is fully populated.boolean
constantExists
(String constantType, String name) Checks if a constant exists.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 seeConstantsManager.ALL_STANDARD_ISSUE_TYPES
,ConstantsManager.ALL_SUB_TASK_ISSUE_TYPES
andConstantsManager.ALL_ISSUE_TYPES
.Returns all issueType Ids.Returns a list of IssueTypes.getConstantByNameIgnoreCase
(String constantType, String name) Returns a constant by name ignoring the case of the name passed in.getConstantObject
(String constantType, String id) Returns anIssueConstant
object for the given type & id.Collection<? extends IssueConstant>
getConstantObjects
(String constantType) Returns allIssueConstant
objects for the given type.getConstantsByIds
(ConstantsManager.CONSTANT_TYPE constantType, Collection<String> ids) Converts the list of ids to the objects of appropriate typesReturns the default priority configured in JIRA.Retrieves an mutable list of sub-task issues.getIssueConstant
(org.ofbiz.core.entity.GenericValue issueConstantGV) Converts a constantGenericValue
to anIssueConstant
object.getIssueConstantByName
(String constantType, String name) Returns a constant by name.getIssueType
(String id) Given an IssueType ID this method retrieves that IssueType.Retrieve all Priorities in JIRA.Returns the priority Name for a given priority ID.Given a priority ID, this method retrieves that priority.Retrieve regular (non-subtask) issue types.getResolution
(String id) Given a resolution ID, this method retrieves that resolution.Retrieve all Resolutions in JIRA.Returns a Status given an id.getStatusByName
(String name) Searches for a given status by name.Searches for a given status by name ignoring case.Searches for a given status by its translated name.Returns all statusesRetrieves all the sub-task issue typesCreates a new IssueType.Creates a new IssueType.void
invalidate
(IssueConstant constant) Clear the cache for this Issue Constant.void
Sets all cached copies of constants to null.void
onClearCache
(ClearCacheEvent ignored) void
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.void
Reloads all IssueTypes from the DB.void
Reloads all priorities from the DB.void
Reloads all resolutions from the DB.void
Reloads all statuses from DB.void
Removes an existing issueType.void
updateIssueType
(String id, String name, Long sequence, String style, String description, Long avatarId) Updates an existing issueType.void
updateIssueType
(String id, String name, Long sequence, String style, String description, String iconurl) 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.io.atlassian.fugue.Option<Pair<String,
ErrorCollection.Reason>> validateName
(String name, io.atlassian.fugue.Option<IssueType> issueTypeToUpdate) Validates the name of issue type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.atlassian.jira.config.ConstantsManager
getStatusObject
-
Field Details
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTH- See Also:
-
-
Constructor Details
-
DefaultConstantsManager
public DefaultConstantsManager(JiraAuthenticationContext authenticationContext, OfBizDelegator ofBizDelegator, DbConnectionManager dbConnectionManager, IssueConstantFactory issueConstantFactory, com.atlassian.cache.CacheManager cacheManager, com.atlassian.event.api.EventPublisher eventPublisher)
-
-
Method Details
-
afterInstantiation
Description copied from interface:InitializingComponent
Called after all the beans are constructed and the ApplicationContext is fully populated. Order of execution is order of bean creation, driven by InitializingComponentProcessor.- Specified by:
afterInstantiation
in interfaceInitializingComponent
- Throws:
Exception
-
onClearCache
-
onIssueTypeDeleted
-
getStatuses
Description copied from interface:ConstantsManager
Returns all statuses- Specified by:
getStatuses
in interfaceConstantsManager
- Returns:
- Returns a Collection of status
Status
s.
-
getStatus
Description copied from interface:ConstantsManager
Returns a Status given an id.- Specified by:
getStatus
in interfaceConstantsManager
- Parameters:
id
- The id of a status- Returns:
- Returns a status
-
refreshStatuses
public void refreshStatuses()Description copied from interface:ConstantsManager
Reloads all statuses from DB.- Specified by:
refreshStatuses
in interfaceConstantsManager
-
getConstantObject
Description copied from interface:ConstantsManager
Returns anIssueConstant
object for the given type & id.- Specified by:
getConstantObject
in interfaceConstantsManager
- Parameters:
constantType
- SeeConstantsManager.CONSTANT_TYPE
id
- The id of the constant.- Returns:
- A
IssueConstant
object. Null if it doesn't exist.
-
getConstantObjects
Description copied from interface:ConstantsManager
Returns allIssueConstant
objects for the given type.- Specified by:
getConstantObjects
in interfaceConstantsManager
- Parameters:
constantType
- SeeConstantsManager.CONSTANT_TYPE
- Returns:
- A collection of
IssueConstant
object; will benull
if and only ifconstantType
is invalid
-
getConstantsByIds
@Nonnull public List<IssueConstant> getConstantsByIds(@Nonnull ConstantsManager.CONSTANT_TYPE constantType, @Nonnull Collection<String> ids) Description copied from interface:ConstantsManager
Converts the list of ids to the objects of appropriate types- Specified by:
getConstantsByIds
in interfaceConstantsManager
- Parameters:
constantType
- Type of constantids
- list of constant ids- Returns:
- List of IssueConstant subclasses.
-
constantExists
Description copied from interface:ConstantsManager
Checks if a constant exists.- Specified by:
constantExists
in interfaceConstantsManager
- Parameters:
constantType
- SeeConstantsManager.PRIORITY_CONSTANT_TYPE
,ConstantsManager.STATUS_CONSTANT_TYPE
,ConstantsManager.RESOLUTION_CONSTANT_TYPE
,ConstantsManager.ISSUE_TYPE_CONSTANT_TYPE
name
- The name of the constant.- Returns:
- True if the constant exists. False otherwise
-
getIssueConstantByName
Description copied from interface:ConstantsManager
Returns a constant by name.- Specified by:
getIssueConstantByName
in interfaceConstantsManager
- Parameters:
constantType
- SeeConstantsManager.PRIORITY_CONSTANT_TYPE
,ConstantsManager.STATUS_CONSTANT_TYPE
,ConstantsManager.RESOLUTION_CONSTANT_TYPE
,ConstantsManager.ISSUE_TYPE_CONSTANT_TYPE
name
- The Name of the constant.- Returns:
- The IssueConstant
-
getConstantByNameIgnoreCase
Description copied from interface:ConstantsManager
Returns a constant by name ignoring the case of the name passed in.- Specified by:
getConstantByNameIgnoreCase
in interfaceConstantsManager
- Parameters:
constantType
- SeeConstantsManager.PRIORITY_CONSTANT_TYPE
,ConstantsManager.STATUS_CONSTANT_TYPE
,ConstantsManager.RESOLUTION_CONSTANT_TYPE
,ConstantsManager.ISSUE_TYPE_CONSTANT_TYPE
name
- The Name of the constant, case-insensitive.- Returns:
- An IssueConstant (or null if not found)
-
insertIssueType
public IssueType insertIssueType(String name, Long sequence, String style, String description, String iconurl) throws CreateException Description copied from interface:ConstantsManager
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
ConstantsManager.validateCreateIssueType(String, String, String, String, com.atlassian.jira.util.ErrorCollection, String)
- Specified by:
insertIssueType
in interfaceConstantsManager
- Parameters:
name
- Name of the new IssueTypesequence
- 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.
-
insertIssueType
public IssueType insertIssueType(String name, Long sequence, String style, String description, Long avatarId) throws CreateException Description copied from interface:ConstantsManager
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
ConstantsManager.validateCreateIssueType(String, String, String, String, com.atlassian.jira.util.ErrorCollection, String)
- Specified by:
insertIssueType
in interfaceConstantsManager
- Parameters:
name
- Name of the new IssueTypesequence
- 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.
-
validateCreateIssueType
public void validateCreateIssueType(String name, String style, String description, String iconurl, ErrorCollection errors, String nameFieldName) Description copied from interface:ConstantsManager
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.- Specified by:
validateCreateIssueType
in interfaceConstantsManager
- Parameters:
name
- Name of the new IssueTypestyle
- 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.
-
validateName
public io.atlassian.fugue.Option<Pair<String,ErrorCollection.Reason>> validateName(String name, io.atlassian.fugue.Option<IssueType> issueTypeToUpdate) Description copied from interface:ConstantsManager
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.- Specified by:
validateName
in interfaceConstantsManager
-
validateCreateIssueTypeWithAvatar
public void validateCreateIssueTypeWithAvatar(String name, String style, String description, String avatarId, ErrorCollection errors, String nameFieldName) Description copied from interface:ConstantsManager
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.- Specified by:
validateCreateIssueTypeWithAvatar
in interfaceConstantsManager
- Parameters:
name
- Name of the new IssueTypestyle
- 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.
-
updateIssueType
public void updateIssueType(String id, String name, Long sequence, String style, String description, String iconurl) throws DataAccessException Description copied from interface:ConstantsManager
Updates an existing issueType. This will cause a invalidate of all issue types (i.e. reload from the DB).- Specified by:
updateIssueType
in interfaceConstantsManager
- Parameters:
id
- ID of the existing issuetype.name
- Name of the new IssueTypesequence
- 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
-
updateIssueType
public void updateIssueType(String id, String name, Long sequence, String style, String description, Long avatarId) throws DataAccessException Description copied from interface:ConstantsManager
Updates an existing issueType. This will cause a invalidate of all issue types (i.e. reload from the DB).- Specified by:
updateIssueType
in interfaceConstantsManager
- Parameters:
id
- ID of the existing issuetype.name
- Name of the new IssueTypesequence
- 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
-
removeIssueType
Description copied from interface:ConstantsManager
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.
- Specified by:
removeIssueType
in interfaceConstantsManager
- Parameters:
id
- ID of an existing issueType- Throws:
RemoveException
- if the issueType with id doesn't exist, or an error occurred removing the issue.
-
recalculateIssueTypeSequencesAndStore
Description copied from interface:ConstantsManager
Resequences the supplied issuetypes into sequential order.- Specified by:
recalculateIssueTypeSequencesAndStore
in interfaceConstantsManager
-
recalculatePrioritySequencesAndStore
Description copied from interface:ConstantsManager
Resequences the supplied priorities into sequential order.- Specified by:
recalculatePrioritySequencesAndStore
in interfaceConstantsManager
-
recalculateStatusSequencesAndStore
Description copied from interface:ConstantsManager
Resequences the supplied statuses into sequential order.- Specified by:
recalculateStatusSequencesAndStore
in interfaceConstantsManager
-
recalculateResolutionSequencesAndStore
Description copied from interface:ConstantsManager
Resequences the supplied resolutions into sequential order.- Specified by:
recalculateResolutionSequencesAndStore
in interfaceConstantsManager
-
invalidateAll
public void invalidateAll()Description copied from interface:ConstantsManager
Sets all cached copies of constants to null. This will cause them to be re-loaded from the DB the next time they are accessed.- Specified by:
invalidateAll
in interfaceConstantsManager
-
invalidate
Description copied from interface:ConstantsManager
Clear the cache for this Issue Constant. Implementations may clear additional IssueConstants at their discretion.- Specified by:
invalidate
in interfaceConstantsManager
-
expandIssueTypeIds
Description copied from interface:ConstantsManager
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 seeConstantsManager.ALL_STANDARD_ISSUE_TYPES
,ConstantsManager.ALL_SUB_TASK_ISSUE_TYPES
andConstantsManager.ALL_ISSUE_TYPES
.- Specified by:
expandIssueTypeIds
in interfaceConstantsManager
- 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).
-
getAllIssueTypeIds
Description copied from interface:ConstantsManager
Returns all issueType Ids.- Specified by:
getAllIssueTypeIds
in interfaceConstantsManager
- Returns:
- A list of all the IssueType Ids.
-
getIssueConstant
Description copied from interface:ConstantsManager
Converts a constantGenericValue
to anIssueConstant
object.- Specified by:
getIssueConstant
in interfaceConstantsManager
- Parameters:
issueConstantGV
- the constantGenericValue
.- Returns:
- An
IssueConstant
object.
-
getPriorities
Description copied from interface:ConstantsManager
Retrieve all Priorities in JIRA.- Specified by:
getPriorities
in interfaceConstantsManager
- Returns:
- A list of Priority
Priority
s.
-
getPriorityObject
Description copied from interface:ConstantsManager
Given a priority ID, this method retrieves that priority.- Specified by:
getPriorityObject
in interfaceConstantsManager
- Parameters:
id
- The id of the priority- Returns:
- A
Priority
object.
-
getDefaultPriority
Description copied from interface:ConstantsManager
Returns the default priority configured in JIRA.- Specified by:
getDefaultPriority
in interfaceConstantsManager
- Returns:
- The default priority
-
getPriorityName
Description copied from interface:ConstantsManager
Returns the priority Name for a given priority ID.- Specified by:
getPriorityName
in interfaceConstantsManager
- 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.
-
refreshPriorities
public void refreshPriorities()Description copied from interface:ConstantsManager
Reloads all priorities from the DB.- Specified by:
refreshPriorities
in interfaceConstantsManager
-
getResolutions
Description copied from interface:ConstantsManager
Retrieve all Resolutions in JIRA.- Specified by:
getResolutions
in interfaceConstantsManager
- Returns:
- A List of Resolution
Resolution
s.
-
getResolution
Description copied from interface:ConstantsManager
Given a resolution ID, this method retrieves that resolution.- Specified by:
getResolution
in interfaceConstantsManager
- Parameters:
id
- The id of the resolution- Returns:
- A resolution
-
refreshResolutions
public void refreshResolutions()Description copied from interface:ConstantsManager
Reloads all resolutions from the DB.- Specified by:
refreshResolutions
in interfaceConstantsManager
-
getAllIssueTypeObjects
Description copied from interface:ConstantsManager
Returns a list of IssueTypes.- Specified by:
getAllIssueTypeObjects
in interfaceConstantsManager
- Returns:
- A Collection of
IssueType
objects.
-
getRegularIssueTypeObjects
Description copied from interface:ConstantsManager
Retrieve regular (non-subtask) issue types.- Specified by:
getRegularIssueTypeObjects
in interfaceConstantsManager
- Returns:
- A collection of
IssueType
s
-
getSubTaskIssueTypeObjects
Description copied from interface:ConstantsManager
Retrieves all the sub-task issue types- Specified by:
getSubTaskIssueTypeObjects
in interfaceConstantsManager
- Returns:
- A Collection of all sub-task
IssueType
s.
-
getStatusByName
Description copied from interface:ConstantsManager
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.- Specified by:
getStatusByName
in interfaceConstantsManager
- Parameters:
name
- The name of the status.- Returns:
- A
Status
object with the given name, ornull
if none found.
-
getStatusByNameIgnoreCase
Description copied from interface:ConstantsManager
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.- Specified by:
getStatusByNameIgnoreCase
in interfaceConstantsManager
- Parameters:
name
- The name of the status.- Returns:
- A
Status
object with the given name, ornull
if none found.
-
getStatusByTranslatedName
Description copied from interface:ConstantsManager
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.- Specified by:
getStatusByTranslatedName
in interfaceConstantsManager
- Parameters:
name
- The name of the status.- Returns:
- A
Status
object with the given name, ornull
if none found.
-
getEditableSubTaskIssueTypes
Description copied from interface:ConstantsManager
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.- Specified by:
getEditableSubTaskIssueTypes
in interfaceConstantsManager
- Returns:
- A List of editable sub-task
-
getIssueType
Description copied from interface:ConstantsManager
Given an IssueType ID this method retrieves that IssueType.- Specified by:
getIssueType
in interfaceConstantsManager
- Parameters:
id
- The ID of the IssueType.- Returns:
- An IssueType
-
refreshIssueTypes
public void refreshIssueTypes()Description copied from interface:ConstantsManager
Reloads all IssueTypes from the DB.- Specified by:
refreshIssueTypes
in interfaceConstantsManager
-