class UpgradePermissionProvider {

    public boolean permitCmAndStackUpgrade(Image currentImage, Image image, String versionKey, String buildNumberKey) {
        String currentVersion = getVersionFromImage(currentImage, versionKey);
        String newVersion = getVersionFromImage(image, versionKey);
        return versionsArePresent(currentVersion, newVersion) && permitCmAndStackUpgradeByComponentVersion(currentVersion, newVersion)
                || permitCmAndStackUpgradeByBuildNumber(currentImage, image, buildNumberKey, currentVersion, newVersion);
    }

}