From aac3f7ad30b59f6fe48737bdd682a296474f5086 Mon Sep 17 00:00:00 2001 From: Boris Yakovito Date: Tue, 19 Apr 2016 20:42:03 +0300 Subject: [PATCH 1/6] Feature: Added operation to get all user's repositories --- .../social/github/api/UserOperations.java | 9 +++++++++ .../social/github/api/impl/UserTemplate.java | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/UserOperations.java b/spring-social-github/src/main/java/org/springframework/social/github/api/UserOperations.java index 5bf441a2..bb00e05d 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/UserOperations.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/UserOperations.java @@ -60,4 +60,13 @@ public interface UserOperations { * @return list of users the given user is following */ List getFollowing(String user); + + + /** + * Public operation to return the user's repositories + * + * @param user GitHub user + * @return list of repositories + */ + List getRepos(String user); } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/UserTemplate.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/UserTemplate.java index c76c8cd5..409c2776 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/UserTemplate.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/UserTemplate.java @@ -23,8 +23,8 @@ import java.util.Date; import java.util.List; import java.util.Locale; -import java.util.Map; +import org.springframework.social.github.api.GitHubRepo; import org.springframework.social.github.api.GitHubUser; import org.springframework.social.github.api.GitHubUserProfile; import org.springframework.social.github.api.UserOperations; @@ -71,7 +71,10 @@ public String getProfileUrl() { return "https://github.com/" + getUserProfile().getLogin(); } - + @Override + public List getRepos(String user) { + return asList(restTemplate.getForObject(buildUserUri("/repos"), GitHubRepo[].class, user)); + } private String buildUserUri(String path) { return buildUri("users/{user}" + path); From eb4bb46e310be415daf5ed5bd61836d7173cdffd Mon Sep 17 00:00:00 2001 From: Boris Yakovito Date: Wed, 4 May 2016 12:28:19 +0300 Subject: [PATCH 2/6] Test data should be placed in /resources folder, not in the java sources. --- .../org/springframework/social/github/api/impl/gist-comment.json | 0 .../org/springframework/social/github/api/impl/gist-comments.json | 0 .../org/springframework/social/github/api/impl/gists-public.json | 0 .../org/springframework/social/github/api/impl/profile.json | 0 .../social/github/api/impl/repo-collaborators.json | 0 .../org/springframework/social/github/api/impl/repo-commits.json | 0 .../org/springframework/social/github/api/impl/repo-download.json | 0 .../springframework/social/github/api/impl/repo-downloads.json | 0 .../org/springframework/social/github/api/impl/repo-forks.json | 0 .../org/springframework/social/github/api/impl/repo-hooks.json | 0 .../org/springframework/social/github/api/impl/repo-issues.json | 0 .../org/springframework/social/github/api/impl/repo-watchers.json | 0 .../org/springframework/social/github/api/impl/repo.json | 0 .../springframework/social/github/api/impl/user-followers.json | 0 .../springframework/social/github/api/impl/user-following.json | 0 .../org/springframework/social/github/api/impl/user-gists.json | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/gist-comment.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/gist-comments.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/gists-public.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/profile.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/repo-collaborators.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/repo-commits.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/repo-download.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/repo-downloads.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/repo-forks.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/repo-hooks.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/repo-issues.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/repo-watchers.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/repo.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/user-followers.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/user-following.json (100%) rename spring-social-github/src/test/{java => resources}/org/springframework/social/github/api/impl/user-gists.json (100%) diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/gist-comment.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/gist-comment.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/gist-comment.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/gist-comment.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/gist-comments.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/gist-comments.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/gist-comments.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/gist-comments.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/gists-public.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/gists-public.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/gists-public.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/gists-public.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/profile.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/profile.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/profile.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/profile.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-collaborators.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-collaborators.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-collaborators.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-collaborators.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-commits.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-commits.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-commits.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-commits.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-download.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-download.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-download.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-download.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-downloads.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-downloads.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-downloads.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-downloads.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-forks.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-forks.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-forks.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-forks.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-hooks.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-hooks.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-hooks.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-hooks.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-issues.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-issues.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-issues.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-issues.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-watchers.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-watchers.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo-watchers.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo-watchers.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/repo.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/repo.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/user-followers.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/user-followers.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/user-followers.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/user-followers.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/user-following.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/user-following.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/user-following.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/user-following.json diff --git a/spring-social-github/src/test/java/org/springframework/social/github/api/impl/user-gists.json b/spring-social-github/src/test/resources/org/springframework/social/github/api/impl/user-gists.json similarity index 100% rename from spring-social-github/src/test/java/org/springframework/social/github/api/impl/user-gists.json rename to spring-social-github/src/test/resources/org/springframework/social/github/api/impl/user-gists.json From f8be3f085eb1cad992158d5ba1f663321a02f13e Mon Sep 17 00:00:00 2001 From: Boris Yakovito Date: Wed, 4 May 2016 12:34:10 +0300 Subject: [PATCH 3/6] Updated gradle dependency versions; Added maven pom.xml for maven builds integration; --- build.gradle | 10 ++-- spring-social-github/pom.xml | 102 +++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 spring-social-github/pom.xml diff --git a/build.gradle b/build.gradle index 29145917..d54435c7 100644 --- a/build.gradle +++ b/build.gradle @@ -21,11 +21,11 @@ configure(allprojects) { ext { springSocialVersion = '1.1.4.RELEASE' - jacksonVersion = '2.3.0' - junitVersion = '4.11' - mockitoVersion = '1.9.5' - servletApiVersion = '3.0.1' - springVersion = '4.0.2.RELEASE' + jacksonVersion = '2.6.5' + junitVersion = '4.12' + mockitoVersion = '1.10.19' + servletApiVersion = '3.1.0' + springVersion = '4.2.5.RELEASE' } [compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:none'] diff --git a/spring-social-github/pom.xml b/spring-social-github/pom.xml new file mode 100644 index 00000000..ac765249 --- /dev/null +++ b/spring-social-github/pom.xml @@ -0,0 +1,102 @@ + + + 4.0.0 + org.springframework.social + spring-social-github + Spring Social GitHub + 1.0.0.CONTRIB + + Spring Social extension with connection support and an API binding for GitHub + + + 1.1.4.RELEASE + 2.6.5 + 4.2.5.RELEASE + 1.10.19 + + + + + org.springframework.maven.release + Spring Maven Release Repository + http://maven.springframework.org/release + + true + + + false + + + + org.springframework.maven.milestone + Spring Maven Milestone Repository + http://maven.springframework.org/milestone + + false + + + + + + + org.springframework.social + spring-social-core + ${spring.social.version} + + + org.springframework.social + spring-social-config + ${spring.social.version} + + + org.springframework.social + spring-social-security + ${spring.social.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + + org.springframework + spring-test + ${spring.version} + test + + + junit + junit + 4.12 + test + + + org.mockito + mockito-all + ${mockito.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.5 + 1.5 + + + + + + \ No newline at end of file From 5a47c5d6b764b36937a481a5cdff79cd417f822c Mon Sep 17 00:00:00 2001 From: Boris Yakovito Date: Wed, 4 May 2016 12:35:25 +0300 Subject: [PATCH 4/6] Added API allowing to get branches of the GitHub repo --- .../social/github/api/GitHubBranch.java | 25 +++++++++++++++++++ .../social/github/api/RepoOperations.java | 11 +++++++- .../social/github/api/impl/RepoTemplate.java | 15 ++++++----- .../api/impl/json/GitHubBranchMixin.java | 14 +++++++++++ .../github/api/impl/json/GitHubModule.java | 2 +- 5 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 spring-social-github/src/main/java/org/springframework/social/github/api/GitHubBranch.java create mode 100644 spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubBranchMixin.java diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubBranch.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubBranch.java new file mode 100644 index 00000000..de8cf329 --- /dev/null +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubBranch.java @@ -0,0 +1,25 @@ +package org.springframework.social.github.api; + +import java.io.Serializable; + +/** + * A GitHub repo branch. + * + * @author Boris Yakovito + */ +public class GitHubBranch implements Serializable { + + private String name; + + public GitHubBranch(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/RepoOperations.java b/spring-social-github/src/main/java/org/springframework/social/github/api/RepoOperations.java index cb0bc6db..d488c03e 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/RepoOperations.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/RepoOperations.java @@ -32,7 +32,16 @@ public interface RepoOperations { * @return repo */ GitHubRepo getRepo(String user, String repo); - + + /** + * Public operation to return a list of branches for the given repository. + * + * @param user GitHub user + * @param repo GitHub repository + * @return list of collaborators + */ + List getBranches(String user, String repo); + /** * Public operation to return a list of collaborators for the given repository. * diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/RepoTemplate.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/RepoTemplate.java index b3f7a0d5..6fc4bf41 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/RepoTemplate.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/RepoTemplate.java @@ -19,13 +19,7 @@ import java.util.List; -import org.springframework.social.github.api.GitHubCommit; -import org.springframework.social.github.api.GitHubDownload; -import org.springframework.social.github.api.GitHubHook; -import org.springframework.social.github.api.GitHubIssue; -import org.springframework.social.github.api.GitHubRepo; -import org.springframework.social.github.api.GitHubUser; -import org.springframework.social.github.api.RepoOperations; +import org.springframework.social.github.api.*; import org.springframework.web.client.RestTemplate; /** @@ -52,7 +46,12 @@ public RepoTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser) { public GitHubRepo getRepo(String user, String repo) { return restTemplate.getForObject(buildRepoUri(""), GitHubRepo.class, user, repo); } - + + @Override + public List getBranches(String user, String repo) { + return asList(restTemplate.getForObject(buildRepoUri("/branches"), GitHubBranch[].class, user, repo)); + } + public List getCollaborators(String user, String repo) { return asList(restTemplate.getForObject(buildRepoUri("/collaborators"), GitHubUser[].class, user, repo)); } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubBranchMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubBranchMixin.java new file mode 100644 index 00000000..eac922f9 --- /dev/null +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubBranchMixin.java @@ -0,0 +1,14 @@ +package org.springframework.social.github.api.impl.json; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.springframework.social.github.api.GitHubBranch; + +/** + * Annotated mixin to add annotations to {@link GitHubBranch} + * + * @author Boris Yakovito + */ +public class GitHubBranchMixin extends GitHubObjectMixin { + + GitHubBranchMixin(@JsonProperty("name") String name) {} +} diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubModule.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubModule.java index ba2954e8..92988f63 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubModule.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubModule.java @@ -15,7 +15,6 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.module.SimpleModule; import org.springframework.social.github.api.*; @@ -40,6 +39,7 @@ public void setupModule(SetupContext context) { context.setMixInAnnotations(GitHubHook.class, GitHubHookMixin.class); context.setMixInAnnotations(GitHubIssue.class, GitHubIssueMixin.class); context.setMixInAnnotations(GitHubRepo.class, GitHubRepoMixin.class); + context.setMixInAnnotations(GitHubBranch.class, GitHubBranchMixin.class); context.setMixInAnnotations(GitHubUser.class, GitHubUserMixin.class); context.setMixInAnnotations(GitHubUserProfile.class, GitHubUserProfileMixin.class); } From 675318b6fdbda90201dedc49b3864f7a8f0a4d98 Mon Sep 17 00:00:00 2001 From: Boris Yakovito Date: Wed, 4 May 2016 13:08:51 +0300 Subject: [PATCH 5/6] Added target to git ignore list --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index deaf0118..24adfbae 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ .DS_Store build **/build +target +**/target **/src/test/java/exploration .gradle spring-social-core/src/test/java/exploration From edfdcc148c3ccd112db0eefa00a1e0fff665c9d4 Mon Sep 17 00:00:00 2001 From: Barys Yakavita Date: Tue, 1 Sep 2020 01:15:20 +0300 Subject: [PATCH 6/6] Update README --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 511b1c62..a20711e7 100644 --- a/README +++ b/README @@ -1,3 +1,4 @@ +1 ============================= Spring Social GitHub ============================ To check out the project and build from source, do the following: