public Map convertToVcsRootProperties()

in vault-server/src/jetbrains/buildServer/buildTriggers/vcs/vault/VaultVcsSupport.java [368:408]


  public Map<String, String> convertToVcsRootProperties(@NotNull final VcsUrl vcsUrl) throws VcsException {
    if (vcsUrl.getCredentials() == null) return null;

    try {
      final String url = vcsUrl.getUrl();
      final String server = getServer(url);

      if (StringUtil.isNotEmpty(server)) {

        final String repoIdStr = getRepoId(url);
        if (StringUtil.isNotEmpty(repoIdStr)) {

          final int repoId = Integer.parseInt(repoIdStr);
          final String username = vcsUrl.getCredentials().getUsername();
          final String password = vcsUrl.getCredentials().getPassword();

          final List<RepositoryInfo> repos = myConnectionFactory.getOrCreateConnection(
            new VaultConnectionParameters(server,
                                          StringUtil.EMPTY,
                                          username,
                                          password,
                                          vcsUrl.toString(),
                                          myCacheFolder)).getRepositories();
          for (RepositoryInfo repo : repos) {
            if (repo.getId() == repoId) {
              final Map<String, String> res = new HashMap<String, String>(4);
              res.put(VaultUtil.SERVER, server);
              res.put(VaultUtil.REPO, repo.getName());
              res.put(VaultUtil.USER, username);
              res.put(VaultUtil.PASSWORD, password);
              return res;
            }
          }
        }
      }
    } catch (Throwable t) {
      LOG.warn(t.getMessage(), t);
      throw new VcsException(t.getMessage(), t);
    }
    return null;
  }