/**
   * @param id
   * @param model
   * @return
   */
  @RequestMapping(value = "/{id}/scm/collaborators", method = RequestMethod.GET)
  public String getCollaborators(@PathVariable Long id, Model model) {
    Application app = applicationService.findOne(id);

    // FIXME Currently assuming GitHub.
    GitHubScm scm = (GitHubScm) app.getScm();

    // TODO Would like to put this inside GitHubScm, but don't want to use Spring Social GitHub as
    // the data model
    // here since that is intended more for data transfer. We need to control the OJM/OXM here, and
    // don't want
    // changes to the Spring Social GitHub API to produce changes to our web service API. But I'm
    // not necessarily
    // excited about implementing that entire data model here. Considering options.
    List<GitHubUser> collaborators =
        gitHub.repoOperations().getCollaborators(scm.getUser(), scm.getRepo());
    List<List<GitHubUser>> collaboratorRows = ViewUtil.toRows(collaborators, 3);

    model.addAttribute(app);
    model.addAttribute("entity", app);
    model.addAttribute("collaboratorList", collaborators);
    model.addAttribute("collaboratorRows", collaboratorRows);

    return addNavigation(model, "applicationScmCollaborators");
  }
 public UserProfile fetchUserProfile(GitHub github) {
   GitHubUserProfile profile = github.userOperations().getUserProfile();
   return new UserProfileBuilder()
       .setName(profile.getName())
       .setEmail(profile.getEmail())
       .setUsername(profile.getLogin())
       .build();
 }
 public void setConnectionValues(GitHub github, ConnectionValues values) {
   GitHubUserProfile profile = github.userOperations().getUserProfile();
   values.setProviderUserId(String.valueOf(profile.getId()));
   values.setDisplayName(profile.getLogin());
   values.setProfileUrl(
       "https://github.com/" + profile.getLogin()); // TODO: Expose and use HTML URL
   values.setImageUrl(profile.getAvatarUrl());
 }
 public boolean test(GitHub github) {
   try {
     github.userOperations().getUserProfile();
     return true;
   } catch (HttpClientErrorException e) {
     // TODO : Beef up GitHub's error handling and trigger off of a more specific exception
     return false;
   }
 }
  /**
   * @param id
   * @param model
   * @return
   */
  @RequestMapping(value = "/{id}/scm/commits", method = RequestMethod.GET)
  public String getCommits(@PathVariable Long id, Model model) {
    Application app = applicationService.findOne(id);

    // FIXME Currently assuming GitHub.
    GitHubScm scm = (GitHubScm) app.getScm();
    List<GitHubCommit> commits = gitHub.repoOperations().getCommits(scm.getUser(), scm.getRepo());

    model.addAttribute(app);
    model.addAttribute("entity", app);
    model.addAttribute("commitList", commits);

    return addNavigation(model, "applicationScmCommits");
  }
  /**
   * @param id
   * @param model
   * @return
   */
  @RequestMapping(value = "/{id}/scm/watchers", method = RequestMethod.GET)
  public String getWatchers(@PathVariable Long id, Model model) {
    Application app = applicationService.findOne(id);

    // FIXME Currently assuming GitHub.
    GitHubScm scm = (GitHubScm) app.getScm();
    String user = scm.getUser();
    String repo = scm.getRepo();
    List<GitHubUser> watchers = gitHub.repoOperations().getWatchers(user, repo);
    List<List<GitHubUser>> watcherRows = ViewUtil.toRows(watchers, 3);

    model.addAttribute(app);
    model.addAttribute("entity", app);
    model.addAttribute("watcherList", watchers);
    model.addAttribute("watcherRows", watcherRows);

    return addNavigation(model, "applicationScmWatchers");
  }
예제 #7
0
 private GitHubUser[] getGitHubUsers(GitHub gitHub) {
   String membersUrl = GitHubClient.API_URL_BASE + "/teams/{teamId}/members";
   ResponseEntity<GitHubUser[]> entity =
       gitHub.restOperations().getForEntity(membersUrl, GitHubUser[].class, gitHubTeamId);
   return entity.getBody();
 }