/** Fill combobox with forks of repository */ public ComboBoxModel doFillForkItems(@QueryParameter String value, @QueryParameter String name) { ComboBoxModel aux = new ComboBoxModel(); if (this.githubClient.getUser() == null) { setGithubConfig(); } try { RepositoryService githubRepoSrv = new RepositoryService(this.githubClient); List<org.eclipse.egit.github.core.Repository> forks; try { // get parent repository if repository itself is forked org.eclipse.egit.github.core.Repository parent = githubRepoSrv.getRepository(value, name).getParent(); if (parent != null) { // get fork of parent repository forks = githubRepoSrv.getForks(parent); for (org.eclipse.egit.github.core.Repository fork : forks) { org.eclipse.egit.github.core.User user = fork.getOwner(); aux.add(user.getLogin()); } } if (aux.isEmpty()) { // add forks of repository forks = githubRepoSrv.getForks(new RepositoryId(value, name)); for (org.eclipse.egit.github.core.Repository fork : forks) { org.eclipse.egit.github.core.User user = fork.getOwner(); aux.add(user.getLogin()); } } aux.add(0, value); } catch (Exception ex) { } try { // try to use global githubLogin, find repository and add forks forks = githubRepoSrv.getForks(new RepositoryId(this.githubLogin, name)); for (org.eclipse.egit.github.core.Repository fork : forks) { org.eclipse.egit.github.core.User user = fork.getOwner(); if (!aux.contains(user.getLogin())) { aux.add(user.getLogin()); } } } catch (Exception ex) { } } catch (Exception ex) { // TODO: handle exception } Collections.sort(aux); return this.forkItems = aux; }
public String getDiff() { if (diff == null && repositoryService.getRepository() != null) { Response response = null; try { response = bitbucketV2Client.getPullRequestDiff(repositoryOwner, repositoryName, id); if (response.getStatus() == HttpServletResponse.SC_OK) { diff = response.readEntity(String.class); } } finally { if (response != null) { response.close(); } } } return diff; }
public PullRequest getPullRequest() { if (pullRequest == null && repositoryService.getRepository() != null) { Response response = null; try { response = bitbucketV2Client.getPullRequestById(repositoryOwner, repositoryName, id); if (response.getStatus() == HttpServletResponse.SC_OK) { pullRequest = response.readEntity(PullRequest.class); } } finally { if (response != null) { response.close(); } } } return pullRequest; }
public TaskList getTaskList() { if (taskList == null && repositoryService.getRepository() != null && id != null) { Response response = null; try { response = bitBucketUndocumentedClient.getPullRequestTasks(repositoryOwner, repositoryName, id); if (response.getStatus() == HttpServletResponse.SC_OK) { taskList = response.readEntity(TaskList.class); } else { LOGGER.error("error getting task list. response:{}", response.getStatus()); } } finally { if (response != null) { response.close(); } } } return taskList; }
/** 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); }