Interface CustomFieldService
- All Known Implementing Classes:
DefaultCustomFieldService
@PublicApi
public interface CustomFieldService
Service front for the custom field manager. Implementations of this interface are responsible for
carrying out any validation and permission logic required to carry out a certain task. The actual
work required to do a certain task should be delegated to the
CustomFieldManager
.- Since:
- v3.13
-
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 aCreateValidationResult
as parameter.getCustomField
(ApplicationUser user, Long fieldId) Returns a custom field with the providedfieldId
or an invalid outcome if the custom field does not exist or theuser
does 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 theCustomFieldType
s that the passed user can use to create a newCustomField
.getDefaultSearcher
(CustomFieldType<?, ?> type) Return the defaultCustomFieldSearcher
for the passedCustomFieldType
.removeFromScreenTabs
(ApplicationUser user, Long customFieldId, List<Long> tabIds) Removes a custom field with the given id from selected tabs.void
updateTranslation
(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String locale) 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.void
validateDelete
(JiraServiceContext jiraServiceContext, Long customFieldId) Validates that the custom field with the provided id can be deleted.void
validateTranslation
(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String locale) Validates that the parameters to set a translation for a custom field are validvoid
validateUpdate
(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String searcherKey) Validates that the custom field with the provided id can be updated.
-
Method Details
-
getCustomFieldForEditConfig
ServiceOutcome<CustomField> getCustomFieldForEditConfig(@Nullable ApplicationUser user, String fieldId) Return the custom field if the passed user has permission to edit its configuration.- 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
Return theCustomFieldType
s that the passed user can use to create a newCustomField
.A
CustomFieldType
can 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.- Parameters:
user
- the user to check against.- Returns:
- the
CustomFieldType
s that the passed user can use to create aCustomField
.
-
getDefaultSearcher
Return the defaultCustomFieldSearcher
for the passedCustomFieldType
. The default searcher can be null if there is no searcher associated with the type.- Parameters:
type
- theCustomFieldType
to query.- Returns:
- the default searcher for the passed
CustomFieldType
. Can be null if the type has no associated searcher.
-
validateDelete
Validates 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.- Parameters:
jiraServiceContext
- containing theUser
who is performing the change and theErrorCollection
that will contain any errors in calling the methodcustomFieldId
- the custom field id of the custom field about to be deleted.
-
validateUpdate
void validateUpdate(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String searcherKey) Validates 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.- Parameters:
jiraServiceContext
- containing theUser
who is performing the change and theErrorCollection
that 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
-
validateCreate
ServiceOutcome<CreateValidationResult> validateCreate(ApplicationUser user, CustomFieldDefinition customFieldDefinition) Validates that the custom field with the provided data can be created. Data placeholder is theCustomFieldDefinition
. The result of this operation isCreateValidationResult
which after validation will contain all necessery data to create a custom field (including user)- 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
ServiceOutcome<CustomField> create(CreateValidationResult createValidationResult) throws DataAccessException Creates a custom field using aCreateValidationResult
as parameter. CreateValidationResult is an output of createValidation method which should be executed before executing create.- Parameters:
createValidationResult
- - data needed to create custom field, containing user.- Returns:
- ServiceOutcome with CustomField or with errorCollection
- Throws:
DataAccessException
- throwed when there is a problem with creating custom field in database
-
addToScreenTabs
ServiceOutcome<List<Long>> addToScreenTabs(ApplicationUser user, Long customFieldId, List<Long> tabIds) Adds 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.- 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
ServiceOutcome<List<Long>> removeFromScreenTabs(ApplicationUser user, Long customFieldId, List<Long> tabIds) Removes 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.- 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
-
validateTranslation
void validateTranslation(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String locale) Validates that the parameters to set a translation for a custom field are valid- Parameters:
jiraServiceContext
- containing theUser
who is performing the change and theErrorCollection
that 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
void updateTranslation(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String locale) Sets the current a translation for a custom field. The name and description can be empty and if so the translation will be cleared.- Parameters:
jiraServiceContext
- containing theUser
who is performing the change and theErrorCollection
that 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
-
getCustomField
@ExperimentalApi ServiceOutcome<CustomField> getCustomField(@Nullable ApplicationUser user, @Nonnull Long fieldId) Returns a custom field with the providedfieldId
or an invalid outcome if the custom field does not exist or theuser
does not have permission to view it.- 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
-