private UpgradeType calculateUpgradeType(Map<String, Object> upgradeRequestMap,
                                           UpgradeEntity upgradeEntity) throws AmbariException{

    UpgradeType upgradeType = UpgradeType.ROLLING;

    String upgradeTypeProperty = (String) upgradeRequestMap.get(UPGRADE_TYPE);
    boolean upgradeTypePassed = StringUtils.isNotBlank(upgradeTypeProperty);

    if (upgradeTypePassed){
      try {
        upgradeType = UpgradeType.valueOf(upgradeRequestMap.get(UPGRADE_TYPE).toString());
      } catch (Exception e) {
        throw new AmbariException(String.format("Property %s has an incorrect value of %s.",
          UPGRADE_TYPE, upgradeTypeProperty));
      }
    } else if (upgradeEntity != null){
      upgradeType = upgradeEntity.getUpgradeType();
    }

    return upgradeType;
  }
Reading upgrade type from provided request  or if nothing were provided,
from previous upgrade for downgrade direction.

@param upgradeRequestMap arguments provided for current upgrade request
@param upgradeEntity previous upgrade entity, should be passed only for downgrade direction

@return
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/stack/upgrade/orchestrate/UpgradeContext.java