コード例 #1
0
  /** Checks if given repository exists */
  public FormValidation checkDepName(@QueryParameter String value, @QueryParameter String fork)
      throws IOException, ServletException {

    doFillNameItems(fork);

    if (fork.length() == 0) {
      return FormValidation.error(Messages.Dependency_NoFork());
    }

    if (value.length() == 0) {
      return FormValidation.warning(Messages.Repository_NoName());
    }

    // check if given repository is in repo list
    for (String repoName : this.repoNameItems) {
      if (repoName.equals(value)) {
        return FormValidation.ok();
      }
    }
    // if repository was not in list, for example extern repository
    try {
      RepositoryService githubRepoSrv = new RepositoryService(githubClient);
      org.eclipse.egit.github.core.Repository selectedRepo =
          githubRepoSrv.getRepository(fork, value);
      if (selectedRepo != null) {
        if (selectedRepo.isPrivate()) {
          return FormValidation.ok(Messages.Dependency_PrivateFound());
        }
        return FormValidation.ok();
      }
    } catch (IOException ex) {
      // TODO: handle exception
    }

    return FormValidation.warning(
        Messages.Dependency_NotFound(value, fork)); // error(Messages.Repository_NoFound());
  }
コード例 #2
0
  @JavaScriptMethod
  public String checkName(String repo, String fork) {

    doFillNameItems(fork);

    if (fork.length() == 0) {
      return Messages.Repository_NoFork();
    }

    if (repo.length() == 0) {
      return Messages.Repository_NoName();
    }

    // check if given repository is in repo list
    for (String repoName : this.repoNameItems) {
      if (repoName.equals(repo)) {
        return "";
      }
    }
    // if repository was not in list, for example extern repository
    try {
      RepositoryService githubRepoSrv = new RepositoryService(githubClient);
      org.eclipse.egit.github.core.Repository selectedRepo =
          githubRepoSrv.getRepository(fork, repo);
      if (selectedRepo != null) {
        if (selectedRepo.isPrivate()) {
          return Messages.Repository_PrivateFound() + "__succeeded";
        }
        return "__succeeded";
      }
    } catch (IOException ex) {
      // TODO: handle exception
    }

    return Messages.Repository_NotFound(repo, fork);
  }