Exemplo n.º 1
0
  /**
   * Create issue
   *
   * @param user
   * @param repository
   * @param issue
   * @return created issue
   * @throws IOException
   */
  public Issue createIssue(String user, String repository, Issue issue) throws IOException {
    Assert.notNull("User cannot be null", user); // $NON-NLS-1$
    Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$
    StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
    uri.append('/').append(user).append('/').append(repository);
    uri.append(IGitHubConstants.SEGMENT_ISSUES);

    Map<Object, Object> params = createIssueMap(issue, true);
    return this.client.post(uri.toString(), params, Issue.class);
  }
Exemplo n.º 2
0
 /**
  * Get issue
  *
  * @param user
  * @param repository
  * @param id
  * @return issue
  * @throws IOException
  */
 public Issue getIssue(String user, String repository, String id) throws IOException {
   Assert.notNull("User cannot be null", user); // $NON-NLS-1$
   Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$
   Assert.notNull("Id cannot be null", id); // $NON-NLS-1$
   StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
   uri.append('/').append(user).append('/').append(repository);
   uri.append(IGitHubConstants.SEGMENT_ISSUES);
   uri.append('/').append(id);
   GitHubRequest request = createRequest().setUri(uri).setType(Issue.class);
   return (Issue) client.get(request).getBody();
 }
Exemplo n.º 3
0
 /**
  * Delete the issue comment with the given id
  *
  * @param user
  * @param repository
  * @param comment
  * @throws IOException
  */
 public void deleteComment(String user, String repository, String comment) throws IOException {
   Assert.notNull("User cannot be null", user); // $NON-NLS-1$
   Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$
   Assert.notNull("Comment cannot be null", comment); // $NON-NLS-1$
   StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
   uri.append('/').append(user).append('/').append(repository);
   uri.append(IGitHubConstants.SEGMENT_ISSUES);
   uri.append(IGitHubConstants.SEGMENT_COMMENTS);
   uri.append('/').append(comment);
   client.delete(uri.toString());
 }
Exemplo n.º 4
0
 /**
  * Get bulk issues request
  *
  * @param user
  * @param repository
  * @param filterData
  * @param start
  * @param size
  * @return paged request
  */
 protected PagedRequest<Issue> createIssuesRequest(
     String user, String repository, Map<String, String> filterData, int start, int size) {
   Assert.notNull("User cannot be null", user); // $NON-NLS-1$
   Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$
   StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
   uri.append('/').append(user).append('/').append(repository);
   uri.append(IGitHubConstants.SEGMENT_ISSUES);
   PagedRequest<Issue> request = createPagedRequest(start, size);
   request.setParams(filterData).setUri(uri);
   request.setType(new TypeToken<List<Issue>>() {}.getType());
   return request;
 }
Exemplo n.º 5
0
 /**
  * Get an issue's comments
  *
  * @param user
  * @param repository
  * @param id
  * @return list of matching issues
  * @throws IOException
  */
 public List<Comment> getComments(String user, String repository, String id) throws IOException {
   Assert.notNull("User cannot be null", user); // $NON-NLS-1$
   Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$
   Assert.notNull("Id cannot be null", id); // $NON-NLS-1$
   StringBuilder builder = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
   builder.append('/').append(user).append('/').append(repository);
   builder.append(IGitHubConstants.SEGMENT_ISSUES);
   builder.append('/').append(id);
   builder.append(IGitHubConstants.SEGMENT_COMMENTS);
   PagedRequest<Comment> request = createPagedRequest();
   request.setUri(builder.toString()).setType(new TypeToken<List<Comment>>() {}.getType());
   return getAll(request);
 }
Exemplo n.º 6
0
  /**
   * Edit issue
   *
   * @param user
   * @param repository
   * @param issue
   * @return created issue
   * @throws IOException
   */
  public Issue editIssue(String user, String repository, Issue issue) throws IOException {
    Assert.notNull("User cannot be null", user); // $NON-NLS-1$
    Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$
    Assert.notNull("Issue cannot be null", issue); // $NON-NLS-1$
    StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
    uri.append('/').append(user).append('/').append(repository);
    uri.append(IGitHubConstants.SEGMENT_ISSUES);
    uri.append('/').append(issue.getNumber());

    Map<Object, Object> params = createIssueMap(issue, false);
    String state = issue.getState();
    if (state != null) params.put(FILTER_STATE, state);
    return this.client.post(uri.toString(), params, Issue.class);
  }
Exemplo n.º 7
0
  /**
   * Create comment on specified issue id
   *
   * @param user
   * @param repository
   * @param issueId
   * @param comment
   * @return created issue
   * @throws IOException
   */
  public Comment createComment(String user, String repository, String issueId, String comment)
      throws IOException {
    Assert.notNull("User cannot be null", user); // $NON-NLS-1$
    Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$
    Assert.notNull("Issue id cannot be null", issueId); // $NON-NLS-1$
    StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
    uri.append('/').append(user).append('/').append(repository);
    uri.append(IGitHubConstants.SEGMENT_ISSUES);
    uri.append('/').append(issueId);
    uri.append(IGitHubConstants.SEGMENT_COMMENTS);

    Map<String, String> params = new HashMap<String, String>(1, 1);
    params.put(FIELD_BODY, comment);

    return this.client.post(uri.toString(), params, Comment.class);
  }