/**
   * 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;
  }
 /**
  * Validate the importable repo key
  *
  * @param importableRemoteRepo Importable repo to validate
  */
 private void validateRepoKey(ImportableRemoteRepo importableRemoteRepo) {
   // Indicate if the key already exists as any type
   boolean existsAsLocal =
       repositoryService.localRepoDescriptorByKey(importableRemoteRepo.getRepoKey()) != null;
   boolean existsAsRemote = false;
   if (!existsAsLocal) {
     existsAsRemote =
         repositoryService.remoteRepoDescriptorByKey(importableRemoteRepo.getRepoKey()) != null;
   }
   boolean existsAsVirtual = false;
   if (!existsAsLocal && !existsAsRemote) {
     existsAsVirtual =
         repositoryService.virtualRepoDescriptorByKey(importableRemoteRepo.getRepoKey()) != null;
   }
   importableRemoteRepo.setExistsAsLocal(existsAsLocal);
   importableRemoteRepo.setExistsAsRemote(existsAsRemote);
   importableRemoteRepo.setExistsAsVirtual(existsAsVirtual);
 }