code: public void addRepository(RepositoryAdmin repositoryAdmin, String repository)
      {
          try {
              if (repository != null)
              {
                  boolean duplicate = false;
                  for (Repository repo : repositoryAdmin.listRepositories())
                  {
                      if (repository.equalsIgnoreCase(repo.getURI()))
                          duplicate = true;
                  }
                  if (!duplicate)
                  {
                      Repository repo = repositoryAdmin.addRepository(repository);
                      if (repo == null)
                          repositoryAdmin.removeRepository(repository);   // Ignore repos not found
                  }
              }
          } catch (Exception e) {
              // Ignore exception e.printStackTrace();
          }
      }
docs: Add this repository to my available repositories.
  @param repositoryAdmin
  @param repository