From 211cde53363a4a85806c9c99fc792d098b70e4e3 Mon Sep 17 00:00:00 2001 From: Yevhenii Voevodin Date: Fri, 26 Feb 2016 14:45:31 +0200 Subject: [PATCH] Add promise based getRepository method to the GithubServiceClient --- .../github/client/GitHubClientService.java | 24 +++++++++++++++---- .../client/GitHubClientServiceImpl.java | 8 +++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/GitHubClientService.java b/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/GitHubClientService.java index 47325126c1..521d3a3276 100644 --- a/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/GitHubClientService.java +++ b/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/GitHubClientService.java @@ -41,9 +41,21 @@ public interface GitHubClientService { * the repository name. * @param callback * callback called when operation is done. + * @deprecated use {@link #getRepository(String, String)} */ + @Deprecated void getRepository(@NotNull String user, @NotNull String repository, @NotNull AsyncRequestCallback callback); + /** + * Get given repository information. + * + * @param user + * the owner of the repository. + * @param repository + * the repository name. + */ + Promise getRepository(String user, String repository); + /** * Get list of available public and private repositories of the authorized user. */ @@ -105,10 +117,14 @@ public interface GitHubClientService { /** * Get a pull request by id for a given repository. * - * @param owner the owner of the target repository - * @param repository the target repository - * @param pullRequestId the Id of the pull request - * @param callback the callback with either the pull request as argument or null if it doesn't exist + * @param owner + * the owner of the target repository + * @param repository + * the target repository + * @param pullRequestId + * the Id of the pull request + * @param callback + * the callback with either the pull request as argument or null if it doesn't exist */ void getPullRequest(@NotNull String owner, @NotNull String repository, diff --git a/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/GitHubClientServiceImpl.java b/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/GitHubClientServiceImpl.java index 0acd29cbe4..4ce32ed5e4 100644 --- a/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/GitHubClientServiceImpl.java +++ b/plugins/plugin-github/che-plugin-github-ext-github/src/main/java/org/eclipse/che/ide/ext/github/client/GitHubClientServiceImpl.java @@ -81,6 +81,14 @@ public class GitHubClientServiceImpl implements GitHubClientService { asyncRequestFactory.createGetRequest(url).loader(loader).send(callback); } + @Override + public Promise getRepository(String user, String repository) { + final String url = baseUrl + REPOSITORIES + "/" + user + "/" + repository; + return asyncRequestFactory.createGetRequest(url) + .loader(loader) + .send(dtoUnmarshallerFactory.newUnmarshaller(GitHubRepository.class)); + } + /** {@inheritDoc} */ @Override public Promise> getRepositoriesList() {