Class PostClient
- Author:
- Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it), Ahmed Ibrahim at ISTI-CNR (ahmed.ibrahim@isti.cnr.it)
-
Field Summary
Fields inherited from class org.gcube.social_networking.social_networking_client_library.BaseClient
SG3_BRIDGE_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAttachment(String postId, org.gcube.portal.databook.shared.Attachment attachment) Add an attachment to an existing post.deletePost(String postId) Delete a post by id.org.gcube.portal.databook.shared.PostEdit the text of an existing post.List<org.gcube.portal.databook.shared.Post>Get posts application (token set must belong to the application)List<org.gcube.portal.databook.shared.Post>Get all postsList<org.gcube.portal.databook.shared.Attachment>getAttachments(String postId) Retrieve additional attachments of a post by id.List<org.gcube.portal.databook.shared.Post>getHashtagPosts(String hashtag) Get posts hashtagList<org.gcube.portal.databook.shared.Post>Retrieve portal-wide posts with default quantity (20).List<org.gcube.portal.databook.shared.Post>getPortalPosts(int quantity) Retrieve portal-wide posts up to a maximum quantity.List<org.gcube.portal.databook.shared.Post>getPortalTimeline(int quantity) Alias ofgetPortalPosts(int)for portal timeline callers.org.gcube.portal.databook.shared.PostRetrieve a post by id.List<org.gcube.portal.databook.shared.Feed>Deprecated.org.gcube.portal.databook.shared.RangePostsgetRecentVREPostsByRange(int from, int quantity) Retrieve recent posts for the VRE context by range.List<org.gcube.portal.databook.shared.Post>Retrieve the aggregated timeline with default quantity (20).List<org.gcube.portal.databook.shared.Post>getTimeline(int quantity) Retrieve the aggregated timeline across the caller's VREs plus portal-wide posts up to a maximum quantity.List<org.gcube.portal.databook.shared.Post>getUserCommentedPostsSince(long since) Retrieve posts commented by the calling user since a reference timestamp.List<org.gcube.portal.databook.shared.Post>getUserCommentedPostsSince(String username, long since) Retrieve posts commented by a user since a given timestamp, restricted to posts visible in the caller's token context.List<org.gcube.portal.databook.shared.Post>Get liked postsGet liked posts idsList<org.gcube.portal.databook.shared.Post>getUserLikedPostsSince(long since) Retrieve posts liked by the calling user since a given timestamp.List<org.gcube.portal.databook.shared.Post>getUserLikedPostsSince(String username, long since) Retrieve posts liked by a user since a given timestamp, restricted to posts visible in the caller's token context.List<org.gcube.portal.databook.shared.Post>getUserPostsQuantity(int quantity) Get posts quantityList<org.gcube.portal.databook.shared.Post>getUserPostsQuantity(String username, int quantity) Get recent posts of a user up toquantity, visible in the token's context.List<org.gcube.portal.databook.shared.Post>getUserPostsSince(long since) Retrieve posts of the calling user since a reference timestamp.List<org.gcube.portal.databook.shared.Post>getUserPostsSince(String username, long since) Retrieve posts of a user since a reference timestamp, visible in the token's context.List<org.gcube.portal.databook.shared.Post>getUserPostsSinceDate(long timeInMillis) Get posts since dateList<org.gcube.portal.databook.shared.Post>getUserPostsSinceDate(String username, long since) Retrieve posts of a user since a reference timestamp, visible in the token's context.getUserPostStats(long since) Retrieve activity statistics for the calling user since a reference timestamp.getUserPostStats(String username, long since) Retrieve user activity statistics (posts, liked posts, commented posts) since a reference timestamp in milliseconds, filtered by the token's context.List<org.gcube.portal.databook.shared.Post>Get posts vreorg.gcube.portal.databook.shared.PostwriteApplicationPost(org.gcube.social_networking.socialnetworking.model.beans.PostInputBean toWrite) Write post application (token set must belong to the application)org.gcube.portal.databook.shared.PostwriteUserPost(String text, List<org.gcube.portal.databook.shared.Attachment> attachments) Write a simple user post with text and attachments.org.gcube.portal.databook.shared.PostwriteUserPost(org.gcube.social_networking.socialnetworking.model.beans.PostInputBean toWrite) Write postorg.gcube.portal.databook.shared.PostwriteUserPost(org.gcube.social_networking.socialnetworking.model.beans.PostInputBean toWrite, List<org.gcube.portal.databook.shared.Attachment> attachments) Write a user post with attachments.Methods inherited from class org.gcube.social_networking.social_networking_client_library.BaseClient
getServiceEndpoint
-
Constructor Details
-
PostClient
- Throws:
Exception
-
-
Method Details
-
getUserPostsSinceDate
Get posts since date- Returns:
-
getAllUserPosts
Get all posts- Returns:
-
getUserPostsQuantity
Get posts quantity- Returns:
-
getUserPostsQuantity
public List<org.gcube.portal.databook.shared.Post> getUserPostsQuantity(String username, int quantity) Get recent posts of a user up toquantity, visible in the token's context.- Parameters:
username- target username, or null for the calling userquantity- maximum number of posts to return (non-negative)- Returns:
- list of posts visible in the token's context
-
writeUserPost
public org.gcube.portal.databook.shared.Post writeUserPost(org.gcube.social_networking.socialnetworking.model.beans.PostInputBean toWrite) Write post- Returns:
-
getAllApplicationPosts
Get posts application (token set must belong to the application)- Returns:
-
writeApplicationPost
public org.gcube.portal.databook.shared.Post writeApplicationPost(org.gcube.social_networking.socialnetworking.model.beans.PostInputBean toWrite) Write post application (token set must belong to the application)- Returns:
-
getPostsVRE
Deprecated.UsegetVREPosts()instead. Get posts vre- Returns:
-
getVREPosts
Get posts vre- Returns:
-
getPost
Retrieve a post by id.Endpoint:
GET 2/posts/get-post?id={postId}Identity semantics: acts as the token's caller (the user or application owning the token in context). Sensitive information is hidden for the caller; access is restricted to posts belonging to the token's context.
- Parameters:
postId- the identifier of the post to retrieve- Returns:
- the post matching the given id in the token's context
-
getRecentVREPostsByRange
public org.gcube.portal.databook.shared.RangePosts getRecentVREPostsByRange(int from, int quantity) Retrieve recent posts for the VRE context by range.Endpoint:
GET 2/posts/get-recent-posts-vre-by-range?from={from}&quantity={quantity}Identity semantics: acts as the token's caller (the user or application owning the token in context). Sensitive information is hidden for the caller; the VRE context is determined by the token's context.
- Parameters:
from- the 1-based start index (greater than or equal to 1)quantity- the number of recent posts to retrieve (greater than or equal to 0)- Returns:
- a
RangePostsobject containing the posts and total count
-
getHashtagPosts
public List<org.gcube.portal.databook.shared.Post> getHashtagPosts(String hashtag) throws UnsupportedEncodingException Get posts hashtag- Returns:
- Throws:
UnsupportedEncodingException
-
getUserLikedPost
Get liked posts- Returns:
-
getUserLikedPostIds
Get liked posts ids- Returns:
-
getUserPostsSince
Retrieve posts of a user since a reference timestamp, visible in the token's context.Endpoint:
GET 2/posts/get-posts-user-since?since={since}&username={username}Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; target user defaults to the caller if null or empty. Sensitive information is hidden for the caller.
- Parameters:
username- target username, or null for the calling usersince- reference timestamp in milliseconds (non-negative)- Returns:
- list of posts visible in the token's context
-
getUserPostsSince
Retrieve posts of the calling user since a reference timestamp.Endpoint:
GET 2/posts/get-posts-user-since?since={since}- Parameters:
since- reference timestamp in milliseconds (non-negative)- Returns:
- list of posts visible in the token's context
-
getUserPostsSinceDate
public List<org.gcube.portal.databook.shared.Post> getUserPostsSinceDate(String username, long since) Retrieve posts of a user since a reference timestamp, visible in the token's context.- Parameters:
username- target username, or null for the calling usersince- reference timestamp in milliseconds (non-negative)- Returns:
- list of posts visible in the token's context
-
writeUserPost
public org.gcube.portal.databook.shared.Post writeUserPost(org.gcube.social_networking.socialnetworking.model.beans.PostInputBean toWrite, List<org.gcube.portal.databook.shared.Attachment> attachments) Write a user post with attachments.Endpoint:
POST 2/posts/write-post-userIdentity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; writes a post authored by the caller in the token's context and associates any provided attachments.
- Parameters:
toWrite- the post input metadataattachments- the list ofAttachmentobjects to associate with the post- Returns:
- the created
Post
-
writeUserPost
public org.gcube.portal.databook.shared.Post writeUserPost(String text, List<org.gcube.portal.databook.shared.Attachment> attachments) Write a simple user post with text and attachments.Endpoint:
POST 2/posts/write-post-user- Parameters:
text- the post textattachments- the list ofAttachmentobjects- Returns:
- the created
Post
-
deletePost
Delete a post by id.Endpoint:
POST 2/posts/delete-post?id={postId}Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; caller must be either the author of the post or a VRE-Manager of the post's context. Associated comments and hashtags are also cleaned up server-side.
- Parameters:
postId- the identifier of the post to delete- Returns:
- true when the post has been deleted
-
editPost
Edit the text of an existing post.- Parameters:
postId- the identifier of the post to edittext- the updated text- Returns:
- the updated
Post
-
getPortalPosts
Retrieve portal-wide posts up to a maximum quantity.Endpoint:
GET 2/posts/get-portal-posts?quantity={quantity}Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; returns posts with portal or public privacy level in reverse chronological order. Sensitive information is hidden for the caller.
- Parameters:
quantity- maximum number of portal-level posts to return- Returns:
- portal-wide posts in reverse chronological order
-
getPortalPosts
Retrieve portal-wide posts with default quantity (20).Endpoint:
GET 2/posts/get-portal-posts?quantity=20- Returns:
- portal-wide posts in reverse chronological order
-
getPortalTimeline
Alias ofgetPortalPosts(int)for portal timeline callers.- Parameters:
quantity- maximum number of portal-level posts to return- Returns:
- portal-wide posts in reverse chronological order
-
getAttachments
Retrieve additional attachments of a post by id.Endpoint:
GET 2/posts/get-attachments?id={postId}Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; access is restricted to posts belonging to the caller's context (or portal/public). Sensitive information is hidden.
- Parameters:
postId- the identifier of the post- Returns:
- list of
Attachmentassociated with the post
-
getTimeline
Retrieve the aggregated timeline across the caller's VREs plus portal-wide posts up to a maximum quantity.Endpoint:
GET 2/posts/get-timeline?quantity={quantity}Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; merges timeline posts across the caller's VRE memberships and portal-wide feeds in reverse chronological order. Sensitive information is hidden for the caller.
- Parameters:
quantity- maximum number of timeline posts to return- Returns:
- aggregated timeline posts for the caller
-
getTimeline
Retrieve the aggregated timeline with default quantity (20).Endpoint:
GET 2/posts/get-timeline?quantity=20- Returns:
- aggregated timeline posts for the caller
-
getUserPostStats
public Map<String,List<org.gcube.portal.databook.shared.Post>> getUserPostStats(String username, long since) Retrieve user activity statistics (posts, liked posts, commented posts) since a reference timestamp in milliseconds, filtered by the token's context.Endpoint:
GET 2/posts/get-posts-user-stats?since={since}&username={username}Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; target username defaults to the caller if null or empty. All retrieved posts are filtered by the token context.
- Parameters:
username- target username, or null to query for the callersince- reference timestamp in milliseconds (non-negative)- Returns:
- map containing keys
posts,likedPosts, andcommentedPosts
-
getUserPostStats
Retrieve activity statistics for the calling user since a reference timestamp.Endpoint:
GET 2/posts/get-posts-user-stats?since={since}- Parameters:
since- reference timestamp in milliseconds (non-negative)- Returns:
- map containing keys
posts,likedPosts, andcommentedPosts
-
getUserLikedPostsSince
public List<org.gcube.portal.databook.shared.Post> getUserLikedPostsSince(String username, long since) Retrieve posts liked by a user since a given timestamp, restricted to posts visible in the caller's token context.Endpoint:
GET 2/posts/get-posts-user-liked-since?since={since}&username={username}Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; target username defaults to caller if null or empty.
- Parameters:
username- target username, or null for the callersince- reference timestamp in milliseconds (non-negative)- Returns:
- list of liked posts visible in the token's context
-
getUserLikedPostsSince
Retrieve posts liked by the calling user since a given timestamp.Endpoint:
GET 2/posts/get-posts-user-liked-since?since={since}- Parameters:
since- reference timestamp in milliseconds (non-negative)- Returns:
- list of liked posts visible in the token's context
-
getUserCommentedPostsSince
public List<org.gcube.portal.databook.shared.Post> getUserCommentedPostsSince(String username, long since) Retrieve posts commented by a user since a given timestamp, restricted to posts visible in the caller's token context.Endpoint:
GET 2/posts/get-posts-user-commented-since?since={since}&username={username}Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; target username defaults to caller if null or empty.
- Parameters:
username- target username, or null for the callersince- reference timestamp in milliseconds (non-negative)- Returns:
- list of commented posts visible in the token's context
-
getUserCommentedPostsSince
Retrieve posts commented by the calling user since a reference timestamp.Endpoint:
GET 2/posts/get-posts-user-commented-since?since={since}- Parameters:
since- reference timestamp in milliseconds (non-negative)- Returns:
- list of commented posts visible in the token's context
-
getVREPosts()instead.