com.atlassian.jira.bc.customfield
Class DefaultCustomFieldService

java.lang.Object
  extended by com.atlassian.jira.bc.customfield.DefaultCustomFieldService
All Implemented Interfaces:
CustomFieldService

public class DefaultCustomFieldService
extends Object
implements CustomFieldService

Since:
v3.13

Constructor Summary
DefaultCustomFieldService(GlobalPermissionManager permissionManager, CustomFieldManager customFieldManager, PermissionSchemeManager permissionSchemeManager, IssueSecuritySchemeManager issueSecuritySchemeManager, CustomFieldValidator customFieldValidator, I18nHelper.BeanFactory i18nFactory, JiraContextTreeManager treeManager, CustomFieldContextConfigHelper customFieldContextConfigHelper, ReindexMessageManager reindexMessageManager, ConstantsManager constantManager, FieldScreenManager fieldScreenManager, LocaleManager localeManager, TranslationManager translationManager, ManagedConfigurationItemService managedConfigurationItemService)
           
 
Method Summary
 ServiceOutcomeImpl<List<Long>> addToScreenTabs(com.atlassian.crowd.embedded.api.User user, Long customFieldId, List<Long> tabIds)
          Adds a custom field with the given id to selected tabs.
 ServiceOutcome<CustomField> create(CreateValidationResult createValidationResult)
          Creates a custom field using a CreateValidationResult as parameter.
 ServiceOutcome<CustomField> getCustomFieldForEditConfig(ApplicationUser user, String fieldId)
          Return the custom field if the passed user has permission to edit its configuration.
 Iterable<CustomFieldType<?,?>> getCustomFieldTypesForUser(ApplicationUser user)
          Return the CustomFieldTypes that the passed user can use to create a new CustomField.
 CustomFieldSearcher getDefaultSearcher(CustomFieldType<?,?> type)
          Return the default CustomFieldSearcher for the passed CustomFieldType.
 ServiceOutcomeImpl<List<Long>> removeFromScreenTabs(com.atlassian.crowd.embedded.api.User 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 localeString)
          Sets the current a translation for a custom field.
 ServiceOutcome<CreateValidationResult> validateCreate(com.atlassian.crowd.embedded.api.User 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 valid
 void validateUpdate(JiraServiceContext jiraServiceContext, Long customFieldId, String name, String description, String searcherKey)
          Validates that the custom field with the provided id can be updated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCustomFieldService

public DefaultCustomFieldService(GlobalPermissionManager permissionManager,
                                 CustomFieldManager customFieldManager,
                                 PermissionSchemeManager permissionSchemeManager,
                                 IssueSecuritySchemeManager issueSecuritySchemeManager,
                                 CustomFieldValidator customFieldValidator,
                                 I18nHelper.BeanFactory i18nFactory,
                                 JiraContextTreeManager treeManager,
                                 CustomFieldContextConfigHelper customFieldContextConfigHelper,
                                 ReindexMessageManager reindexMessageManager,
                                 ConstantsManager constantManager,
                                 FieldScreenManager fieldScreenManager,
                                 LocaleManager localeManager,
                                 TranslationManager translationManager,
                                 ManagedConfigurationItemService managedConfigurationItemService)
Method Detail

getCustomFieldForEditConfig

public ServiceOutcome<CustomField> getCustomFieldForEditConfig(@Nullable
                                                               ApplicationUser user,
                                                               String fieldId)
Description copied from interface: CustomFieldService
Return the custom field if the passed user has permission to edit its configuration.

Specified by:
getCustomFieldForEditConfig in interface CustomFieldService
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

@Nonnull
public Iterable<CustomFieldType<?,?>> getCustomFieldTypesForUser(ApplicationUser user)
Description copied from interface: CustomFieldService
Return the CustomFieldTypes that the passed user can use to create a new CustomField. 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.

Specified by:
getCustomFieldTypesForUser in interface CustomFieldService
Parameters:
user - the user to check against.
Returns:
the CustomFieldTypes that the passed user can use to create a CustomField.

getDefaultSearcher

@Nullable
public CustomFieldSearcher getDefaultSearcher(@Nonnull
                                                       CustomFieldType<?,?> type)
Description copied from interface: CustomFieldService
Return the default CustomFieldSearcher for the passed CustomFieldType. The default searcher can be null if there is no searcher associated with the type.

Specified by:
getDefaultSearcher in interface CustomFieldService
Parameters:
type - the CustomFieldType to query.
Returns:
the default searcher for the passed CustomFieldType. Can be null if the type has no associated searcher.

validateDelete

public void validateDelete(JiraServiceContext jiraServiceContext,
                           Long customFieldId)
Description copied from interface: CustomFieldService
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.

Specified by:
validateDelete in interface CustomFieldService
Parameters:
jiraServiceContext - containing the User who is performing the change and the ErrorCollection that will contain any errors in calling the method
customFieldId - 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: CustomFieldService
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.

Specified by:
validateUpdate in interface CustomFieldService
Parameters:
jiraServiceContext - containing the User who is performing the change and the ErrorCollection that will contain any errors in calling the method
customFieldId - the custom field id of the customfield about to be updated
name - the updated name of the customfield
description - the description of the customfield
searcherKey - 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: CustomFieldService
Validates that the parameters to set a translation for a custom field are valid

Specified by:
validateTranslation in interface CustomFieldService
Parameters:
jiraServiceContext - containing the User who is performing the change and the ErrorCollection that will contain any errors in calling the method
customFieldId - the custom field id of the customfield about to be updated
name - the updated name of the customfield
description - the description of the customfield
locale - the locale of the translation

updateTranslation

public void updateTranslation(JiraServiceContext jiraServiceContext,
                              Long customFieldId,
                              String name,
                              String description,
                              String localeString)
Description copied from interface: CustomFieldService
Sets 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:
updateTranslation in interface CustomFieldService
Parameters:
jiraServiceContext - containing the User who is performing the change and the ErrorCollection that will contain any errors in calling the method
customFieldId - the custom field id of the customfield about to be updated
name - the updated name of the customfield
description - the description of the customfield
localeString - the locale of the translation

validateCreate

public ServiceOutcome<CreateValidationResult> validateCreate(com.atlassian.crowd.embedded.api.User user,
                                                             CustomFieldDefinition customFieldDefinition)
Description copied from interface: CustomFieldService
Validates that the custom field with the provided data can be created. Data placeholder is the CustomFieldDefinition. The result of this operation is CreateValidationResult which after validation will contain all necessery data to create a custom field (including user)

Specified by:
validateCreate in interface CustomFieldService
Parameters:
user - - the user who is performing the validation
customFieldDefinition - - custom field data
Returns:
validation result, which contains valid data to cre`ate a custom field. This should be passed to create method.

create

public ServiceOutcome<CustomField> create(CreateValidationResult createValidationResult)
Description copied from interface: CustomFieldService
Creates a custom field using a CreateValidationResult as parameter. CreateValidationResult is an output of createValidation method which should be executed before executing create.

Specified by:
create in interface CustomFieldService
Parameters:
createValidationResult - - data needed to create custom field, containing user.
Returns:
ServiceOutcome with CustomField or with errorCollection

addToScreenTabs

public ServiceOutcomeImpl<List<Long>> addToScreenTabs(com.atlassian.crowd.embedded.api.User user,
                                                      Long customFieldId,
                                                      List<Long> tabIds)
Description copied from interface: CustomFieldService
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.

Specified by:
addToScreenTabs in interface CustomFieldService
Parameters:
user - user who performs the change
customFieldId - id of custom field
tabIds - 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(com.atlassian.crowd.embedded.api.User user,
                                                           Long customFieldId,
                                                           List<Long> tabIds)
Description copied from interface: CustomFieldService
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.

Specified by:
removeFromScreenTabs in interface CustomFieldService
Parameters:
user - user who performs the change
customFieldId - id of custom field
tabIds - 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


Copyright © 2002-2014 Atlassian. All Rights Reserved.