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 521d3a32764..efc455924cf 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 @@ -70,9 +70,21 @@ public interface GitHubClientService { * the repository name. * @param callback * callback called when operation is done. + * @deprecated use {@link #getForks(String user, String repository)} */ + @Deprecated void getForks(@NotNull String user, @NotNull String repository, @NotNull AsyncRequestCallback callback); + /** + * Get list of forks for given repository + * + * @param user + * the owner of the repository. + * @param repository + * the repository name. + */ + Promise getForks(String user, String repository); + /** * Fork the given repository for the authorized user. * @@ -82,9 +94,21 @@ public interface GitHubClientService { * the repository name. * @param callback * callback called when operation is done. + * @deprecated use {@link #fork(String, String)} */ + @Deprecated void fork(@NotNull String user, @NotNull String repository, @NotNull AsyncRequestCallback callback); + /** + * Fork the given repository for the authorized user. + * + * @param user + * the owner of the repository to fork. + * @param repository + * the repository name. + */ + Promise fork(String user, String repository); + /** * Add a comment to the issue on the given repository. * @@ -111,9 +135,21 @@ void commentIssue(@NotNull String user, @NotNull String repository, @NotNull Str * the repository name. * @param callback * callback called when operation is done. + * @deprecated use {@link #getPullRequests(String, String)} */ + @Deprecated void getPullRequests(@NotNull String owner, @NotNull String repository, @NotNull AsyncRequestCallback callback); + /** + * Get pull requests for given repository. + * + * @param owner + * the repository owner. + * @param repository + * the repository name. + */ + Promise getPullRequests(@NotNull String owner, @NotNull String repository); + /** * Get a pull request by id for a given repository. * @@ -142,10 +178,28 @@ void getPullRequest(@NotNull String owner, * the pull request information. * @param callback * callback called when operation is done. + * @deprecated use {@link #createPullRequest(String, String, GitHubPullRequestCreationInput)} */ - void createPullRequest(@NotNull String user, @NotNull String repository, @NotNull GitHubPullRequestCreationInput input, + @Deprecated + void createPullRequest(@NotNull String user, + @NotNull String repository, + @NotNull GitHubPullRequestCreationInput input, @NotNull AsyncRequestCallback callback); + /** + * Create a pull request on origin repository + * + * @param user + * the owner of the repository. + * @param repository + * the repository name. + * @param input + * the pull request information. + */ + Promise createPullRequest(@NotNull String user, + @NotNull String repository, + @NotNull GitHubPullRequestCreationInput input); + /** * Get the list of available public repositories for a GitHub user. * 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 4ce32ed5e4f..29bd794c56b 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 @@ -99,12 +99,20 @@ public Promise> getRepositoriesList() { /** {@inheritDoc} */ @Override - public void getForks(@NotNull String user, @NotNull String repository, + public void getForks(@NotNull String user, + @NotNull String repository, @NotNull AsyncRequestCallback callback) { String url = baseUrl + FORKS + "/" + user + "/" + repository; asyncRequestFactory.createGetRequest(url).loader(loader).send(callback); } + @Override + public Promise getForks(String user, String repository) { + return asyncRequestFactory.createGetRequest(baseUrl + FORKS + '/' + user + '/' + repository) + .loader(loader) + .send(dtoUnmarshallerFactory.newUnmarshaller(GitHubRepositoryList.class)); + } + /** {@inheritDoc} */ @Override public void fork(@NotNull String user, @NotNull String repository, @NotNull AsyncRequestCallback callback) { @@ -112,6 +120,13 @@ public void fork(@NotNull String user, @NotNull String repository, @NotNull Asyn asyncRequestFactory.createGetRequest(url).loader(loader).send(callback); } + @Override + public Promise fork(String user, String repository) { + return asyncRequestFactory.createGetRequest(baseUrl + CREATE_FORK + '/' + user + '/' + repository) + .loader(loader) + .send(dtoUnmarshallerFactory.newUnmarshaller(GitHubRepository.class)); + } + @Override public void commentIssue(@NotNull String user, @NotNull String repository, @NotNull String issue, @NotNull GitHubIssueCommentInput input, @NotNull AsyncRequestCallback callback) { @@ -126,6 +141,14 @@ public void getPullRequests(@NotNull String owner, @NotNull String repository, asyncRequestFactory.createGetRequest(url).loader(loader).send(callback); } + @Override + public Promise getPullRequests(@NotNull String owner, @NotNull String repository) { + final String url = baseUrl + PULL_REQUESTS + '/' + owner + '/' + repository; + return asyncRequestFactory.createGetRequest(url) + .loader(loader) + .send(dtoUnmarshallerFactory.newUnmarshaller(GitHubPullRequestList.class)); + } + @Override public void getPullRequest(final String owner, final String repository, final String pullRequestId, final AsyncRequestCallback callback) { @@ -141,6 +164,16 @@ public void createPullRequest(@NotNull String user, @NotNull String repository, asyncRequestFactory.createPostRequest(url, input).loader(loader).send(callback); } + @Override + public Promise createPullRequest(@NotNull String user, + @NotNull String repository, + @NotNull GitHubPullRequestCreationInput input) { + final String url = baseUrl + PULL_REQUEST + '/' + user + '/' + repository; + return asyncRequestFactory.createPostRequest(url, input) + .loader(loader) + .send(dtoUnmarshallerFactory.newUnmarshaller(GitHubPullRequest.class)); + } + /** {@inheritDoc} */ @Override public void getRepositoriesByUser(String userName, @NotNull AsyncRequestCallback callback) {