From b7560bcf9eca037f2814ed6b30380a7cecea1b70 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 11 Mar 2015 14:35:19 -0400 Subject: [PATCH 1/2] Consistent use of tabs and imports Replace spaces with tabs and organize imports --- .../social/github/api/GistOperations.java | 30 +++--- .../social/github/api/GitHubComment.java | 73 ++++++------- .../social/github/api/GitHubCommit.java | 28 +++-- .../social/github/api/GitHubDownload.java | 32 +++--- .../social/github/api/GitHubFile.java | 39 ++++--- .../social/github/api/GitHubGist.java | 53 +++++---- .../social/github/api/GitHubHook.java | 41 ++++--- .../social/github/api/GitHubIssue.java | 42 ++++---- .../social/github/api/GitHubRepo.java | 47 ++++---- .../social/github/api/GitHubUser.java | 32 +++--- .../social/github/api/GitHubUserProfile.java | 102 +++++++++--------- .../social/github/api/RepoOperations.java | 32 +++--- .../social/github/api/UserOperations.java | 18 ++-- .../api/impl/AbstractGitHubOperations.java | 10 +- .../social/github/api/impl/GistTemplate.java | 4 +- .../github/api/impl/GitHubTemplate.java | 43 ++++---- .../social/github/api/impl/UserTemplate.java | 13 +-- .../api/impl/json/GitHubCommentMixin.java | 25 ++--- .../api/impl/json/GitHubCommitMixin.java | 15 +-- .../api/impl/json/GitHubDownloadMixin.java | 21 ++-- .../github/api/impl/json/GitHubFileMixin.java | 21 ++-- .../github/api/impl/json/GitHubGistMixin.java | 37 +++---- .../github/api/impl/json/GitHubHookMixin.java | 21 ++-- .../api/impl/json/GitHubIssueMixin.java | 35 +++--- .../github/api/impl/json/GitHubModule.java | 45 ++++---- .../github/api/impl/json/GitHubRepoMixin.java | 27 ++--- .../github/api/impl/json/GitHubUserMixin.java | 21 ++-- .../api/impl/json/GitHubUserProfileMixin.java | 37 +++---- .../xml/GitHubConfigBeanDefinitionParser.java | 10 +- .../config/xml/GitHubNamespaceHandler.java | 2 +- .../social/github/connect/GitHubAdapter.java | 6 +- .../connect/GitHubConnectionFactory.java | 2 +- .../github/connect/GitHubServiceProvider.java | 2 +- 33 files changed, 479 insertions(+), 487 deletions(-) diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GistOperations.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GistOperations.java index 819653f4..044da9e8 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GistOperations.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GistOperations.java @@ -19,61 +19,61 @@ /** * Interface defining the operations for working with GitHub gists. - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) */ public interface GistOperations { - + /** * Public operation to return the given user's public gists. - * + * * @param user GitHub user * @return list of user's gists */ List getUserGists(String user); - + /** *

* If authenticated, this method returns the current user's gists. Otherwise it returns all public gists. *

- * + * * @return current user's gists, or else all public gists */ List getGists(); - + /** * Public operation to return all public gists. - * + * * @return all public gists */ List getPublicGists(); - + /** * Returns the authenticated user's starred gists. - * + * * @return authenticated user's starred gists */ List getStarredGists(); - + /** * Returns the gist with the given ID. - * + * * @param id gist ID * @return gist */ GitHubGist getGist(String id); - + /** * Public operation to return the comments on a given gist. - * + * * @param gistId gist ID * @return gist comments */ List getGistComments(String gistId); - + /** * Public operation to return a gist comment. - * + * * @param id comment ID * @return comment */ diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubComment.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubComment.java index 7b4cd229..930e5d8d 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubComment.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubComment.java @@ -18,63 +18,60 @@ import java.io.Serializable; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - /** * A GitHub comment. - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) * @author Andy Wilkinson */ @SuppressWarnings("serial") public class GitHubComment implements Serializable { - private final long id; + private final long id; - private final String url; + private final String url; - private final GitHubUser user; + private final GitHubUser user; - private final Date createdAt; + private final Date createdAt; - private final Date updatedAt; + private final Date updatedAt; - private volatile String body; + private volatile String body; - public GitHubComment(long id, String url, GitHubUser user, Date createdAt, Date updatedAt) { - this.id = id; - this.url = url; - this.user = user; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - } + public GitHubComment(long id, String url, GitHubUser user, Date createdAt, Date updatedAt) { + this.id = id; + this.url = url; + this.user = user; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } - public long getId() { - return id; - } + public long getId() { + return id; + } - public String getUrl() { - return url; - } + public String getUrl() { + return url; + } - public GitHubUser getUser() { - return user; - } + public GitHubUser getUser() { + return user; + } - public Date getCreatedAt() { - return createdAt; - } + public Date getCreatedAt() { + return createdAt; + } - public Date getUpdatedAt() { - return updatedAt; - } + public Date getUpdatedAt() { + return updatedAt; + } - public String getBody() { - return body; - } + public String getBody() { + return body; + } - public void setBody(String body) { - this.body = body; - } + public void setBody(String body) { + this.body = body; + } } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubCommit.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubCommit.java index c40ae6d1..054aae5c 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubCommit.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubCommit.java @@ -17,11 +17,9 @@ import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - /** * A GitHub repository commit. - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) */ @SuppressWarnings("serial") @@ -37,15 +35,15 @@ public class GitHubCommit implements Serializable { private final GitHubUser author; - public GitHubCommit(String message, String sha, String url, GitHubUser committer, GitHubUser author) { - this.message = message; - this.sha = sha; - this.url = url; - this.committer = committer; - this.author = author; - } + public GitHubCommit(String message, String sha, String url, GitHubUser committer, GitHubUser author) { + this.message = message; + this.sha = sha; + this.url = url; + this.committer = committer; + this.author = author; + } - /** + /** * @return commit message */ public String getMessage() { return message; } @@ -61,8 +59,8 @@ public GitHubCommit(String message, String sha, String url, GitHubUser committer */ public GitHubUser getCommitter() { return committer; } - /** - * @return user who wrote the patch - */ - public GitHubUser getAuthor() { return author; } + /** + * @return user who wrote the patch + */ + public GitHubUser getAuthor() { return author; } } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubDownload.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubDownload.java index 3e62e369..b15a3798 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubDownload.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubDownload.java @@ -16,14 +16,10 @@ package org.springframework.social.github.api; import java.io.Serializable; -import java.util.Date; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; /** * A GitHub download. - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) * @author Andy Wilkinson */ @@ -46,19 +42,19 @@ public class GitHubDownload implements Serializable { private final String contentType; - public GitHubDownload(long id, String url, String htmlUrl, String name, String description, long size, - int downloadCount, String contentType) { - this.id = id; - this.url = url; - this.htmlUrl = htmlUrl; - this.name = name; - this.description = description; - this.size = size; - this.downloadCount = downloadCount; - this.contentType = contentType; - } - - public long getId() { return id; } + public GitHubDownload(long id, String url, String htmlUrl, String name, String description, long size, + int downloadCount, String contentType) { + this.id = id; + this.url = url; + this.htmlUrl = htmlUrl; + this.name = name; + this.description = description; + this.size = size; + this.downloadCount = downloadCount; + this.contentType = contentType; + } + + public long getId() { return id; } public String getUrl() { return url; } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubFile.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubFile.java index 7068feba..72c92cf2 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubFile.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubFile.java @@ -17,46 +17,43 @@ import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - /** * A GitHub file. - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) * @author Andy Wilkinson */ @SuppressWarnings("serial") public class GitHubFile implements Serializable { - private final String type; + private final String type; - private final String language; + private final String language; - private final String rawUrl; + private final String rawUrl; - private final long size; + private final long size; - private String filename; + private String filename; - private String content; + private String content; - public GitHubFile(String type, String language, String rawUrl, long size) { - this.type = type; - this.language = language; - this.rawUrl = rawUrl; - this.size = size; - } + public GitHubFile(String type, String language, String rawUrl, long size) { + this.type = type; + this.language = language; + this.rawUrl = rawUrl; + this.size = size; + } - public String getType() { return type; } + public String getType() { return type; } - public String getLanguage() { return language; } + public String getLanguage() { return language; } - public String getRawUrl() { return rawUrl; } + public String getRawUrl() { return rawUrl; } - public long getSize() { return size; } + public long getSize() { return size; } - public String getFilename() { return filename; } + public String getFilename() { return filename; } public void setFilename(String filename) { this.filename = filename; } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubGist.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubGist.java index 270d1660..b2a950d5 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubGist.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubGist.java @@ -19,12 +19,9 @@ import java.util.Date; import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - /** * A GitHub gist. - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) * @author Andy Wilkinson */ @@ -43,7 +40,7 @@ public class GitHubGist implements Serializable { private final String htmlUrl; - private final String gitPullUrl; + private final String gitPullUrl; private final String gitPushUrl; @@ -51,40 +48,40 @@ public class GitHubGist implements Serializable { private final Date updatedAt; - private String description; + private String description; - private Map files; + private Map files; - public GitHubGist(String id, String url, boolean publicGist, GitHubUser user, int comments, String htmlUrl, - String gitPullUrl, String gitPushUrl, Date createdAt, Date updatedAt) { - this.id = id; - this.url = url; - this.publicGist = publicGist; - this.user = user; - this.comments = comments; - this.htmlUrl = htmlUrl; - this.gitPullUrl = gitPullUrl; - this.gitPushUrl = gitPushUrl; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - } + public GitHubGist(String id, String url, boolean publicGist, GitHubUser user, int comments, String htmlUrl, + String gitPullUrl, String gitPushUrl, Date createdAt, Date updatedAt) { + this.id = id; + this.url = url; + this.publicGist = publicGist; + this.user = user; + this.comments = comments; + this.htmlUrl = htmlUrl; + this.gitPullUrl = gitPullUrl; + this.gitPushUrl = gitPushUrl; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } public String getId() { return id; } - + public String getUrl() { return url; } - + public String getDescription() { return description; } - + public void setDescription(String description) { this.description = description; } - + public boolean isPublic() { return publicGist; } - + public GitHubUser getUser() { return user; } - + public Map getFiles() { return files; } - + public void setFiles(Map files) { this.files = files; } - + public int getComments() { return comments; } public String getHtmlUrl() { return htmlUrl; } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubHook.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubHook.java index 9cf0290d..4a7aee71 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubHook.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubHook.java @@ -18,12 +18,9 @@ import java.io.Serializable; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - /** * A GitHub hook. Hooks share commits with other apps, such as Bamboo, Basecamp, e-mail and so forth. - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) * @author Andy Wilkinson */ @@ -36,35 +33,35 @@ public class GitHubHook implements Serializable { private final String url; - private final Date createdAt; + private final Date createdAt; - private final Date updatedAt; + private final Date updatedAt; private boolean active; - public GitHubHook(long id, String name, String url, Date createdAt, Date updatedAt) { - this.id = id; - this.name = name; - this.url = url; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - } + public GitHubHook(long id, String name, String url, Date createdAt, Date updatedAt) { + this.id = id; + this.name = name; + this.url = url; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + public long getId() { return id; } - public long getId() { return id; } - public String getName() { return name; } - + public String getUrl() { return url; } public Date getCreatedAt() { return createdAt; } public Date getUpdatedAt() { return updatedAt; } - public boolean isActive() { - return active; - } + public boolean isActive() { + return active; + } - public void setActive(boolean active) { - this.active = active; - } + public void setActive(boolean active) { + this.active = active; + } } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubIssue.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubIssue.java index d3da9c7d..dbb1c998 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubIssue.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubIssue.java @@ -32,11 +32,11 @@ public class GitHubIssue { private final String htmlUrl; - private final Date closedAt; + private final Date closedAt; - private final Date createdAt; + private final Date createdAt; - private final Date updatedAt; + private final Date updatedAt; private String state; @@ -46,16 +46,16 @@ public class GitHubIssue { private GitHubUser assignee; - public GitHubIssue(int number, String url, String htmlUrl, Date closedAt, Date createdAt, Date updatedAt) { - this.number = number; - this.url = url; - this.htmlUrl = htmlUrl; - this.closedAt = closedAt; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - } + public GitHubIssue(int number, String url, String htmlUrl, Date closedAt, Date createdAt, Date updatedAt) { + this.number = number; + this.url = url; + this.htmlUrl = htmlUrl; + this.closedAt = closedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } - public int getNumber() { + public int getNumber() { return number; } @@ -63,17 +63,17 @@ public String getUrl() { return url; } - public Date getClosedAt() { - return closedAt; - } + public Date getClosedAt() { + return closedAt; + } - public Date getCreatedAt() { - return createdAt; - } + public Date getCreatedAt() { + return createdAt; + } - public Date getUpdatedAt() { - return updatedAt; - } + public Date getUpdatedAt() { + return updatedAt; + } public String getHtmlUrl() { return htmlUrl; diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubRepo.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubRepo.java index d122a528..74e12861 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubRepo.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubRepo.java @@ -17,12 +17,9 @@ import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - /** * A GitHub repo. - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) * @author Andy Wilkinson */ @@ -43,23 +40,23 @@ public class GitHubRepo implements Serializable { private final String svnUrl; - public GitHubRepo(long id, String url, String htmlUrl, String cloneUrl, String gitUrl, String sshUrl, - String svnUrl) { - this.id = id; - this.url = url; - this.htmlUrl = htmlUrl; - this.cloneUrl = cloneUrl; - this.gitUrl = gitUrl; - this.sshUrl = sshUrl; - this.svnUrl = svnUrl; - } - - private String name; - - private String description; - + public GitHubRepo(long id, String url, String htmlUrl, String cloneUrl, String gitUrl, String sshUrl, + String svnUrl) { + this.id = id; + this.url = url; + this.htmlUrl = htmlUrl; + this.cloneUrl = cloneUrl; + this.gitUrl = gitUrl; + this.sshUrl = sshUrl; + this.svnUrl = svnUrl; + } + + private String name; + + private String description; + public long getId() { return id; } - + public String getUrl() { return url; } public String getHtmlUrl() { return htmlUrl; } @@ -72,12 +69,12 @@ public GitHubRepo(long id, String url, String htmlUrl, String cloneUrl, String g public String getSvnUrl() { return svnUrl; } - public String getName() { return name; } + public String getName() { return name; } + + public void setName(String name) { this.name = name; } - public void setName(String name) { this.name = name; } + public String getDescription() { return description; } - public String getDescription() { return description; } + public void setDescription(String description) { this.description = description; } - public void setDescription(String description) { this.description = description; } - } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubUser.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubUser.java index 26cac3b4..c0a3a4f0 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubUser.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubUser.java @@ -16,14 +16,10 @@ package org.springframework.social.github.api; import java.io.Serializable; -import java.util.Date; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; /** * A GitHub user - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) * @author Andy Wilkinson */ @@ -44,16 +40,16 @@ public class GitHubUser implements Serializable { private String email; - public GitHubUser(long id, String url, String login, String avatarUrl, String gravatarId) { - this.id = id; - this.url = url; - this.login = login; - this.avatarUrl = avatarUrl; - this.gravatarId = gravatarId; - } + public GitHubUser(long id, String url, String login, String avatarUrl, String gravatarId) { + this.id = id; + this.url = url; + this.login = login; + this.avatarUrl = avatarUrl; + this.gravatarId = gravatarId; + } + + public Long getId() { return id; } - public Long getId() { return id; } - public String getUrl() { return url; } public String getLogin() { return login; } @@ -61,12 +57,12 @@ public GitHubUser(long id, String url, String login, String avatarUrl, String gr public String getAvatarUrl() { return avatarUrl; } public String getGravatarId() { return gravatarId; } - + public String getName() { return name; } - + public void setName(String name) { this.name = name; } - + public String getEmail() { return email; } - + public void setEmail(String email) { this.email = email; } } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubUserProfile.java b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubUserProfile.java index 5e908e76..cf5a9f4b 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubUserProfile.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/GitHubUserProfile.java @@ -27,11 +27,11 @@ public class GitHubUserProfile implements Serializable { private final long id; - private final String login; + private final String login; - private final String avatarUrl; + private final String avatarUrl; - private final Date createdAt; + private final Date createdAt; private String name; @@ -43,66 +43,66 @@ public class GitHubUserProfile implements Serializable { private String email; - public GitHubUserProfile(long id, String login, String avatarUrl, Date createdAt) { - this.id = id; - this.login = login; - this.avatarUrl = avatarUrl; - this.createdAt = createdAt; - } + public GitHubUserProfile(long id, String login, String avatarUrl, Date createdAt) { + this.id = id; + this.login = login; + this.avatarUrl = avatarUrl; + this.createdAt = createdAt; + } - public long getId() { - return id; - } + public long getId() { + return id; + } - public String getLogin() { - return login; - } + public String getLogin() { + return login; + } - public String getAvatarUrl() { - return avatarUrl; - } + public String getAvatarUrl() { + return avatarUrl; + } - public Date getCreatedAt() { - return createdAt; - } + public Date getCreatedAt() { + return createdAt; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getLocation() { - return location; - } + public String getLocation() { + return location; + } - public void setLocation(String location) { - this.location = location; - } + public void setLocation(String location) { + this.location = location; + } - public String getCompany() { - return company; - } + public String getCompany() { + return company; + } - public void setCompany(String company) { - this.company = company; - } + public void setCompany(String company) { + this.company = company; + } - public String getBlog() { - return blog; - } + public String getBlog() { + return blog; + } - public void setBlog(String blog) { - this.blog = blog; - } + public void setBlog(String blog) { + this.blog = blog; + } - public String getEmail() { - return email; - } + public String getEmail() { + return email; + } - public void setEmail(String email) { - this.email = email; - } + public void setEmail(String email) { + this.email = email; + } } 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..2bc5cd7b 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 @@ -19,60 +19,60 @@ /** * Interface defining the operations for working with GitHub repositories. - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) */ public interface RepoOperations { - + /** * Public operation to return a repo. - * + * * @param user GitHub user * @param repo GitHub repo * @return repo */ GitHubRepo getRepo(String user, String repo); - + /** * Public operation to return a list of collaborators for the given repository. - * + * * @param user GitHub user * @param repo GitHub repository * @return list of collaborators */ List getCollaborators(String user, String repo); - + /** * Public operation to return a list of commits for the given repository. - * + * * @param user GitHub user * @param repo GitHub repository * @return list of commits */ List getCommits(String user, String repo); - + /** * Public operation to return a list of downloads for the given repository. - * + * * @param user GitHub user * @param repo GitHub repository * @return list of downloads */ List getDownloads(String user, String repo); - + /** * Public operation to return a single download. - * + * * @param user GitHub user * @param repo GitHub repository * @param id download ID * @return download */ GitHubDownload getDownload(String user, String repo, Long id); - + /** * Public operation to return the forks for the given repository. - * + * * @param user GitHub user * @param repo GitHub repository * @return list of repository forks @@ -91,16 +91,16 @@ public interface RepoOperations { /** * Public operation to return a list of watchers for the given repository. - * + * * @param user GitHub user * @param repo GitHub repository * @return list of watchers */ List getWatchers(String user, String repo); - + /** * Authorized operation to return a list of hooks for the given repository. - * + * * @param user GitHub user * @param repo GitHub repository * @return list of hooks 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..9510b90e 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 @@ -19,43 +19,43 @@ /** * Interface defining the operations for working with GitHub users. - * + * * @author Willie Wheeler (willie.wheeler@gmail.com) */ public interface UserOperations { - + /** * Retrieves the user's GitHub profile ID. - * + * * @return the user's GitHub profile ID. */ String getProfileId(); /** * Retrieves the user's GitHub profile details. - * + * * @return the user's GitHub profile */ GitHubUserProfile getUserProfile(); /** * Retrieve the URL to the user's GitHub profile. - * + * * @return the URL to the user's GitHub profile. */ String getProfileUrl(); - + /** * Public operation to return a given user's followers. - * + * * @param user GitHub user * @return list of followers */ List getFollowers(String user); - + /** * Public operation to return the users that a given user is following. - * + * * @param user GitHub user * @return list of users the given user is following */ diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/AbstractGitHubOperations.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/AbstractGitHubOperations.java index afcbf0b5..28c972e7 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/AbstractGitHubOperations.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/AbstractGitHubOperations.java @@ -21,28 +21,28 @@ *

* Based on AbstractTwitterOperations, by Keith Donald. *

- * + * * @author Willie Wheeler (willie.wheeler@gmail.com) */ class AbstractGitHubOperations { private final boolean isAuthorized; - + public AbstractGitHubOperations(boolean isAuthorized) { this.isAuthorized = isAuthorized; } - + protected void requireAuthorization() { if (!isAuthorized) { throw new MissingAuthorizationException("github"); } } - + // Using String here instead of URI so I can include braces in the path. See, e.g., RepoTemplate. [WLW] protected String buildUri(String path) { // return URIBuilder.fromUri(API_URL_BASE + path).build(); return API_URL_BASE + path; } - + // GitHub API v3 private static final String API_URL_BASE = "https://api.github.com/"; } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GistTemplate.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GistTemplate.java index eb303edf..0aaa6e16 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GistTemplate.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GistTemplate.java @@ -28,13 +28,13 @@ *

* Gist template implementation. *

- * + * * @author Willie Wheeler (willie.wheeler@gmail.com) */ public class GistTemplate extends AbstractGitHubOperations implements GistOperations { private final RestTemplate restTemplate; - + /** * @param restTemplate A RestTemplate * @param isAuthorizedForUser Boolean indicating whether the RestTemplate is authorized for a user diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GitHubTemplate.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GitHubTemplate.java index 6bc1400c..b1e0a862 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GitHubTemplate.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GitHubTemplate.java @@ -15,7 +15,6 @@ */ package org.springframework.social.github.api.impl; -import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.social.github.api.GistOperations; import org.springframework.social.github.api.GitHub; @@ -26,6 +25,8 @@ import org.springframework.social.oauth2.OAuth2Version; import org.springframework.web.client.RestOperations; +import com.fasterxml.jackson.databind.ObjectMapper; + /** *

* The central class for interacting with GitHub. @@ -38,7 +39,7 @@ public class GitHubTemplate extends AbstractOAuth2ApiBinding implements GitHub { private GistOperations gistOperations; private RepoOperations repoOperations; private UserOperations userOperations; - + /** * No-arg constructor to support cases in which you want to call the GitHub * API without requiring authorization. This is useful for public operations, @@ -48,12 +49,12 @@ public GitHubTemplate() { super(); initSubApis(); } - + /** * Constructs a GitHubTemplate with the minimal amount of information * required to sign requests with an OAuth Authorization * header. - * + * * @param accessToken * An access token granted to the application after OAuth * authentication. @@ -67,34 +68,34 @@ public GitHubTemplate(String accessToken) { protected OAuth2Version getOAuth2Version() { return OAuth2Version.BEARER; } - + public GistOperations gistOperations() { return gistOperations; } - + public RepoOperations repoOperations() { - return repoOperations; + return repoOperations; } - - public UserOperations userOperations() { - return userOperations; + + public UserOperations userOperations() { + return userOperations; } - + public RestOperations restOperations() { return getRestTemplate(); } - @Override - protected MappingJackson2HttpMessageConverter getJsonMessageConverter() { - MappingJackson2HttpMessageConverter converter = super.getJsonMessageConverter(); - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.registerModule(new GitHubModule()); - converter.setObjectMapper(objectMapper); - return converter; - } + @Override + protected MappingJackson2HttpMessageConverter getJsonMessageConverter() { + MappingJackson2HttpMessageConverter converter = super.getJsonMessageConverter(); + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new GitHubModule()); + converter.setObjectMapper(objectMapper); + return converter; + } + + // internal helpers - // internal helpers - private void initSubApis() { this.gistOperations = new GistTemplate(getRestTemplate(), isAuthorized()); this.repoOperations = new RepoTemplate(getRestTemplate(), isAuthorized()); 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..c78d2c0b 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 @@ -15,7 +15,7 @@ */ package org.springframework.social.github.api.impl; -import static java.util.Arrays.*; +import static java.util.Arrays.asList; import java.text.DateFormat; import java.text.ParseException; @@ -23,7 +23,6 @@ import java.util.Date; import java.util.List; import java.util.Locale; -import java.util.Map; import org.springframework.social.github.api.GitHubUser; import org.springframework.social.github.api.GitHubUserProfile; @@ -34,14 +33,14 @@ *

* User template implementation. *

- * + * * @author Willie Wheeler (willie.wheeler@gmail.com) * @author Andy Wilkinson */ public class UserTemplate extends AbstractGitHubOperations implements UserOperations { private final RestTemplate restTemplate; - + /** * @param restTemplate A RestTemplate * @param isAuthorizedForUser Boolean indicating whether the RestTemplate is authorized for a user @@ -71,12 +70,10 @@ public String getProfileUrl() { return "https://github.com/" + getUserProfile().getLogin(); } - - private String buildUserUri(String path) { return buildUri("users/{user}" + path); } - + private Date toDate(String dateString, DateFormat dateFormat) { try { return dateFormat.parse(dateString); @@ -86,5 +83,5 @@ private Date toDate(String dateString, DateFormat dateFormat) { } private DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss Z", Locale.ENGLISH); - + } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubCommentMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubCommentMixin.java index b08b0e83..79a6fee5 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubCommentMixin.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubCommentMixin.java @@ -15,12 +15,13 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Date; + import org.springframework.social.github.api.GitHubComment; import org.springframework.social.github.api.GitHubUser; -import java.util.Date; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Annotated mixin to add annotations to {@link GitHubComment} @@ -29,14 +30,14 @@ */ abstract class GitHubCommentMixin extends GitHubObjectMixin { - @JsonProperty("body") - String body; + @JsonProperty("body") + String body; - @JsonCreator - GitHubCommentMixin( - @JsonProperty("id") long id, - @JsonProperty("url") String url, - @JsonProperty("user") GitHubUser user, - @JsonProperty("created_at") Date createdAt, - @JsonProperty("updated_at") Date updatedAt) {} + @JsonCreator + GitHubCommentMixin( + @JsonProperty("id") long id, + @JsonProperty("url") String url, + @JsonProperty("user") GitHubUser user, + @JsonProperty("created_at") Date createdAt, + @JsonProperty("updated_at") Date updatedAt) {} } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubCommitMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubCommitMixin.java index 19a936dc..036c0845 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubCommitMixin.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubCommitMixin.java @@ -15,10 +15,11 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.social.github.api.GitHubCommit; import org.springframework.social.github.api.GitHubUser; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * Annotated mixin to add annotations to {@link GitHubCommit} * @@ -26,10 +27,10 @@ */ abstract class GitHubCommitMixin extends GitHubObjectMixin { - GitHubCommitMixin( - @JsonProperty("message") String message, - @JsonProperty("sha") String sha, - @JsonProperty("url") String url, - @JsonProperty("committer") GitHubUser committer, - @JsonProperty("author") GitHubUser author) {} + GitHubCommitMixin( + @JsonProperty("message") String message, + @JsonProperty("sha") String sha, + @JsonProperty("url") String url, + @JsonProperty("committer") GitHubUser committer, + @JsonProperty("author") GitHubUser author) {} } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubDownloadMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubDownloadMixin.java index e1ea8e49..f3f7d947 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubDownloadMixin.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubDownloadMixin.java @@ -15,9 +15,10 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.social.github.api.GitHubDownload; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * Annotated mixin to add annotations to {@link GitHubDownload} * @@ -25,13 +26,13 @@ */ abstract class GitHubDownloadMixin extends GitHubObjectMixin { - GitHubDownloadMixin( - @JsonProperty("id") long id, - @JsonProperty("url") String url, - @JsonProperty("html_url") String htmlUrl, - @JsonProperty("name") String name, - @JsonProperty("description") String description, - @JsonProperty("size") long size, - @JsonProperty("download_count") int downloadCount, - @JsonProperty("content_type") String contentType) {} + GitHubDownloadMixin( + @JsonProperty("id") long id, + @JsonProperty("url") String url, + @JsonProperty("html_url") String htmlUrl, + @JsonProperty("name") String name, + @JsonProperty("description") String description, + @JsonProperty("size") long size, + @JsonProperty("download_count") int downloadCount, + @JsonProperty("content_type") String contentType) {} } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubFileMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubFileMixin.java index 31ad0af0..09d5eb90 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubFileMixin.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubFileMixin.java @@ -15,9 +15,10 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.social.github.api.GitHubFile; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * Annotated mixin to add annotations to {@link GitHubFile} * @@ -25,16 +26,16 @@ */ abstract class GitHubFileMixin extends GitHubObjectMixin { - @JsonProperty("filename") - String filename; + @JsonProperty("filename") + String filename; - @JsonProperty("content") - String content; + @JsonProperty("content") + String content; - GitHubFileMixin( - @JsonProperty("type") String type, - @JsonProperty("language") String language, - @JsonProperty("raw_url") String rawUrl, - @JsonProperty("size") long size) {} + GitHubFileMixin( + @JsonProperty("type") String type, + @JsonProperty("language") String language, + @JsonProperty("raw_url") String rawUrl, + @JsonProperty("size") long size) {} } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubGistMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubGistMixin.java index 7c37142d..83c4a642 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubGistMixin.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubGistMixin.java @@ -15,13 +15,14 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Date; +import java.util.Map; + import org.springframework.social.github.api.GitHubFile; import org.springframework.social.github.api.GitHubGist; import org.springframework.social.github.api.GitHubUser; -import java.util.Date; -import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Annotated mixin to add annotations to {@link GitHubGist} @@ -30,21 +31,21 @@ */ abstract class GitHubGistMixin extends GitHubObjectMixin { - @JsonProperty("files") - Map files; + @JsonProperty("files") + Map files; - @JsonProperty("description") - String description; + @JsonProperty("description") + String description; - GitHubGistMixin( - @JsonProperty("id") String id, - @JsonProperty("url") String url, - @JsonProperty("public") boolean publicGist, - @JsonProperty("user") GitHubUser user, - @JsonProperty("comments") int comments, - @JsonProperty("html_url") String htmlUrl, - @JsonProperty("git_pull_url") String gitPullUrl, - @JsonProperty("git_push_url") String gitPushUrl, - @JsonProperty("created_at") Date createdAt, - @JsonProperty("updated_at") Date updatedAt) {} + GitHubGistMixin( + @JsonProperty("id") String id, + @JsonProperty("url") String url, + @JsonProperty("public") boolean publicGist, + @JsonProperty("user") GitHubUser user, + @JsonProperty("comments") int comments, + @JsonProperty("html_url") String htmlUrl, + @JsonProperty("git_pull_url") String gitPullUrl, + @JsonProperty("git_push_url") String gitPushUrl, + @JsonProperty("created_at") Date createdAt, + @JsonProperty("updated_at") Date updatedAt) {} } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubHookMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubHookMixin.java index f1d80a46..0bd24de5 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubHookMixin.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubHookMixin.java @@ -15,10 +15,11 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Date; + import org.springframework.social.github.api.GitHubHook; -import java.util.Date; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Annotated mixin to add annotations to {@link GitHubHook} @@ -27,13 +28,13 @@ */ abstract class GitHubHookMixin extends GitHubObjectMixin { - @JsonProperty("active") - boolean active; + @JsonProperty("active") + boolean active; - GitHubHookMixin( - @JsonProperty("id") long id, - @JsonProperty("name") String name, - @JsonProperty("url") String url, - @JsonProperty("created_at") Date createdAt, - @JsonProperty("updated_at") Date updatedAt) {} + GitHubHookMixin( + @JsonProperty("id") long id, + @JsonProperty("name") String name, + @JsonProperty("url") String url, + @JsonProperty("created_at") Date createdAt, + @JsonProperty("updated_at") Date updatedAt) {} } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubIssueMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubIssueMixin.java index 8847a759..f4d2872b 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubIssueMixin.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubIssueMixin.java @@ -15,11 +15,12 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Date; + import org.springframework.social.github.api.GitHubIssue; import org.springframework.social.github.api.GitHubUser; -import java.util.Date; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Annotated mixin to add annotations to {@link GitHubIssue} @@ -28,23 +29,23 @@ */ abstract class GitHubIssueMixin extends GitHubObjectMixin { - @JsonProperty("state") - String state; + @JsonProperty("state") + String state; - @JsonProperty("title") - String title; + @JsonProperty("title") + String title; - @JsonProperty("body") - String body; + @JsonProperty("body") + String body; - @JsonProperty("assignee") - GitHubUser assignee; + @JsonProperty("assignee") + GitHubUser assignee; - GitHubIssueMixin( - @JsonProperty("number") int number, - @JsonProperty("url") String url, - @JsonProperty("html_url") String htmlUrl, - @JsonProperty("closed_at") Date closedAt, - @JsonProperty("created_at") Date createdAt, - @JsonProperty("updated_at") Date updatedAt) {} + GitHubIssueMixin( + @JsonProperty("number") int number, + @JsonProperty("url") String url, + @JsonProperty("html_url") String htmlUrl, + @JsonProperty("closed_at") Date closedAt, + @JsonProperty("created_at") Date createdAt, + @JsonProperty("updated_at") Date updatedAt) {} } 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..801a003d 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,9 +15,18 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.databind.Module; +import org.springframework.social.github.api.GitHubComment; +import org.springframework.social.github.api.GitHubCommit; +import org.springframework.social.github.api.GitHubDownload; +import org.springframework.social.github.api.GitHubFile; +import org.springframework.social.github.api.GitHubGist; +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.GitHubUserProfile; + import com.fasterxml.jackson.databind.module.SimpleModule; -import org.springframework.social.github.api.*; /** * Jackson module for setting up mixin annotations on GitHub model types. @@ -26,21 +35,21 @@ */ public class GitHubModule extends SimpleModule { - public GitHubModule() { - super("GitHubModule"); - } + public GitHubModule() { + super("GitHubModule"); + } - @Override - public void setupModule(SetupContext context) { - context.setMixInAnnotations(GitHubComment.class, GitHubCommentMixin.class); - context.setMixInAnnotations(GitHubCommit.class, GitHubCommitMixin.class); - context.setMixInAnnotations(GitHubDownload.class, GitHubDownloadMixin.class); - context.setMixInAnnotations(GitHubFile.class, GitHubFileMixin.class); - context.setMixInAnnotations(GitHubGist.class, GitHubGistMixin.class); - context.setMixInAnnotations(GitHubHook.class, GitHubHookMixin.class); - context.setMixInAnnotations(GitHubIssue.class, GitHubIssueMixin.class); - context.setMixInAnnotations(GitHubRepo.class, GitHubRepoMixin.class); - context.setMixInAnnotations(GitHubUser.class, GitHubUserMixin.class); - context.setMixInAnnotations(GitHubUserProfile.class, GitHubUserProfileMixin.class); - } + @Override + public void setupModule(SetupContext context) { + context.setMixInAnnotations(GitHubComment.class, GitHubCommentMixin.class); + context.setMixInAnnotations(GitHubCommit.class, GitHubCommitMixin.class); + context.setMixInAnnotations(GitHubDownload.class, GitHubDownloadMixin.class); + context.setMixInAnnotations(GitHubFile.class, GitHubFileMixin.class); + context.setMixInAnnotations(GitHubGist.class, GitHubGistMixin.class); + context.setMixInAnnotations(GitHubHook.class, GitHubHookMixin.class); + context.setMixInAnnotations(GitHubIssue.class, GitHubIssueMixin.class); + context.setMixInAnnotations(GitHubRepo.class, GitHubRepoMixin.class); + context.setMixInAnnotations(GitHubUser.class, GitHubUserMixin.class); + context.setMixInAnnotations(GitHubUserProfile.class, GitHubUserProfileMixin.class); + } } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubRepoMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubRepoMixin.java index d2520abc..88891900 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubRepoMixin.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubRepoMixin.java @@ -15,9 +15,10 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.social.github.api.GitHubRepo; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * Annotated mixin to add annotations to {@link GitHubRepo} * @@ -25,18 +26,18 @@ */ public class GitHubRepoMixin extends GitHubObjectMixin { - @JsonProperty("name") - String name; + @JsonProperty("name") + String name; - @JsonProperty("description") - String description; + @JsonProperty("description") + String description; - GitHubRepoMixin( - @JsonProperty("id") long id, - @JsonProperty("url") String url, - @JsonProperty("html_url") String htmlUrl, - @JsonProperty("clone_url") String clone_url, - @JsonProperty("git_url") String gitUrl, - @JsonProperty("ssh_url") String sshUrl, - @JsonProperty("svn_url") String svnUrl) {} + GitHubRepoMixin( + @JsonProperty("id") long id, + @JsonProperty("url") String url, + @JsonProperty("html_url") String htmlUrl, + @JsonProperty("clone_url") String clone_url, + @JsonProperty("git_url") String gitUrl, + @JsonProperty("ssh_url") String sshUrl, + @JsonProperty("svn_url") String svnUrl) {} } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubUserMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubUserMixin.java index 654f5096..7b0d0809 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubUserMixin.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubUserMixin.java @@ -15,9 +15,10 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.social.github.api.GitHubUser; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * Annotated mixin to add annotations to {@link GitHubUser} * @@ -25,16 +26,16 @@ */ abstract class GitHubUserMixin extends GitHubObjectMixin { - String name; + String name; - String email; + String email; - String bio; + String bio; - GitHubUserMixin( - @JsonProperty("id") long id, - @JsonProperty("url") String url, - @JsonProperty("login") String login, - @JsonProperty("avatar_url") String avatarUrl, - @JsonProperty("gravatar_id") String gravatarId) {} + GitHubUserMixin( + @JsonProperty("id") long id, + @JsonProperty("url") String url, + @JsonProperty("login") String login, + @JsonProperty("avatar_url") String avatarUrl, + @JsonProperty("gravatar_id") String gravatarId) {} } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubUserProfileMixin.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubUserProfileMixin.java index ebdfe78d..404b714b 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubUserProfileMixin.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/json/GitHubUserProfileMixin.java @@ -15,36 +15,37 @@ */ package org.springframework.social.github.api.impl.json; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Date; + import org.springframework.social.github.api.GitHubUserProfile; -import java.util.Date; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Annotated mixin to add annotations to {@link GitHubUserProfile} * * @author Andy Wilkinson */ - abstract class GitHubUserProfileMixin extends GitHubObjectMixin { +abstract class GitHubUserProfileMixin extends GitHubObjectMixin { - @JsonProperty("name") - String name; + @JsonProperty("name") + String name; - @JsonProperty("location") - String location; + @JsonProperty("location") + String location; - @JsonProperty("company") - String company; + @JsonProperty("company") + String company; - @JsonProperty("blog") - String blog; + @JsonProperty("blog") + String blog; - @JsonProperty("email") - String email; + @JsonProperty("email") + String email; - GitHubUserProfileMixin( - @JsonProperty("id") long id, - @JsonProperty("login") String login, - @JsonProperty("avatar_url") String avatarUrl, - @JsonProperty("created_at") Date createdAt) {} + GitHubUserProfileMixin( + @JsonProperty("id") long id, + @JsonProperty("login") String login, + @JsonProperty("avatar_url") String avatarUrl, + @JsonProperty("created_at") Date createdAt) {} } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/config/xml/GitHubConfigBeanDefinitionParser.java b/spring-social-github/src/main/java/org/springframework/social/github/config/xml/GitHubConfigBeanDefinitionParser.java index 38f134e5..8f6a23b3 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/config/xml/GitHubConfigBeanDefinitionParser.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/config/xml/GitHubConfigBeanDefinitionParser.java @@ -41,12 +41,12 @@ class GitHubConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinit public GitHubConfigBeanDefinitionParser() { super(GitHubConnectionFactory.class, GitHubApiHelper.class); } - + @Override protected Class> getAuthenticationServiceClass() { return GitHubAuthenticationService.class; } - + @Override protected BeanDefinition getConnectionFactoryBeanDefinition(String appId, String appSecret, Map allAttributes) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(GitHubConnectionFactory.class).addConstructorArgValue(appId).addConstructorArgValue(appSecret); @@ -61,14 +61,14 @@ static class GitHubApiHelper implements ApiHelper { private GitHubApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) { this.usersConnectionRepository = usersConnectionRepository; - this.userIdSource = userIdSource; + this.userIdSource = userIdSource; } public GitHub getApi() { if (logger.isDebugEnabled()) { logger.debug("Getting API binding instance for GitHub"); } - + Connection connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(GitHub.class); if (logger.isDebugEnabled() && connection == null) { logger.debug("No current connection; Returning default GitHubTemplate instance."); @@ -79,5 +79,5 @@ public GitHub getApi() { private final static Log logger = LogFactory.getLog(GitHubApiHelper.class); } - + } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/config/xml/GitHubNamespaceHandler.java b/spring-social-github/src/main/java/org/springframework/social/github/config/xml/GitHubNamespaceHandler.java index a2349e57..10f28d72 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/config/xml/GitHubNamespaceHandler.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/config/xml/GitHubNamespaceHandler.java @@ -21,7 +21,7 @@ /** * {@link NamespaceHandler} for Spring Social GitHub - * + * * @author Craig Walls */ public class GitHubNamespaceHandler extends AbstractProviderConfigNamespaceHandler { diff --git a/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubAdapter.java b/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubAdapter.java index f9ea4fb6..434f5c48 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubAdapter.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubAdapter.java @@ -42,7 +42,7 @@ public boolean test(GitHub github) { public void setConnectionValues(GitHub github, ConnectionValues values) { GitHubUserProfile profile = github.userOperations().getUserProfile(); - values.setProviderUserId(String.valueOf(profile.getId())); + values.setProviderUserId(String.valueOf(profile.getId())); values.setDisplayName(profile.getLogin()); values.setProfileUrl("https://github.com/" + profile.getLogin()); // TODO: Expose and use HTML URL values.setImageUrl(profile.getAvatarUrl()); @@ -52,9 +52,9 @@ public UserProfile fetchUserProfile(GitHub github) { GitHubUserProfile profile = github.userOperations().getUserProfile(); return new UserProfileBuilder().setName(profile.getName()).setEmail(profile.getEmail()).setUsername(profile.getLogin()).build(); } - + public void updateStatus(GitHub github, String message) { // not supported } - + } diff --git a/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubConnectionFactory.java b/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubConnectionFactory.java index fd53b722..0b27901b 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubConnectionFactory.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubConnectionFactory.java @@ -26,7 +26,7 @@ public class GitHubConnectionFactory extends OAuth2ConnectionFactory { /** * Creates a factory for GitHub connections. - * + * * @param clientId client ID * @param clientSecret client secret */ diff --git a/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubServiceProvider.java b/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubServiceProvider.java index ba6ca04e..ef05b110 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubServiceProvider.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/connect/GitHubServiceProvider.java @@ -38,6 +38,6 @@ private static OAuth2Template createOAuth2Template(String clientId, String clien public GitHub getApi(String accessToken) { return new GitHubTemplate(accessToken); - } + } } From 67b00d43b8c49546188bd868afc7f04c253dcc45 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 11 Mar 2015 14:44:53 -0400 Subject: [PATCH 2/2] Don't serialize empty items Update Jackson configuration to ensure that null values are not serialized. Fixes gh-23 --- .../springframework/social/github/api/impl/GitHubTemplate.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GitHubTemplate.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GitHubTemplate.java index b1e0a862..b7b8ce12 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GitHubTemplate.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/GitHubTemplate.java @@ -25,6 +25,7 @@ import org.springframework.social.oauth2.OAuth2Version; import org.springframework.web.client.RestOperations; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.ObjectMapper; /** @@ -89,6 +90,7 @@ public RestOperations restOperations() { protected MappingJackson2HttpMessageConverter getJsonMessageConverter() { MappingJackson2HttpMessageConverter converter = super.getJsonMessageConverter(); ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(Include.NON_EMPTY); objectMapper.registerModule(new GitHubModule()); converter.setObjectMapper(objectMapper); return converter;