/**
   * Validates and returns the selected repositories out of the list
   *
   * @param importableRepos List of importable repositories
   * @return repos map
   */
  private Map<String, RemoteRepoDescriptor> validatedAndReturnSelection(
      Collection<ImportableRemoteRepo> importableRepos) {
    Map<String, RemoteRepoDescriptor> map = Maps.newLinkedHashMap();

    if (importableRepos.isEmpty()) {
      error("Please select at least one repository to import.");
      return map;
    }

    // If a repo which key already exists as another local\virtual repo key is selected, throw an
    // error
    for (ImportableRemoteRepo importableRepo : importableRepos) {
      if (importableRepo.isSelected()) {
        if (importableRepo.isExistsAsLocal() || importableRepo.isExistsAsVirtual()) {
          error(getString("existsAsLocalOrVirtualWarn"));
          map.clear();
          return map;
        }

        map.put(importableRepo.getRepoKey(), importableRepo.getRepoDescriptor());
      }
    }

    if (map.isEmpty()) {
      error("Please select at least one repository to import.");
    }

    return map;
  }