Interface ActivityManager


  • @ProviderType
    public interface ActivityManager
    The activity manager is used as entry point to read, create and write activities and activity streams.
    • Method Detail

      • newActivity

        MutableActivity newActivity()
        Creates a new mutable activity for populating with the input data.
        Returns:
        a new mutable activity.
      • newActivity

        MutableActivity newActivity​(JSONObject jsonObject)
        Creates a new mutable activity populated with input data of a JSON object.
        Parameters:
        jsonObject - JSON object representing the activity.
        Returns:
        a new mutable activity.
      • newActivityObject

        MutableActivityObject newActivityObject()
        Creates a new mutable activity object for populating with the input data.
        Returns:
        a new mutable activity object.
      • newMediaLink

        MutableMediaLink newMediaLink()
        Creates a new mutable media link for populating with the input data.
        Returns:
        a new mutable media link.
      • getActivities

        ActivityCollection getActivities​(ResourceResolver resolver,
                                         java.lang.String userId)
                                  throws ActivityException
        Returns the activity collection for the given user. The collection is an aggregate of the users stream and all the streams the user follows.
        Parameters:
        resolver - resource resolver to resolve the path
        userId - the userid of the user. If null the user bound to the resource resolver is used.
        Returns:
        the ActivityCollection
        Throws:
        ActivityException
      • getActivities

        ActivityCollection getActivities​(ResourceResolver resolver,
                                         java.lang.String userId,
                                         AggregateOptions options)
                                  throws ActivityException
        Returns the activity collection for the given user. The collection is an aggregate of the users stream and all the streams the user follows controlled by the aggregate options.
        Parameters:
        resolver - resource resolver
        userId - the userid of the user. If null the user bound to the resource resolver is used.
        options - the aggregate options
        Returns:
        the ActivityCollection
        Throws:
        ActivityException - if an error occurs
        Since:
        0.0.14
      • getActivity

        Activity getActivity​(ResourceResolver resolver,
                             java.lang.String id)
                      throws ActivityException
        Returns the activity with the given id or null if not exists.
        Parameters:
        resolver - resource resolver to resolve the id
        id - the id of the activity
        Returns:
        the activity or null
        Throws:
        ActivityException - if an error occurs.
      • getUserStream

        ActivityStream getUserStream​(ResourceResolver resolver,
                                     java.lang.String userId,
                                     java.lang.String streamName,
                                     boolean create)
                              throws ActivityException
        Gets the distinct activity stream for the given user.
        Parameters:
        resolver - resource resolver to resolve the path
        userId - the userid of the user
        streamName - the name of the stream or null to use the default stream
        Returns:
        the activity stream or null if the user or his stream does not exist.
        Throws:
        ActivityException - if an error occurs.
      • getGroupStream

        ActivityStream getGroupStream​(ResourceResolver resolver,
                                      java.lang.String groupName,
                                      java.lang.String streamName,
                                      boolean create)
                               throws ActivityException
        Gets the distinct activity stream for the given group.
        Parameters:
        resolver - resource resolver to resolve the path
        groupName - the name of the group
        streamName - the name of the stream or null to use the default stream
        Returns:
        the activity stream or null if the user or his stream does not exist.
        Throws:
        ActivityException - if an error occurs.
      • getStream

        ActivityStream getStream​(ResourceResolver resolver,
                                 Authorizable auth,
                                 java.lang.String streamName,
                                 boolean create)
                          throws ActivityException
        Gets the distinct activity stream for the given authorizable.
        Parameters:
        resolver - resource resolver to resolve the path
        auth - the jackrabbit authorizable
        streamName - the name of the stream or null to use the default stream
        Returns:
        the activity stream or null if the user or his stream does not exist.
        Throws:
        ActivityException - if an error occurs
      • getStream

        ActivityStream getStream​(Resource containerResource,
                                 java.lang.String name,
                                 boolean create)
                          throws ActivityException
        Returns the activity stream for the given container resource, e.g. user, group, document. If the stream does not exist and create is true a new stream is created.
        Parameters:
        containerResource - the container resource
        name - the stream name
        Returns:
        the stream or null if no such stream exists
        Throws:
        ActivityException - if an error occurs
      • listStreams

        java.util.Collection<ActivityStream> listStreams​(Resource containerResource)
                                                  throws ActivityException
        Lists all streams of the given container resource (user, group, document);
        Parameters:
        containerResource - the resource to list the streams
        Returns:
        a collection of streams or null if the resource is invalid.
        Throws:
        ActivityException - if an error occurs
      • listStreams

        java.util.Collection<ActivityStream> listStreams​(ResourceResolver resolver,
                                                         java.lang.String userId,
                                                         AggregateOptions options)
                                                  throws ActivityException
        Lists all streams for the given user that would be used to build the activity collection.
        Parameters:
        resolver - resource resolver
        userId - the user id
        options - the aggregate options
        Returns:
        a collection of streams or null if the resource is invalid.
        Throws:
        ActivityException - if an error occurs
        Since:
        0.0.10
      • getFollowers

        java.lang.Iterable<java.lang.String> getFollowers​(Activity activity)
                                                   throws ActivityException,
                                                          java.lang.IllegalArgumentException
        Returns an iterable over a list of users that see this activity in their default aggregate stream. Note that the resource resolver bound to the activity is used to resolve all paths and authorizables.
        Parameters:
        activity - the activity
        Returns:
        an iterable over all user ids.
        Throws:
        ActivityException - if an error occurs
        java.lang.IllegalArgumentException - if the activity is not persisted in the underlying repository
        Since:
        0.0.10
      • getFollowers

        java.lang.Iterable<java.lang.String> getFollowers​(ActivityStream stream)
                                                   throws ActivityException,
                                                          java.lang.IllegalArgumentException
        Returns an iterable over a list of users that follow this stream stream. Note that the resource resolver bound to the activity is used to resolve all paths and authorizables.
        Parameters:
        stream - the stream
        Returns:
        an iterable over all user ids.
        Throws:
        ActivityException - if an error occurs
        java.lang.IllegalArgumentException - if the activity is not persisted in the underlying repository
        Since:
        0.0.14