@JavaScriptMethod
  public String checkBranch(String branch, String fork, String repo) {

    doFillBranchItems(repo, fork);

    if (branch.length() == 0) {
      return Messages.Branch_NoBranch();
    }

    // check if given branch is in branch list
    for (String b : this.branchItems) {
      if (b.equals(branch)) {
        return "__succeeded";
      }
    }

    return Messages.Branch_NotFound(branch);
  }
  /** Checks if given branch exists */
  public FormValidation checkDepBranch(
      @QueryParameter String value, @QueryParameter String name, @QueryParameter String fork)
      throws IOException, ServletException {

    doFillBranchItems(name, fork);

    if (value.length() == 0) {
      return FormValidation.error(Messages.Branch_NoBranch());
    }

    // check if given branch is in branch list
    for (String branch : this.branchItems) {
      if (branch.equals(value)) {
        return FormValidation.ok();
      }
    }

    return FormValidation.error(Messages.Branch_NotFound(value));
  }
  /** Checks if given fork owner exists */
  public FormValidation checkDepFork(@QueryParameter String value, @QueryParameter String name)
      throws IOException, ServletException {

    doFillForkItems(value, name);

    if (value.length() == 0) {
      return FormValidation.error(Messages.Fork_NoFork());
    }

    // check if given fork owner is in fork list
    /*for (String fork : this.forkItems) {
    	if (fork.equals(value)) {
    		return (msg.length()==0) ? FormValidation.ok() : FormValidation.ok(msg);
    	}
    }*/

    // if fork owner was not in list
    try {
      // check if user exists
      try {
        UserService githubUserSrv = new UserService(this.githubClient);
        githubUserSrv.getUser(value);
      } catch (Exception ex) {
        return FormValidation.error(Messages.Fork_OwnerNotFound() + "\n" + ex.getMessage());
      }
      // check if user has public repository with given name
      try {
        RepositoryService githubRepoSrv = new RepositoryService(this.githubClient);
        List<org.eclipse.egit.github.core.Repository> repos = githubRepoSrv.getRepositories(value);
        for (org.eclipse.egit.github.core.Repository repo : repos) {
          if (repo.getName().equals(name)) return FormValidation.ok(Messages.Fork_Found());
        }
      } catch (Exception ex) {
        return FormValidation.error(Messages.Fork_GetReposFailed() + "\n" + ex.getMessage());
      }
      return FormValidation.ok();
    } catch (Exception ex) {
      return FormValidation.error(Messages.Fork_AuthFailed() + "\n" + ex.getMessage());
    }
  }
  @JavaScriptMethod
  public String checkFork(String fork, String repo) {

    doFillForkItems(fork, repo);

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

    // check if given fork owner is in fork list
    for (String f : this.forkItems) {
      if (f.equals(fork)) {
        return "__succeeded";
      }
    }

    // if fork owner was not in list
    try {
      // check if user exists
      try {
        UserService githubUserSrv = new UserService(this.githubClient);
        githubUserSrv.getUser(fork);
      } catch (Exception ex) {
        return Messages.Fork_OwnerNotFound() + "\n" + ex.getMessage();
      }
      // check if user has public repository with given name
      try {
        RepositoryService githubRepoSrv = new RepositoryService(this.githubClient);
        List<org.eclipse.egit.github.core.Repository> repos = githubRepoSrv.getRepositories(fork);
        for (org.eclipse.egit.github.core.Repository r : repos) {
          if (r.getName().equals(repo)) return Messages.Fork_Found() + "__succeeded";
        }
      } catch (Exception ex) {
        return Messages.Fork_GetReposFailed() + "\n" + ex.getMessage();
      }
      return "__succeeded";
    } catch (Exception ex) {
      return Messages.Fork_AuthFailed() + "\n" + ex.getMessage();
    }
  }
  /** 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());
  }
  @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);
  }