java.lang.Object
org.gcube.social_networking.social_networking_client_library.BaseClient
org.gcube.social_networking.social_networking_client_library.PostClient

public class PostClient extends BaseClient
Posts client.
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    addAttachment(String postId, org.gcube.portal.databook.shared.Attachment attachment)
    Add an attachment to an existing post.
    Delete a post by id.
    org.gcube.portal.databook.shared.Post
    editPost(String postId, String text)
    Edit 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 posts
    List<org.gcube.portal.databook.shared.Attachment>
    Retrieve additional attachments of a post by id.
    List<org.gcube.portal.databook.shared.Post>
    Get posts hashtag
    List<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 of getPortalPosts(int) for portal timeline callers.
    org.gcube.portal.databook.shared.Post
    getPost(String postId)
    Retrieve a post by id.
    List<org.gcube.portal.databook.shared.Feed>
    Deprecated.
    Use getVREPosts() instead.
    org.gcube.portal.databook.shared.RangePosts
    getRecentVREPostsByRange(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>
    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 posts
    Get liked posts ids
    List<org.gcube.portal.databook.shared.Post>
    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 quantity
    List<org.gcube.portal.databook.shared.Post>
    getUserPostsQuantity(String username, int quantity)
    Get recent posts of a user up to quantity, 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 date
    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.
    Map<String,List<org.gcube.portal.databook.shared.Post>>
    getUserPostStats(long since)
    Retrieve activity statistics for the calling user since a reference timestamp.
    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.
    List<org.gcube.portal.databook.shared.Post>
    Get posts vre
    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)
    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.
    org.gcube.portal.databook.shared.Post
    writeUserPost(org.gcube.social_networking.socialnetworking.model.beans.PostInputBean toWrite)
    Write post
    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.

    Methods inherited from class org.gcube.social_networking.social_networking_client_library.BaseClient

    getServiceEndpoint

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getUserPostsSinceDate

      public List<org.gcube.portal.databook.shared.Post> getUserPostsSinceDate(long timeInMillis)
      Get posts since date
      Returns:
    • getAllUserPosts

      public List<org.gcube.portal.databook.shared.Post> getAllUserPosts()
      Get all posts
      Returns:
    • getUserPostsQuantity

      public List<org.gcube.portal.databook.shared.Post> getUserPostsQuantity(int quantity)
      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 to quantity, visible in the token's context.
      Parameters:
      username - target username, or null for the calling user
      quantity - 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

      public List<org.gcube.portal.databook.shared.Post> 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

      public List<org.gcube.portal.databook.shared.Feed> getPostsVRE()
      Deprecated.
      Use getVREPosts() instead. Get posts vre
      Returns:
    • getVREPosts

      public List<org.gcube.portal.databook.shared.Post> getVREPosts()
      Get posts vre
      Returns:
    • getPost

      public org.gcube.portal.databook.shared.Post getPost(String postId)
      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 RangePosts object 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

      public List<org.gcube.portal.databook.shared.Post> getUserLikedPost()
      Get liked posts
      Returns:
    • getUserLikedPostIds

      public List<String> getUserLikedPostIds()
      Get liked posts ids
      Returns:
    • getUserPostsSince

      public 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.

      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 user
      since - reference timestamp in milliseconds (non-negative)
      Returns:
      list of posts visible in the token's context
    • getUserPostsSince

      public List<org.gcube.portal.databook.shared.Post> getUserPostsSince(long since)
      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 user
      since - 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-user

      Identity 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 metadata
      attachments - the list of Attachment objects 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 text
      attachments - the list of Attachment objects
      Returns:
      the created Post
    • deletePost

      public Boolean deletePost(String postId)
      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

      public org.gcube.portal.databook.shared.Post editPost(String postId, String text)
      Edit the text of an existing post.
      Parameters:
      postId - the identifier of the post to edit
      text - the updated text
      Returns:
      the updated Post
    • getPortalPosts

      public List<org.gcube.portal.databook.shared.Post> getPortalPosts(int quantity)
      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

      public List<org.gcube.portal.databook.shared.Post> 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

      public List<org.gcube.portal.databook.shared.Post> getPortalTimeline(int quantity)
      Alias of getPortalPosts(int) for portal timeline callers.
      Parameters:
      quantity - maximum number of portal-level posts to return
      Returns:
      portal-wide posts in reverse chronological order
    • getAttachments

      public List<org.gcube.portal.databook.shared.Attachment> getAttachments(String postId)
      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 Attachment associated with the post
    • addAttachment

      public Boolean addAttachment(String postId, org.gcube.portal.databook.shared.Attachment attachment)
      Add an attachment to an existing post.
      Parameters:
      postId - the identifier of the post
      attachment - the Attachment to add
      Returns:
      true when saved
    • getTimeline

      public 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.

      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

      public List<org.gcube.portal.databook.shared.Post> 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 caller
      since - reference timestamp in milliseconds (non-negative)
      Returns:
      map containing keys posts, likedPosts, and commentedPosts
    • getUserPostStats

      public Map<String,List<org.gcube.portal.databook.shared.Post>> getUserPostStats(long since)
      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, and commentedPosts
    • 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 caller
      since - reference timestamp in milliseconds (non-negative)
      Returns:
      list of liked posts visible in the token's context
    • getUserLikedPostsSince

      public List<org.gcube.portal.databook.shared.Post> getUserLikedPostsSince(long since)
      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 caller
      since - reference timestamp in milliseconds (non-negative)
      Returns:
      list of commented posts visible in the token's context
    • getUserCommentedPostsSince

      public List<org.gcube.portal.databook.shared.Post> getUserCommentedPostsSince(long since)
      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