StackId stack = cluster.getDesiredStackVersion();
String repoVersion = version;
if (direction.isDowngrade() && null != versionForUpgradePack) {
repoVersion = versionForUpgradePack;
}
<BUG>RepositoryVersionEntity versionEntity = s_repoVersionDAO.findByStackAndVersion(

stack, repoVersion);</BUG>
if (null == versionEntity) {
throw new AmbariException(String.format("Version %s for stack %s was not found",

StackId stack = cluster.getDesiredStackVersion();
String repoVersion = version;
if (direction.isDowngrade() && null != versionForUpgradePack) {
repoVersion = versionForUpgradePack;
}
RepositoryVersionEntity versionEntity = s_repoVersionDAO.findMaxByVersion(repoVersion);
if (null == versionEntity) {
throw new AmbariException(String.format("Version %s for stack %s was not found",
