Permalink
Browse files

added response envelope and other migrations to all operations

  • Loading branch information...
arikg committed Sep 2, 2012
1 parent ba09f99 commit 1d6452724d66c75bffae2a6173c20eaf02b80cd5
Showing with 630 additions and 129 deletions.
  1. +51 −17 src/main/java/org/springframework/social/appdotnet/api/PostsOperations.java
  2. +4 −41 src/main/java/org/springframework/social/appdotnet/api/UsersOperations.java
  3. +43 −0 src/main/java/org/springframework/social/appdotnet/api/data/ADNPaging.java
  4. +25 −0 src/main/java/org/springframework/social/appdotnet/api/data/ADNResponse.java
  5. +67 −0 src/main/java/org/springframework/social/appdotnet/api/data/ADNResponseMeta.java
  6. +36 −0 src/main/java/org/springframework/social/appdotnet/api/data/post/ADNPosts.java
  7. +0 −11 src/main/java/org/springframework/social/appdotnet/api/data/post/ADNPostsList.java
  8. +37 −0 src/main/java/org/springframework/social/appdotnet/api/data/user/ADNUsers.java
  9. +0 −11 src/main/java/org/springframework/social/appdotnet/api/data/user/ADNUsersList.java
  10. +18 −2 src/main/java/org/springframework/social/appdotnet/api/impl/AbstractAppdotnetOperations.java
  11. +25 −0 src/main/java/org/springframework/social/appdotnet/api/impl/AppdotnetRequestInterceptor.java
  12. +7 −1 src/main/java/org/springframework/social/appdotnet/api/impl/AppdotnetTemplate.java
  13. +12 −0 src/main/java/org/springframework/social/appdotnet/api/impl/PostResponse.java
  14. +14 −0 src/main/java/org/springframework/social/appdotnet/api/impl/PostsResponse.java
  15. +49 −15 src/main/java/org/springframework/social/appdotnet/api/impl/PostsTemplate.java
  16. +12 −0 src/main/java/org/springframework/social/appdotnet/api/impl/TokenResponse.java
  17. +2 −1 src/main/java/org/springframework/social/appdotnet/api/impl/TokensTemplate.java
  18. +12 −0 src/main/java/org/springframework/social/appdotnet/api/impl/UserResponse.java
  19. +14 −0 src/main/java/org/springframework/social/appdotnet/api/impl/UsersResponse.java
  20. +16 −29 src/main/java/org/springframework/social/appdotnet/api/impl/UsersTemplate.java
  21. +98 −0 src/main/java/org/springframework/social/appdotnet/api/impl/error/AppdotnetErrorHandler.java
  22. +38 −0 src/main/java/org/springframework/social/appdotnet/api/impl/error/AppdotnetErrorMeta.java
  23. +16 −0 src/main/java/org/springframework/social/appdotnet/api/impl/error/AppdotnetErrorResponse.java
  24. +1 −1 src/main/java/org/springframework/social/appdotnet/api/impl/json/ADNLinkMixin.java
  25. +33 −0 src/test/java/org/springframework/social/appdotnet/connect/AppdotnetAdapterTest.java
