// ------------------------------------------------------------------------------------------
  // Private Helper Methods
  public FieldConfigScheme getConfig() {
    if ((fieldConfigScheme == null) && (fieldConfigSchemeId != null)) {
      fieldConfigScheme = fieldConfigSchemeManager.getFieldConfigScheme(fieldConfigSchemeId);
    }

    return fieldConfigScheme;
  }
  @RequiresXsrfCheck
  public String doRemove() throws Exception {
    if (isFieldLocked()) {
      return "locked";
    }

    final FieldConfigScheme configScheme = getConfig();

    if (customFieldContextConfigHelper.doesRemovingSchemeFromCustomFieldAffectIssues(
        getLoggedInUser(), getCustomField(), configScheme)) {
      reindexMessageManager.pushMessage(
          getLoggedInUser(), "admin.notifications.task.custom.fields");
    }

    fieldConfigSchemeManager.removeFieldConfigScheme(configScheme.getId());

    ComponentAccessor.getFieldManager().refresh();
    customFieldManager.refreshConfigurationSchemes(getCustomFieldId());
    return redirectToView();
  }
  @Override
  @RequiresXsrfCheck
  protected String doExecute() throws Exception {
    if (isFieldLocked()) {
      return "locked";
    }

    FieldConfigScheme configScheme =
        new FieldConfigScheme.Builder(getConfig())
            .setName(getName())
            .setDescription(getDescription())
            .toFieldConfigScheme();

    if (isBasicMode()) {
      // Add the contexts
      final List<JiraContextNode> contexts =
          CustomFieldUtils.buildJiraIssueContexts(
              isGlobal(), getProjectCategories(), getProjects(), treeManager);

      // Add the issue types
      final List<GenericValue> issueTypes =
          CustomFieldUtils.buildIssueTypes(constantsManager, getIssuetypes());

      boolean messageRequired;
      if (configScheme.getId() == null) {
        messageRequired =
            customFieldContextConfigHelper.doesAddingContextToCustomFieldAffectIssues(
                getLoggedInUser(), getCustomField(), contexts, issueTypes, false);

        configScheme =
            fieldConfigSchemeManager.createFieldConfigScheme(
                configScheme, contexts, issueTypes, getCustomField());
      } else {
        // keep a handle on the old scheme (pre edit) projects and issue types
        messageRequired =
            customFieldContextConfigHelper.doesChangingContextAffectIssues(
                getLoggedInUser(),
                getCustomField(),
                configScheme,
                isGlobal(),
                contexts,
                issueTypes);

        // Update so keep the old config
        if (issueTypes != null) {
          // Since we know that there is only one config
          final Long configId = getFieldConfigIds()[0];
          final FieldConfig config = fieldConfigManager.getFieldConfig(configId);
          final Map<String, FieldConfig> configs =
              new HashMap<String, FieldConfig>(issueTypes.size());
          for (final GenericValue issueType : issueTypes) {
            final String issueTypeId =
                issueType == null
                    ? null
                    : issueType.getString(FieldConfigSchemePersisterImpl.ENTITY_ID);
            configs.put(issueTypeId, config);
          }
          configScheme =
              new FieldConfigScheme.Builder(configScheme).setConfigs(configs).toFieldConfigScheme();
        }
        configScheme =
            fieldConfigSchemeManager.updateFieldConfigScheme(
                configScheme, contexts, getCustomField());
      }

      if (messageRequired) {
        reindexMessageManager.pushMessage(
            getLoggedInUser(), "admin.notifications.task.custom.fields");
      }

      fieldConfigScheme = configScheme;
    } else {
      // @TODO advanced config
    }

    ComponentAccessor.getFieldManager().refresh();
    customFieldManager.refreshConfigurationSchemes(getCustomFieldId());

    return redirectToView();
  }