public List<RepoOsEntity> createRepoOsEntities(List<RepositoryInfo> repositories) {

    List<RepoOsEntity> repoOsEntities = new ArrayList<>();
    final Multimap<String, RepositoryInfo> operatingSystems = ArrayListMultimap.create();
    for (RepositoryInfo repository : repositories) {
      operatingSystems.put(repository.getOsType(), repository);
    }
    for (Entry<String, Collection<RepositoryInfo>> operatingSystem : operatingSystems.asMap().entrySet()) {
      RepoOsEntity operatingSystemEntity = new RepoOsEntity();
      List<RepoDefinitionEntity> repositoriesList = new ArrayList<>();
      for (RepositoryInfo repository : operatingSystem.getValue()) {
        RepoDefinitionEntity repositoryDefinition = new RepoDefinitionEntity();
        repositoryDefinition.setBaseUrl(repository.getBaseUrl());
        repositoryDefinition.setRepoName(repository.getRepoName());
        repositoryDefinition.setRepoID(repository.getRepoId());
        repositoryDefinition.setDistribution(repository.getDistribution());
        repositoryDefinition.setComponents(repository.getComponents());
        repositoryDefinition.setMirrors(repository.getMirrorsList());
        repositoryDefinition.setUnique(repository.isUnique());

        repositoryDefinition.setTags(repository.getTags());
        repositoryDefinition.setApplicableServices(repository.getApplicableServices());

        repositoriesList.add(repositoryDefinition);
        operatingSystemEntity.setAmbariManaged(repository.isAmbariManagedRepositories());
      }
      operatingSystemEntity.addRepoDefinitionEntities(repositoriesList);
      operatingSystemEntity.setFamily(operatingSystem.getKey());
      repoOsEntities.add(operatingSystemEntity);
    }
    return repoOsEntities;
  }
Parses operating systems json to a list of entities. Expects json like:
<pre>
[
   {
      "repositories":[
         {
            "Repositories/base_url":"http://s3.amazonaws.com/dev.hortonworks.com/HDP/centos6/2.x/updates/2.2.0.0",
            "Repositories/repo_name":"HDP-UTILS",
            "Repositories/repo_id":"HDP-UTILS-1.1.0.20"
         },
         {
            "Repositories/base_url":"http://s3.amazonaws.com/dev.hortonworks.com/HDP/centos6/2.x/updates/2.2.0.0",
            "Repositories/repo_name":"HDP",
            "Repositories/repo_id":"HDP-2.2"
         }
      ],
      "OperatingSystems/os_type":"redhat6"
   }
]
</pre>
@param repositoriesJson operating systems json
@return list of operating system entities
@throws Exception if any kind of json parsing error happened
ambari-server/src/main/java/org/apache/ambari/server/stack/upgrade/RepositoryVersionHelper.java