class MaintenanceModeValidationService {

    public List<Warning> validateStackRepository(Long clusterId, String stackRepo) {
        List<Warning> warnings = new ArrayList<>();
        StackRepoDetails repoDetails = clusterComponentConfigProvider.getStackRepoDetails(clusterId);
        Map<String, String> stack = repoDetails.getStack();
        if (Objects.nonNull(stackRepo)) {
            JsonNode stackRepoJson = jsonHelper.createJsonFromString(stackRepo).path("Repositories");
            String baseUrl = stackRepoJson.path("base_url").asText();
            String osType = stackRepoJson.path("os_type").asText();
            String repoId = stackRepoJson.path("repo_id").asText();

            String configuredRepoId = stack.get(StackRepoDetails.REPO_ID_TAG);
            if (!configuredRepoId.contentEquals(repoId)) {
                warnings.add(new Warning(WarningType.STACK_REPO_WARNING,
                        String.format("Incorrect repo id! Configured '%s', but fetched '%s' from Ambari.",
                                configuredRepoId,
                                repoId)));
            }
            String configuredBaseUrl = stack.get(osType);
            if (configuredBaseUrl == null) {
                warnings.add(new Warning(WarningType.STACK_REPO_WARNING,
                        String.format("Incorrect OS type configured, fetched '%s' from Ambari.",
                                osType)));
            } else if (!configuredBaseUrl.contentEquals(baseUrl)) {
                warnings.add(new Warning(WarningType.STACK_REPO_WARNING,
                        String.format("Incorrect repo URL. '%s' configured but '%s' fetched from Ambari.",
                                configuredBaseUrl,
                                baseUrl)));
            }
        }

        stack.remove(StackRepoDetails.REPO_ID_TAG);
        return warnings;
    }

}