Skip to content

Commit 211cde5

Browse files
author
Yevhenii Voevodin
committed
Add promise based getRepository method to the GithubServiceClient
1 parent 0057a88 commit 211cde5

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/GitHubClientService.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,21 @@ public interface GitHubClientService {
4141
* the repository name.
4242
* @param callback
4343
* callback called when operation is done.
44+
* @deprecated use {@link #getRepository(String, String)}
4445
*/
46+
@Deprecated
4547
void getRepository(@NotNull String user, @NotNull String repository, @NotNull AsyncRequestCallback<GitHubRepository> callback);
4648

49+
/**
50+
* Get given repository information.
51+
*
52+
* @param user
53+
* the owner of the repository.
54+
* @param repository
55+
* the repository name.
56+
*/
57+
Promise<GitHubRepository> getRepository(String user, String repository);
58+
4759
/**
4860
* Get list of available public and private repositories of the authorized user.
4961
*/
@@ -105,10 +117,14 @@ void commentIssue(@NotNull String user, @NotNull String repository, @NotNull Str
105117
/**
106118
* Get a pull request by id for a given repository.
107119
*
108-
* @param owner the owner of the target repository
109-
* @param repository the target repository
110-
* @param pullRequestId the Id of the pull request
111-
* @param callback the callback with either the pull request as argument or null if it doesn't exist
120+
* @param owner
121+
* the owner of the target repository
122+
* @param repository
123+
* the target repository
124+
* @param pullRequestId
125+
* the Id of the pull request
126+
* @param callback
127+
* the callback with either the pull request as argument or null if it doesn't exist
112128
*/
113129
void getPullRequest(@NotNull String owner,
114130
@NotNull String repository,

plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/GitHubClientServiceImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ public void getRepository(@NotNull String user, @NotNull String repository, @Not
8181
asyncRequestFactory.createGetRequest(url).loader(loader).send(callback);
8282
}
8383

84+
@Override
85+
public Promise<GitHubRepository> getRepository(String user, String repository) {
86+
final String url = baseUrl + REPOSITORIES + "/" + user + "/" + repository;
87+
return asyncRequestFactory.createGetRequest(url)
88+
.loader(loader)
89+
.send(dtoUnmarshallerFactory.newUnmarshaller(GitHubRepository.class));
90+
}
91+
8492
/** {@inheritDoc} */
8593
@Override
8694
public Promise<List<GitHubRepository>> getRepositoriesList() {

0 commit comments

Comments
 (0)