Class DefaultCustomFieldService
java.lang.Object
com.atlassian.jira.bc.customfield.DefaultCustomFieldService
- All Implemented Interfaces:
CustomFieldService
- Since:
- v3.13
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCustomFieldService(GlobalPermissionManager permissionManager, CustomFieldManager customFieldManager, PermissionSchemeManager permissionSchemeManager, IssueSecuritySchemeManager issueSecuritySchemeManager, CustomFieldValidator customFieldValidator, I18nHelper.BeanFactory i18nFactory, ProjectManager projectManager, CustomFieldContextConfigHelper customFieldContextConfigHelper, ReindexMessageManager reindexMessageManager, ConstantsManager constantManager, FieldScreenManager fieldScreenManager, LocaleManager localeManager, TranslationManager translationManager, ManagedConfigurationItemService managedConfigurationItemService, CustomFieldVisibilityCheck customFieldVisibilityCheck) -
Method Summary
Modifier and TypeMethodDescriptionaddToScreenTabs(ApplicationUser user, Long customFieldId, List<Long> tabIds) Adds a custom field with the given id to selected tabs.create(CreateValidationResult createValidationResult) Creates a custom field using aCreateValidationResultas parameter.findCustomFields(ApplicationUser user, String searchString, List<String> types, List<String> projects, List<String> screens, String sortOrder, String sortColumn, Long lastValueUpdate) Returns filtered list of customfieldsgetCustomField(ApplicationUser user, Long fieldId) Returns a custom field with the providedfieldIdor an invalid outcome if the custom field does not exist or theuserdoes not have permission to view it.getCustomFieldForEditConfig(ApplicationUser user, String fieldId) Return the custom field if the passed user has permission to edit its configuration.Iterable<CustomFieldType<?,?>> Return theCustomFieldTypes that the passed user can use to create a newCustomField.getDefaultSearcher(CustomFieldType<?, ?> type) Return the defaultCustomFieldSearcherfor the passedCustomFieldType.removeFromScreenTabs(ApplicationUser user, Long customFieldId, List<Long> tabIds) Removes a custom field with the given id from selected tabs.voidupdateTranslation(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String localeString) Sets the current a translation for a custom field.validateCreate(ApplicationUser user, CustomFieldDefinition customFieldDefinition) Validates that the custom field with the provided data can be created.voidvalidateDelete(JiraServiceContext jiraServiceContext, Long customFieldId) Validates that the custom field with the provided id can be deleted.voidvalidateTranslation(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String locale) Validates that the parameters to set a translation for a custom field are validvoidvalidateUpdate(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String searcherKey) Validates that the custom field with the provided id can be updated.
-
Field Details
-
GLOBAL_CONTEXT_TEXT
- See Also:
-
-
Constructor Details
-
DefaultCustomFieldService
public DefaultCustomFieldService(GlobalPermissionManager permissionManager, CustomFieldManager customFieldManager, PermissionSchemeManager permissionSchemeManager, IssueSecuritySchemeManager issueSecuritySchemeManager, CustomFieldValidator customFieldValidator, I18nHelper.BeanFactory i18nFactory, ProjectManager projectManager, CustomFieldContextConfigHelper customFieldContextConfigHelper, ReindexMessageManager reindexMessageManager, ConstantsManager constantManager, FieldScreenManager fieldScreenManager, LocaleManager localeManager, TranslationManager translationManager, ManagedConfigurationItemService managedConfigurationItemService, CustomFieldVisibilityCheck customFieldVisibilityCheck)
-
-
Method Details
-
getCustomFieldForEditConfig
public ServiceOutcome<CustomField> getCustomFieldForEditConfig(@Nullable ApplicationUser user, String fieldId) Description copied from interface:CustomFieldServiceReturn the custom field if the passed user has permission to edit its configuration.- Specified by:
getCustomFieldForEditConfigin interfaceCustomFieldService- Parameters:
user- the user to check.fieldId- the field to search for.- Returns:
- the custom field with the passed fieldId if the passed user has permission to edit its configuration and it actually exists.
-
getCustomFieldTypesForUser
Description copied from interface:CustomFieldServiceReturn theCustomFieldTypes that the passed user can use to create a newCustomField.A
CustomFieldTypecan be hidden if the passed user either does not have permission to see it or when the type is locked and not meant to be created by users.- Specified by:
getCustomFieldTypesForUserin interfaceCustomFieldService- Parameters:
user- the user to check against.- Returns:
- the
CustomFieldTypes that the passed user can use to create aCustomField.
-
getDefaultSearcher
Description copied from interface:CustomFieldServiceReturn the defaultCustomFieldSearcherfor the passedCustomFieldType. The default searcher can be null if there is no searcher associated with the type.- Specified by:
getDefaultSearcherin interfaceCustomFieldService- Parameters:
type- theCustomFieldTypeto query.- Returns:
- the default searcher for the passed
CustomFieldType. Can be null if the type has no associated searcher.
-
validateDelete
Description copied from interface:CustomFieldServiceValidates that the custom field with the provided id can be deleted. This means we check whether or not the custom field is used in any permission or issue level security schemes. This method will also check that the custom field with the given id exists. The user performing this operation needs to have global admin permission.- Specified by:
validateDeletein interfaceCustomFieldService- Parameters:
jiraServiceContext- containing theUserwho is performing the change and theErrorCollectionthat will contain any errors in calling the methodcustomFieldId- the custom field id of the custom field about to be deleted.
-
validateUpdate
public void validateUpdate(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String searcherKey) Description copied from interface:CustomFieldServiceValidates that the custom field with the provided id can be updated. This means we check whether or not the custom field is used in any permission or issue level security schemes if the custom field's searcher is being set to null. This method will also check that the custom field with the given id exists and that all its attributes are valid. The user performing this operation needs to have global admin permission.- Specified by:
validateUpdatein interfaceCustomFieldService- Parameters:
jiraServiceContext- containing theUserwho is performing the change and theErrorCollectionthat will contain any errors in calling the methodcustomFieldId- the custom field id of the customfield about to be updatedname- the updated name of the customfielddescription- the description of the customfieldsearcherKey- the customfield searcher that should be used
-
validateTranslation
public void validateTranslation(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String locale) Description copied from interface:CustomFieldServiceValidates that the parameters to set a translation for a custom field are valid- Specified by:
validateTranslationin interfaceCustomFieldService- Parameters:
jiraServiceContext- containing theUserwho is performing the change and theErrorCollectionthat will contain any errors in calling the methodcustomFieldId- the custom field id of the customfield about to be updatedname- the updated name of the customfielddescription- the description of the customfieldlocale- the locale of the translation
-
updateTranslation
public void updateTranslation(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String localeString) Description copied from interface:CustomFieldServiceSets the current a translation for a custom field. The name and description can be empty and if so the translation will be cleared.- Specified by:
updateTranslationin interfaceCustomFieldService- Parameters:
jiraServiceContext- containing theUserwho is performing the change and theErrorCollectionthat will contain any errors in calling the methodcustomFieldId- the custom field id of the customfield about to be updatedname- the updated name of the customfielddescription- the description of the customfieldlocaleString- the locale of the translation
-
validateCreate
public ServiceOutcome<CreateValidationResult> validateCreate(ApplicationUser user, CustomFieldDefinition customFieldDefinition) Description copied from interface:CustomFieldServiceValidates that the custom field with the provided data can be created. Data placeholder is theCustomFieldDefinition. The result of this operation isCreateValidationResultwhich after validation will contain all necessery data to create a custom field (including user)- Specified by:
validateCreatein interfaceCustomFieldService- Parameters:
user- - the user who is performing the validationcustomFieldDefinition- - custom field data- Returns:
- validation result, which contains valid data to cre`ate a custom field. This should be passed to create method.
-
create
Description copied from interface:CustomFieldServiceCreates a custom field using aCreateValidationResultas parameter. CreateValidationResult is an output of createValidation method which should be executed before executing create.- Specified by:
createin interfaceCustomFieldService- Parameters:
createValidationResult- - data needed to create custom field, containing user.- Returns:
- ServiceOutcome with CustomField or with errorCollection
-
addToScreenTabs
public ServiceOutcomeImpl<List<Long>> addToScreenTabs(ApplicationUser user, Long customFieldId, List<Long> tabIds) Description copied from interface:CustomFieldServiceAdds a custom field with the given id to selected tabs. It returns list of ids of tabs on which custom field is present after performing "add" operation.- Specified by:
addToScreenTabsin interfaceCustomFieldService- Parameters:
user- user who performs the changecustomFieldId- id of custom fieldtabIds- list of tab's id's to which we want to add custom field- Returns:
- service outcome containing list of ids of tabs on which custom field is present after operation
-
removeFromScreenTabs
public ServiceOutcomeImpl<List<Long>> removeFromScreenTabs(ApplicationUser user, Long customFieldId, List<Long> tabIds) Description copied from interface:CustomFieldServiceRemoves a custom field with the given id from selected tabs. It returns list of ids of tabs on which custom field is present after performing "remove" operation.- Specified by:
removeFromScreenTabsin interfaceCustomFieldService- Parameters:
user- user who performs the changecustomFieldId- id of custom fieldtabIds- list of tab's ids from which we want to remove custom field- Returns:
- service outcome containing list of ids of tabs on which custom field is present after operation
-
findCustomFields
public ServiceOutcomeImpl<List<CustomField>> findCustomFields(ApplicationUser user, @Nullable String searchString, @Nullable List<String> types, @Nullable List<String> projects, @Nullable List<String> screens, @Nullable String sortOrder, @Nullable String sortColumn, @Nullable Long lastValueUpdate) Returns filtered list of customfields- Parameters:
searchString- Field name partial matchtypes- Custom field type keys for filteringprojects- Project IDs for filteringscreens- Screen IDs for filteringsortOrder- Sorting order: ascending or descendingsortColumn- Column to sort by: lastValueUpdate or IssuesWithValuelastValueUpdate- Date for filtering- Returns:
- list of filtered custom fields
-
getCustomField
public ServiceOutcome<CustomField> getCustomField(@Nullable ApplicationUser user, @Nonnull Long fieldId) Description copied from interface:CustomFieldServiceReturns a custom field with the providedfieldIdor an invalid outcome if the custom field does not exist or theuserdoes not have permission to view it.- Specified by:
getCustomFieldin interfaceCustomFieldService- Parameters:
user- a user whose permission is checkedfieldId- an id of a custom field to return- Returns:
- a service outcome with a custom field or a failure reason
-