use of org.eclipse.egit.github.core.client.RequestException in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApi method findPullRequest.
@Override
@SneakyThrows
public Optional<PullRequest> findPullRequest(String repoId, int pullRequestId, String accessToken) {
GitHubClient client = createClient(accessToken);
PullRequestService service = new PullRequestService(client);
try {
return Optional.ofNullable(service.getPullRequest(RepositoryId.createFromId(repoId), pullRequestId));
} catch (RequestException e) {
if (e.getStatus() == HttpStatus.NOT_FOUND.value()) {
return Optional.empty();
}
throw e;
}
}
use of org.eclipse.egit.github.core.client.RequestException in project ontrack by nemerosa.
the class DefaultOntrackGitHubClient method getIssue.
@Override
public GitHubIssue getIssue(String repository, int id) {
// Logging
logger.debug("[github] Getting issue {}/{}", repository, id);
// Getting a client
GitHubClient client = createGitHubClient();
// Issue service using this client
IssueService service = new IssueService(client);
// Gets the repository for this project
String owner = StringUtils.substringBefore(repository, "/");
String name = StringUtils.substringAfter(repository, "/");
Issue issue;
try {
issue = service.getIssue(owner, name, id);
} catch (RequestException ex) {
if (ex.getStatus() == 404) {
return null;
} else {
throw new OntrackGitHubClientException(ex);
}
} catch (IOException e) {
throw new OntrackGitHubClientException(e);
}
// Conversion
return new GitHubIssue(id, issue.getHtmlUrl(), issue.getTitle(), issue.getBodyText(), issue.getBodyHtml(), toUser(issue.getAssignee()), toLabels(issue.getLabels()), toState(issue.getState()), toMilestone(repository, issue.getMilestone()), toDateTime(issue.getCreatedAt()), toDateTime(issue.getUpdatedAt()), toDateTime(issue.getClosedAt()));
}
Aggregations