use of org.gitlab4j.api.models.Author in project catma by forTEXT.
the class GitlabManagerRestricted method getComments.
@Override
public List<Comment> getComments(String projectId) throws IOException {
try {
List<Comment> result = new ArrayList<Comment>();
IssuesApi issuesApi = new IssuesApi(restrictedGitLabApi);
String projectPath = projectId;
List<Issue> issues = issuesApi.getGroupIssues(projectPath, new IssueFilter().withLabels(Collections.singletonList(CATMA_COMMENT_LABEL)).withState(IssueState.OPENED));
for (Issue issue : issues) {
String description = issue.getDescription();
int noteCount = issue.getUserNotesCount();
try {
Author author = issue.getAuthor();
Comment comment = new SerializationHelper<Comment>().deserialize(description, Comment.class);
comment.setId(issue.getId());
comment.setIid(issue.getIid());
comment.setUserId(author.getId());
comment.setUsername(author.getName());
comment.setReplyCount(noteCount);
result.add(comment);
} catch (Exception e) {
logger.log(Level.SEVERE, String.format("Error deserializing Comment #%1$d %2$s", issue.getId(), description), e);
}
}
return result;
} catch (GitLabApiException e) {
throw new IOException(String.format("Failed to retrieve Comments in group %1$s!", projectId), e);
}
}
Aggregations