private boolean isOperationAllowed(Cluster cluster, String configType, String targetPropertyKey, ConditionalField operationItem)
  {
    boolean isAllowed = true;

    boolean ifKeyIsNotBlank = StringUtils.isNotBlank(operationItem.ifKey);
    boolean ifTypeIsNotBlank = StringUtils.isNotBlank(operationItem.ifType);
    boolean ifValueIsBlank = StringUtils.isBlank(operationItem.ifValue);

    // if-key/if-type and no value - set only if absent
    if (ifKeyIsNotBlank && ifTypeIsNotBlank && ifValueIsBlank && operationItem.ifKeyState == PropertyKeyState.ABSENT) {
      boolean keyPresent = getDesiredConfigurationKeyPresence(cluster, operationItem.ifType, operationItem.ifKey);
      if (keyPresent) {
        LOG.info("Skipping property operation for {}/{} as the key {} for {} is present",
          configType, targetPropertyKey, operationItem.ifKey, operationItem.ifType);
        isAllowed = false;
      }
      // if-key/if-type and no value - set only is present
    } else if (ifKeyIsNotBlank && ifTypeIsNotBlank && ifValueIsBlank
      && operationItem.ifKeyState == PropertyKeyState.PRESENT) {

      boolean keyPresent = getDesiredConfigurationKeyPresence(cluster, operationItem.ifType, operationItem.ifKey);
      if (!keyPresent) {
        LOG.info("Skipping property operation for {}/{} as the key {} for {} is not present",
          configType, targetPropertyKey, operationItem.ifKey, operationItem.ifType);
        isAllowed = false;
      }
      // if-key/if-type and a value to check - set only if values match
    } else if (ifKeyIsNotBlank && ifTypeIsNotBlank && !ifValueIsBlank) {
      String checkValue = getDesiredConfigurationValue(cluster, operationItem.ifType, operationItem.ifKey);

      // the check value is blank and there is an if-key-state of ABSENT - in
      // this case, it means set the value if it matches or if it's absent
      if (operationItem.ifKeyState == PropertyKeyState.ABSENT) {
        boolean keyPresent = getDesiredConfigurationKeyPresence(cluster, operationItem.ifType, operationItem.ifKey);
        if (!keyPresent) {
          return true;
        }
      }

      // the if-key was found, so we need to do a comparison
      if (operationItem.ifValueMatchType == IfValueMatchType.PARTIAL) {
        if (!StringUtils.containsIgnoreCase(checkValue, operationItem.ifValue) ^ operationItem.ifValueNotMatched) {
          LOG.info("Skipping property operation for {}/{} as the value {} for {}/{} is not found in {}",
            configType, targetPropertyKey, operationItem.ifValue, operationItem.ifType, operationItem.ifKey, checkValue);
          isAllowed = false;
        }
      } else {
        if (!StringUtils.equalsIgnoreCase(operationItem.ifValue, checkValue) ^ operationItem.ifValueNotMatched) {
          LOG.info("Skipping property operation for {}/{} as the value {} for {}/{} is not equal to {}",
            configType, targetPropertyKey, checkValue, operationItem.ifType, operationItem.ifKey, operationItem.ifValue);
          isAllowed = false;
        }
      }
    }

    return isAllowed;
  }
Gets whether the {@code set} directive is valid based on the optional
attributes specified.

@param cluster
         the cluster (not {@code null}).
@param configType
         the configuration type for the change (not {@code null}).
@param targetPropertyKey
         the property to set (not {@code null}).
@param operationItem
          operation field compatible with {@link ConditionalField}
@return {@code true} if the set operation should be executed by the
        upgrade, {@code false} otherwise.
ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java