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 TypeMethodDescriptionvoidCalled after all the beans are constructed and the ApplicationContext is fully populated.booleanconstantExists(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_TYPESandConstantsManager.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 anIssueConstantobject for the given type & id.Collection<? extends IssueConstant>getConstantObjects(String constantType) Returns allIssueConstantobjects 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 constantGenericValueto anIssueConstantobject.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.voidinvalidate(IssueConstant constant) Clear the cache for this Issue Constant.voidSets all cached copies of constants to null.voidonClearCache(ClearCacheEvent ignored) voidvoidrecalculateIssueTypeSequencesAndStore(List<IssueType> issueTypes) Resequences the supplied issuetypes into sequential order.voidrecalculatePrioritySequencesAndStore(List<Priority> priorities) Resequences the supplied priorities into sequential order.voidrecalculateResolutionSequencesAndStore(List<Resolution> resolutions) Resequences the supplied resolutions into sequential order.voidrecalculateStatusSequencesAndStore(List<Status> statuses) Resequences the supplied statuses into sequential order.voidReloads all IssueTypes from the DB.voidReloads all priorities from the DB.voidReloads all resolutions from the DB.voidReloads all statuses from DB.voidRemoves an existing issueType.voidupdateIssueType(String id, String name, Long sequence, String style, String description, Long avatarId) Updates an existing issueType.voidupdateIssueType(String id, String name, Long sequence, String style, String description, String iconurl) Updates an existing issueType.voidvalidateCreateIssueType(String name, String style, String description, String iconurl, ErrorCollection errors, String nameFieldName) Validates creation of a new issuetype.voidvalidateCreateIssueTypeWithAvatar(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, waitMethods 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:InitializingComponentCalled 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:
afterInstantiationin interfaceInitializingComponent- Throws:
Exception
-
onClearCache
-
onIssueTypeDeleted
-
getStatuses
Description copied from interface:ConstantsManagerReturns all statuses- Specified by:
getStatusesin interfaceConstantsManager- Returns:
- Returns a Collection of status
Statuss.
-
getStatus
Description copied from interface:ConstantsManagerReturns a Status given an id.- Specified by:
getStatusin interfaceConstantsManager- Parameters:
id- The id of a status- Returns:
- Returns a status
-
refreshStatuses
public void refreshStatuses()Description copied from interface:ConstantsManagerReloads all statuses from DB.- Specified by:
refreshStatusesin interfaceConstantsManager
-
getConstantObject
Description copied from interface:ConstantsManagerReturns anIssueConstantobject for the given type & id.- Specified by:
getConstantObjectin interfaceConstantsManager- Parameters:
constantType- SeeConstantsManager.CONSTANT_TYPEid- The id of the constant.- Returns:
- A
IssueConstantobject. Null if it doesn't exist.
-
getConstantObjects
Description copied from interface:ConstantsManagerReturns allIssueConstantobjects for the given type.- Specified by:
getConstantObjectsin interfaceConstantsManager- Parameters:
constantType- SeeConstantsManager.CONSTANT_TYPE- Returns:
- A collection of
IssueConstantobject; will benullif and only ifconstantTypeis invalid
-
getConstantsByIds
@Nonnull public List<IssueConstant> getConstantsByIds(@Nonnull ConstantsManager.CONSTANT_TYPE constantType, @Nonnull Collection<String> ids) Description copied from interface:ConstantsManagerConverts the list of ids to the objects of appropriate types- Specified by:
getConstantsByIdsin interfaceConstantsManager- Parameters:
constantType- Type of constantids- list of constant ids- Returns:
- List of IssueConstant subclasses.
-
constantExists
Description copied from interface:ConstantsManagerChecks if a constant exists.- Specified by:
constantExistsin interfaceConstantsManager- Parameters:
constantType- SeeConstantsManager.PRIORITY_CONSTANT_TYPE,ConstantsManager.STATUS_CONSTANT_TYPE,ConstantsManager.RESOLUTION_CONSTANT_TYPE,ConstantsManager.ISSUE_TYPE_CONSTANT_TYPEname- The name of the constant.- Returns:
- True if the constant exists. False otherwise
-
getIssueConstantByName
Description copied from interface:ConstantsManagerReturns a constant by name.- Specified by:
getIssueConstantByNamein interfaceConstantsManager- Parameters:
constantType- SeeConstantsManager.PRIORITY_CONSTANT_TYPE,ConstantsManager.STATUS_CONSTANT_TYPE,ConstantsManager.RESOLUTION_CONSTANT_TYPE,ConstantsManager.ISSUE_TYPE_CONSTANT_TYPEname- The Name of the constant.- Returns:
- The IssueConstant
-
getConstantByNameIgnoreCase
Description copied from interface:ConstantsManagerReturns a constant by name ignoring the case of the name passed in.- Specified by:
getConstantByNameIgnoreCasein interfaceConstantsManager- Parameters:
constantType- SeeConstantsManager.PRIORITY_CONSTANT_TYPE,ConstantsManager.STATUS_CONSTANT_TYPE,ConstantsManager.RESOLUTION_CONSTANT_TYPE,ConstantsManager.ISSUE_TYPE_CONSTANT_TYPEname- 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:ConstantsManagerCreates 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:
insertIssueTypein 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:ConstantsManagerCreates 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:
insertIssueTypein 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:ConstantsManagerValidates 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:
validateCreateIssueTypein 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:ConstantsManagerValidates 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:
validateNamein interfaceConstantsManager
-
validateCreateIssueTypeWithAvatar
public void validateCreateIssueTypeWithAvatar(String name, String style, String description, String avatarId, ErrorCollection errors, String nameFieldName) Description copied from interface:ConstantsManagerValidates 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:
validateCreateIssueTypeWithAvatarin 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:ConstantsManagerUpdates an existing issueType. This will cause a invalidate of all issue types (i.e. reload from the DB).- Specified by:
updateIssueTypein 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:ConstantsManagerUpdates an existing issueType. This will cause a invalidate of all issue types (i.e. reload from the DB).- Specified by:
updateIssueTypein 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:ConstantsManagerRemoves 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:
removeIssueTypein 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:ConstantsManagerResequences the supplied issuetypes into sequential order.- Specified by:
recalculateIssueTypeSequencesAndStorein interfaceConstantsManager
-
recalculatePrioritySequencesAndStore
Description copied from interface:ConstantsManagerResequences the supplied priorities into sequential order.- Specified by:
recalculatePrioritySequencesAndStorein interfaceConstantsManager
-
recalculateStatusSequencesAndStore
Description copied from interface:ConstantsManagerResequences the supplied statuses into sequential order.- Specified by:
recalculateStatusSequencesAndStorein interfaceConstantsManager
-
recalculateResolutionSequencesAndStore
Description copied from interface:ConstantsManagerResequences the supplied resolutions into sequential order.- Specified by:
recalculateResolutionSequencesAndStorein interfaceConstantsManager
-
invalidateAll
public void invalidateAll()Description copied from interface:ConstantsManagerSets 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:
invalidateAllin interfaceConstantsManager
-
invalidate
Description copied from interface:ConstantsManagerClear the cache for this Issue Constant. Implementations may clear additional IssueConstants at their discretion.- Specified by:
invalidatein interfaceConstantsManager
-
expandIssueTypeIds
Description copied from interface:ConstantsManagerConverts 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_TYPESandConstantsManager.ALL_ISSUE_TYPES.- Specified by:
expandIssueTypeIdsin 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:ConstantsManagerReturns all issueType Ids.- Specified by:
getAllIssueTypeIdsin interfaceConstantsManager- Returns:
- A list of all the IssueType Ids.
-
getIssueConstant
Description copied from interface:ConstantsManagerConverts a constantGenericValueto anIssueConstantobject.- Specified by:
getIssueConstantin interfaceConstantsManager- Parameters:
issueConstantGV- the constantGenericValue.- Returns:
- An
IssueConstantobject.
-
getPriorities
Description copied from interface:ConstantsManagerRetrieve all Priorities in JIRA.- Specified by:
getPrioritiesin interfaceConstantsManager- Returns:
- A list of Priority
Prioritys.
-
getPriorityObject
Description copied from interface:ConstantsManagerGiven a priority ID, this method retrieves that priority.- Specified by:
getPriorityObjectin interfaceConstantsManager- Parameters:
id- The id of the priority- Returns:
- A
Priorityobject.
-
getDefaultPriority
Description copied from interface:ConstantsManagerReturns the default priority configured in JIRA.- Specified by:
getDefaultPriorityin interfaceConstantsManager- Returns:
- The default priority
-
getPriorityName
Description copied from interface:ConstantsManagerReturns the priority Name for a given priority ID.- Specified by:
getPriorityNamein 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:ConstantsManagerReloads all priorities from the DB.- Specified by:
refreshPrioritiesin interfaceConstantsManager
-
getResolutions
Description copied from interface:ConstantsManagerRetrieve all Resolutions in JIRA.- Specified by:
getResolutionsin interfaceConstantsManager- Returns:
- A List of Resolution
Resolutions.
-
getResolution
Description copied from interface:ConstantsManagerGiven a resolution ID, this method retrieves that resolution.- Specified by:
getResolutionin interfaceConstantsManager- Parameters:
id- The id of the resolution- Returns:
- A resolution
-
refreshResolutions
public void refreshResolutions()Description copied from interface:ConstantsManagerReloads all resolutions from the DB.- Specified by:
refreshResolutionsin interfaceConstantsManager
-
getAllIssueTypeObjects
Description copied from interface:ConstantsManagerReturns a list of IssueTypes.- Specified by:
getAllIssueTypeObjectsin interfaceConstantsManager- Returns:
- A Collection of
IssueTypeobjects.
-
getRegularIssueTypeObjects
Description copied from interface:ConstantsManagerRetrieve regular (non-subtask) issue types.- Specified by:
getRegularIssueTypeObjectsin interfaceConstantsManager- Returns:
- A collection of
IssueTypes
-
getSubTaskIssueTypeObjects
Description copied from interface:ConstantsManagerRetrieves all the sub-task issue types- Specified by:
getSubTaskIssueTypeObjectsin interfaceConstantsManager- Returns:
- A Collection of all sub-task
IssueTypes.
-
getStatusByName
Description copied from interface:ConstantsManagerSearches 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:
getStatusByNamein interfaceConstantsManager- Parameters:
name- The name of the status.- Returns:
- A
Statusobject with the given name, ornullif none found.
-
getStatusByNameIgnoreCase
Description copied from interface:ConstantsManagerSearches 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:
getStatusByNameIgnoreCasein interfaceConstantsManager- Parameters:
name- The name of the status.- Returns:
- A
Statusobject with the given name, ornullif none found.
-
getStatusByTranslatedName
Description copied from interface:ConstantsManagerSearches 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:
getStatusByTranslatedNamein interfaceConstantsManager- Parameters:
name- The name of the status.- Returns:
- A
Statusobject with the given name, ornullif none found.
-
getEditableSubTaskIssueTypes
Description copied from interface:ConstantsManagerRetrieves 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:
getEditableSubTaskIssueTypesin interfaceConstantsManager- Returns:
- A List of editable sub-task
-
getIssueType
Description copied from interface:ConstantsManagerGiven an IssueType ID this method retrieves that IssueType.- Specified by:
getIssueTypein interfaceConstantsManager- Parameters:
id- The ID of the IssueType.- Returns:
- An IssueType
-
refreshIssueTypes
public void refreshIssueTypes()Description copied from interface:ConstantsManagerReloads all IssueTypes from the DB.- Specified by:
refreshIssueTypesin interfaceConstantsManager
-