@@ -1,8 +1,8 @@
package org.springframework.social.appdotnet.api;
import org.springframework.social.appdotnet.api.data.post.ADNPost;
+import org.springframework.social.appdotnet.api.data.post.ADNPosts;
-import java.util.List;
import java.util.Map;
/**
@@ -39,60 +39,94 @@
/**
* Retrieve the latest posts from the user personal stream (this includes only posts from users he is following)
*
- * @return List of Post objects
+ * @return A Posts object containing a list of posts and extra data
*/
- public List<ADNPost> getPersonalStream();
+ public ADNPosts getPersonalStream();
/**
* Retrieve the latest posts from the user personal stream (this includes only posts from users he is following)
*
* @param extraParams extra parameters to modify the query, best used with {@link GeneralParametersBuilder}
- * @return List of Post objects
+ * @return A Posts object containing a list of posts and extra data
*/
- public List<ADNPost> getPersonalStream(Map<String, String> extraParams);
+ public ADNPosts getPersonalStream(Map<String, String> extraParams);
/**
* Retrieve the latest posts from the global stream
*
- * @return List of Post objects
+ * @return A Posts object containing a list of posts and extra data
*/
- public List<ADNPost> getGlobalStream();
+ public ADNPosts getGlobalStream();
/**
* Retrieve the latest posts from the global stream
*
* @param extraParams extra parameters to modify the query, best used with {@link GeneralParametersBuilder}
- * @return List of Post objects
+ * @return A Posts object containing a list of posts and extra data
*/
- public List<ADNPost> getGlobalStream(Map<String, String> extraParams);
+ public ADNPosts getGlobalStream(Map<String, String> extraParams);
/**
* Retrieve the latest posts that contain the specified hashtag
*
- * @return List of Post objects
+ * @return A Posts object containing a list of posts and extra data
*/
- public List<ADNPost> getHashtagStream(String hashtag);
+ public ADNPosts getHashtagStream(String hashtag);
/**
* Retrieve the latest posts that contain the specified hashtag
*
* @param extraParams extra parameters to modify the query, best used with {@link GeneralParametersBuilder}
- * @return List of Post objects
+ * @return A Posts object containing a list of posts and extra data
*/
- public List<ADNPost> getHashtagStream(String hashtag, Map<String, String> extraParams);
+ public ADNPosts getHashtagStream(String hashtag, Map<String, String> extraParams);
/**
* Retrieve all posts that are in the stream of replies to a specified post
*
- * @return List of Post objects
+ * @return A Posts object containing a list of posts and extra data
*/
- public List<ADNPost> getPostReplies(String id);
+ public ADNPosts getPostReplies(String id);
/**
* Retrieve all posts that are in the stream of replies to a specified post
*
* @param extraParams extra parameters to modify the query, best used with {@link GeneralParametersBuilder}
- * @return List of Post objects
+ * @return A Posts object containing a list of posts and extra data
*/
- public List<ADNPost> getPostReplies(String id, Map<String, String> extraParams);
+ public ADNPosts getPostReplies(String id, Map<String, String> extraParams);
+
+ /**
+ * Retrieve all posts created by the specified user
+ *
+ * @param userId App.net user ID of the user whose posts you wish to retrieve
+ * @return A Posts object containing a list of posts and extra data
+ */
+ public ADNPosts getUserPosts(String userId);
+
+ /**
+ * Retrieve all posts created by the specified user
+ *
+ * @param userId App.net user ID of the user whose posts you wish to retrieve
+ * @param extraParams extra parameters to modify the query, best used with {@link GeneralParametersBuilder}
+ * @return A Posts object containing a list of posts and extra data
+ */
+ public ADNPosts getUserPosts(String userId, Map<String, String> extraParams);
+
+ /**
+ * Retrieve all posts that the specified user was mentioned in
+ *
+ * @param userId App.net user ID of the user whose mentions you wish to retrieve
+ * @return A Posts object containing a list of posts and extra data
+ */
+ public ADNPosts getUserMentions(String userId);
+
+ /**
+ * Retrieve all posts that the specified user was mentioned in
+ *
+ * @param userId userId App.net user ID of the user whose mentions you wish to retrieve
+ * @param extraParams extra parameters to modify the query, best used with {@link GeneralParametersBuilder}
+ * @return A Posts object containing a list of posts and extra data
+ */
+ public ADNPosts getUserMentions(String userId, Map<String, String> extraParams);
}
@@ -1,10 +1,7 @@
package org.springframework.social.appdotnet.api;
-import org.springframework.social.appdotnet.api.data.post.ADNPost;
import org.springframework.social.appdotnet.api.data.user.ADNUser;
-
-import java.util.List;
-import java.util.Map;
+import org.springframework.social.appdotnet.api.data.user.ADNUsers;
/**
* Interface defining the operations for retrieving information about App.net users.
@@ -48,15 +45,15 @@
* @param id App.net id of the user you wish to get followers of
* @return a List of {@link ADNUser} objects representing all the user's followers
*/
- public List<ADNUser> getFollowers(String id);
+ public ADNUsers getFollowers(String id);
/**
* Get all the users that the specified user is following
*
* @param id App.net id of the user you wish to get a following list of
* @return a List of {@link ADNUser} objects representing all the users that the specified user is following
*/
- public List<ADNUser> getFollowing(String id);
+ public ADNUsers getFollowing(String id);
/**
* Mute the user who's ID was specified
@@ -79,40 +76,6 @@
*
* @return a List of {@link ADNUser} objects representing all the users that the logged in user muted
*/
- public List<ADNUser> getMutedUsers();
-
- /**
- * Retrieve all posts created by the specified user
- *
- * @param userId App.net user ID of the user whose posts you wish to retrieve
- * @return a List of {@link ADNPost} objects all created by the user specified (without the user in the)
- */
- public List<ADNPost> getPosts(String userId);
-
- /**
- * Retrieve all posts created by the specified user
- *
- * @param userId App.net user ID of the user whose posts you wish to retrieve
- * @param extraParams extra parameters to modify the query, best used with {@link GeneralParametersBuilder}
- * @return a List of {@link ADNPost} objects all created by the user specified (without the user in the)
- */
- public List<ADNPost> getPosts(String userId, Map<String, String> extraParams);
-
- /**
- * Retrieve all posts that the specified user was mentioned in
- *
- * @param userId App.net user ID of the user whose mentions you wish to retrieve
- * @return a List of {@link ADNPost} objects in which the user is mentioned
- */
- public List<ADNPost> getMentions(String userId);
-
- /**
- * Retrieve all posts that the specified user was mentioned in
- *
- * @param userId userId App.net user ID of the user whose mentions you wish to retrieve
- * @param extraParams extra parameters to modify the query, best used with {@link GeneralParametersBuilder}
- * @return a List of {@link ADNPost} objects in which the user is mentioned
- */
- public List<ADNPost> getMentions(String userId, Map<String, String> extraParams);
+ public ADNUsers getMutedUsers();
}
@@ -0,0 +1,43 @@
+package org.springframework.social.appdotnet.api.data;
+
+/**
+ * @author Arik Galansky
+ */
+public class ADNPaging {
+ private String minId;
+ private String maxId;
+ private Boolean more;
+
+ public ADNPaging() {
+ }
+
+ public ADNPaging(String minId, String maxId, Boolean more) {
+ this.minId = minId;
+ this.maxId = maxId;
+ this.more = more;
+ }
+
+ public String getMinId() {
+ return minId;
+ }
+
+ public void setMinId(String minId) {
+ this.minId = minId;
+ }
+
+ public String getMaxId() {
+ return maxId;
+ }
+
+ public void setMaxId(String maxId) {
+ this.maxId = maxId;
+ }
+
+ public Boolean hasMore() {
+ return more;
+ }
+
+ public void setMore(Boolean more) {
+ this.more = more;
+ }
+}
@@ -0,0 +1,25 @@
+package org.springframework.social.appdotnet.api.data;
+
+/**
+ * @author Arik Galansky
+ */
+public class ADNResponse<T> {
+ private T data;
+ private ADNResponseMeta meta;
+
+ public T getData() {
+ return data;
+ }
+
+ public void setData(T data) {
+ this.data = data;
+ }
+
+ public ADNResponseMeta getMeta() {
+ return meta;
+ }
+
+ public void setMeta(ADNResponseMeta meta) {
+ this.meta = meta;
+ }
+}
@@ -0,0 +1,67 @@
+package org.springframework.social.appdotnet.api.data;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+
+/**
+ * @author Arik Galansky
+ */
+// TODO Arikg: remove setters
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ADNResponseMeta {
+ private String max_id;
+ private String min_id;
+ private Boolean more;
+ private String code;
+ private String error_message;
+ private String error_slug;
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getError_message() {
+ return error_message;
+ }
+
+ public void setError_message(String error_message) {
+ this.error_message = error_message;
+ }
+
+ public String getError_slug() {
+ return error_slug;
+ }
+
+ public void setError_slug(String error_slug) {
+ this.error_slug = error_slug;
+ }
+
+ public String getMax_id() {
+ return max_id;
+ }
+
+ public void setMax_id(String max_id) {
+ this.max_id = max_id;
+ }
+
+ public String getMin_id() {
+ return min_id;
+ }
+
+ public void setMin_id(String min_id) {
+ this.min_id = min_id;
+ }
+
+ public Boolean getMore() {
+ return more;
+ }
+
+ public void setMore(Boolean more) {
+ this.more = more;
+ }
+
+
+}
@@ -0,0 +1,36 @@
+package org.springframework.social.appdotnet.api.data.post;
+
+import org.springframework.social.appdotnet.api.data.ADNPaging;
+
+import java.util.List;
+
+/**
+ * A class extending a generic list of posts with extra paging data
+ *
+ * @author Arik Galansky
+ */
+public class ADNPosts {
+ private List<ADNPost> posts;
+ private ADNPaging paging;
+
+ public ADNPosts(List<ADNPost> posts, ADNPaging paging) {
+ this.posts = posts;
+ this.paging = paging;
+ }
+
+ public List<ADNPost> getPosts() {
+ return posts;
+ }
+
+ public void setPosts(List<ADNPost> posts) {
+ this.posts = posts;
+ }
+
+ public ADNPaging getPaging() {
+ return paging;
+ }
+
+ public void setPaging(ADNPaging paging) {
+ this.paging = paging;
+ }
+}
@@ -1,11 +0,0 @@
-package org.springframework.social.appdotnet.api.data.post;
-
-import java.util.ArrayList;
-
-/**
- * A class extending a generic list of posts to use when a Class object is needed
- *
- * @author Arik Galansky
- */
-public class ADNPostsList extends ArrayList<ADNPost> {
-}
Oops, something went wrong.

0 comments on commit 1d64527

Please sign in to comment.