@Experimental(feature = ExperimentalFeature.PATCH_UPGRADES)
  private RepositoryVersionEntity getRepositoryVersionEntity(Cluster cluster, ServiceComponent component) throws SystemException {

    RepositoryVersionEntity repositoryEntity = null;

    // !!! try to find the component repo first
    if (null != component) {
      repositoryEntity = component.getDesiredRepositoryVersion();
    } else {
      LOG.info("Service component not passed in, attempt to resolve the repository for cluster {}",
        cluster.getClusterName());
    }

    if (null == repositoryEntity && null != component) {
      try {
        Service service = cluster.getService(component.getServiceName());
        repositoryEntity = service.getDesiredRepositoryVersion();
      } catch (AmbariException e) {
        throw new SystemException("Unhandled exception", e);
      }
    }

    if (null == repositoryEntity) {
      LOG.info("Cluster {} has no specific Repository Versions.  Using stack-defined values", cluster.getClusterName());
      return null;
    }

    return repositoryEntity;
  }
Checks repo URLs against the current version for the cluster and make
adjustments to the Base URL when the current is different.

@param cluster {@link Cluster} object
@param component resolve {@link RepositoryVersionEntity} for the component, could be {@code null}

@return {@link RepositoryVersionEntity} retrieved for component if set or cluster if not
ambari-server/src/main/java/org/apache/ambari/server/stack/upgrade/RepositoryVersionHelper.java