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

public class NotificationClient extends BaseClient
Notifications 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
    Check whether the token's owner has unread notifications or unread message notifications.
    List<org.gcube.portal.databook.shared.Notification>
    getNotifications(int from, int quantity)
    Get range notifications
    org.gcube.portal.databook.shared.NotificationPreferences
    Retrieve the notification preferences of the token's owner.
    List<org.gcube.portal.databook.shared.Notification>
    Retrieve unread notifications of the token's owner (excluding messages).
    notifyUsers(org.gcube.portal.databook.shared.NotificationInputBean input)
    Send a notification to one or more users belonging to the caller token's context.
    void
    sendCatalogueEvent(org.gcube.social_networking.socialnetworking.model.beans.catalogue.CatalogueEvent event)
    Notify a catalogue event, types availeble see CatalogueEventType
    void
    sendJobNotification(org.gcube.social_networking.socialnetworking.model.beans.JobNotificationBean notification)
    Notify job status
    void
    sendWorkspaceEvent(org.gcube.social_networking.socialnetworking.model.beans.workspace.WorkspaceEvent event)
    Notify a catalogue event, types available see WorkspaceEventType
    Mark all unread notifications of the token's owner as read.
    Mark a single notification as read if and only if it belongs to the token's owner.
    org.gcube.portal.databook.shared.NotificationPreferences
    setPreferences(org.gcube.portal.databook.shared.NotificationPreferences preferences)
    Update the notification preferences of the token's owner.

    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

    • getNotifications

      public List<org.gcube.portal.databook.shared.Notification> getNotifications(int from, int quantity)
      Get range notifications
      Parameters:
      from - greater or equal to one
      quantity -
      Returns:
    • sendJobNotification

      public void sendJobNotification(org.gcube.social_networking.socialnetworking.model.beans.JobNotificationBean notification)
      Notify job status
      Parameters:
      notification -
    • sendWorkspaceEvent

      public void sendWorkspaceEvent(org.gcube.social_networking.socialnetworking.model.beans.workspace.WorkspaceEvent event)
      Notify a catalogue event, types available see WorkspaceEventType
      Parameters:
      event - an instance of WorkspaceEvent
    • sendCatalogueEvent

      public void sendCatalogueEvent(org.gcube.social_networking.socialnetworking.model.beans.catalogue.CatalogueEvent event)
      Notify a catalogue event, types availeble see CatalogueEventType
      Parameters:
      event - an instance of CatalogueEvent
    • getUnreadNotifications

      public List<org.gcube.portal.databook.shared.Notification> getUnreadNotifications()
      Retrieve unread notifications of the token's owner (excluding messages).

      Endpoint: GET 2/notifications/get-unread-notifications

      Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; application tokens are rejected by the service with 403 Forbidden.

      Returns:
      the list of unread notifications for the calling user
    • checkUnread

      public Map<String,Boolean> checkUnread()
      Check whether the token's owner has unread notifications or unread message notifications.

      Endpoint: GET 2/notifications/check-unread

      Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; application tokens are rejected by the service with 403 Forbidden.

      Returns:
      a map with boolean flags notifications and messages
    • setNotificationRead

      public Boolean setNotificationRead(String id)
      Mark a single notification as read if and only if it belongs to the token's owner.

      Endpoint: POST 2/notifications/set-notification-read?id={id}

      Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; caller can only mark their own notifications as read. The service returns 403 Forbidden if the notification belongs to another user or if the token does not belong to a user.

      Parameters:
      id - the identifier of the notification to mark as read
      Returns:
      true when the notification is marked read
    • setAllNotificationsRead

      public Boolean setAllNotificationsRead()
      Mark all unread notifications of the token's owner as read.

      Endpoint: POST 2/notifications/set-all-notifications-read

      Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; application tokens are rejected by the service with 403 Forbidden. Marks all unread notifications of the caller as read.

      Returns:
      true when all notifications of the caller are marked read
    • getPreferences

      public org.gcube.portal.databook.shared.NotificationPreferences getPreferences()
      Retrieve the notification preferences of the token's owner.

      Endpoint: GET 2/notifications/preferences

      Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; application tokens are rejected by the service with 403 Forbidden.

      Returns:
      the NotificationPreferences of the calling user
    • setPreferences

      public org.gcube.portal.databook.shared.NotificationPreferences setPreferences(org.gcube.portal.databook.shared.NotificationPreferences preferences)
      Update the notification preferences of the token's owner.

      Endpoint: POST 2/notifications/preferences

      Identity semantics: acts as the token's caller (the user owning the token in context). Requires a user token; application tokens are rejected by the service with 403 Forbidden.

      Parameters:
      preferences - the NotificationPreferences to store for the caller
      Returns:
      the updated NotificationPreferences
    • notifyUsers

      public Map<String,Object> notifyUsers(org.gcube.portal.databook.shared.NotificationInputBean input)
      Send a notification to one or more users belonging to the caller token's context.

      Endpoint: POST 2/notifications/notify

      Identity semantics: acts as the token's caller (user or application token). Context membership is verified for all recipients. For user tokens, permitted notification types are user-originated (MENTION, MESSAGE, POST_ALERT) unless the caller holds the VRE manager role, and URIs must be relative or match the gateway site host; application tokens are permitted manager/request notification types and external URIs. Dispatches notifications according to recipient preferences (portal and/or email).

      Parameters:
      input - the NotificationInputBean describing recipients, type, reference, URI, and description
      Returns:
      a per-recipient report containing a list of notified recipients and a map of rejected recipients with reasons