Interface ActivityManager
-
@ProviderType public interface ActivityManager
The activity manager is used as entry point to read, create and write activities and activity streams.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description ActivityCollection
getActivities(ResourceResolver resolver, java.lang.String userId)
Returns the activity collection for the given user.ActivityCollection
getActivities(ResourceResolver resolver, java.lang.String userId, AggregateOptions options)
Returns the activity collection for the given user.Activity
getActivity(ResourceResolver resolver, java.lang.String id)
Returns the activity with the given id ornull
if not exists.java.lang.Iterable<java.lang.String>
getFollowers(Activity activity)
Returns an iterable over a list of users that see this activity in their default aggregate stream.java.lang.Iterable<java.lang.String>
getFollowers(ActivityStream stream)
Returns an iterable over a list of users that follow this stream stream.ActivityStream
getGroupStream(ResourceResolver resolver, java.lang.String groupName, java.lang.String streamName, boolean create)
Gets the distinct activity stream for the given group.ActivityStream
getStream(Resource streamResource)
Returns the activity stream for the given resource.ActivityStream
getStream(ResourceResolver resolver, Authorizable auth, java.lang.String streamName, boolean create)
Gets the distinct activity stream for the given authorizable.ActivityStream
getStream(Resource containerResource, java.lang.String name, boolean create)
Returns the activity stream for the given container resource, e.g.ActivityStream
getTopicStream(Resource topicResource, java.lang.String streamName)
Deprecated.since 0.0.8.ActivityStream
getUserStream(ResourceResolver resolver, java.lang.String userId, java.lang.String streamName)
Deprecated.since 0.0.8.ActivityStream
getUserStream(ResourceResolver resolver, java.lang.String userId, java.lang.String streamName, boolean create)
Gets the distinct activity stream for the given user.ActivityStream
getUserStream(ResourceResolver resolver, User user, java.lang.String streamName)
Deprecated.since 0.0.8.java.util.Collection<ActivityStream>
listStreams(Resource containerResource)
Lists all streams of the given container resource (user, group, document);java.util.Collection<ActivityStream>
listStreams(ResourceResolver resolver, java.lang.String userId, AggregateOptions options)
Lists all streams for the given user that would be used to build the activity collection.MutableActivity
newActivity()
Creates a new mutable activity for populating with the input data.MutableActivity
newActivity(JSONObject jsonObject)
Creates a new mutable activity populated with input data of a JSON object.MutableActivityObject
newActivityObject()
Creates a new mutable activity object for populating with the input data.MutableMediaLink
newMediaLink()
Creates a new mutable media link for populating with the input data.
-
-
-
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 pathuserId
- the userid of the user. Ifnull
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 resolveruserId
- the userid of the user. Ifnull
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 ornull
if not exists.- Parameters:
resolver
- resource resolver to resolve the idid
- 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 pathuserId
- the userid of the userstreamName
- the name of the stream ornull
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 pathgroupName
- the name of the groupstreamName
- the name of the stream ornull
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 pathauth
- the jackrabbit authorizablestreamName
- the name of the stream ornull
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 streamResource) throws ActivityException
Returns the activity stream for the given resource.- Parameters:
streamResource
- the stream resource- Returns:
- the stream
- 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 andcreate
istrue
a new stream is created.- Parameters:
containerResource
- the container resourcename
- 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 resolveruserId
- the user idoptions
- 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 occursjava.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 occursjava.lang.IllegalArgumentException
- if the activity is not persisted in the underlying repository- Since:
- 0.0.14
-
getUserStream
@Deprecated ActivityStream getUserStream(ResourceResolver resolver, java.lang.String userId, java.lang.String streamName) throws ActivityException
Deprecated.since 0.0.8. usegetUserStream(org.apache.sling.api.resource.ResourceResolver, String, String, boolean)
instead.Gets the distinct activity stream for the given user.- Parameters:
resolver
- resource resolver to resolve the pathuserId
- the userid of the userstreamName
- the name of the stream ornull
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.
-
getUserStream
@Deprecated ActivityStream getUserStream(ResourceResolver resolver, User user, java.lang.String streamName) throws ActivityException
Deprecated.Gets the distinct activity stream for the given user.- Parameters:
resolver
- resource resolver to resolve the pathuser
- the jackrabbit userstreamName
- the name of the stream ornull
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
-
getTopicStream
@Deprecated ActivityStream getTopicStream(Resource topicResource, java.lang.String streamName) throws ActivityException
Deprecated.since 0.0.8. usegetStream(org.apache.sling.api.resource.Resource, String, boolean)
instead.Returns the activity stream for the given resource.- Parameters:
topicResource
- the topic for which the stream is retrievedstreamName
- the name of the stream ornull
to use the default stream- Returns:
- the stream
- Throws:
ActivityException
- if an error occurs
-
-