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 ActivityCollectiongetActivities(ResourceResolver resolver, java.lang.String userId)Returns the activity collection for the given user.ActivityCollectiongetActivities(ResourceResolver resolver, java.lang.String userId, AggregateOptions options)Returns the activity collection for the given user.ActivitygetActivity(ResourceResolver resolver, java.lang.String id)Returns the activity with the given id ornullif 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.ActivityStreamgetGroupStream(ResourceResolver resolver, java.lang.String groupName, java.lang.String streamName, boolean create)Gets the distinct activity stream for the given group.ActivityStreamgetStream(Resource streamResource)Returns the activity stream for the given resource.ActivityStreamgetStream(ResourceResolver resolver, Authorizable auth, java.lang.String streamName, boolean create)Gets the distinct activity stream for the given authorizable.ActivityStreamgetStream(Resource containerResource, java.lang.String name, boolean create)Returns the activity stream for the given container resource, e.g.ActivityStreamgetTopicStream(Resource topicResource, java.lang.String streamName)Deprecated.since 0.0.8.ActivityStreamgetUserStream(ResourceResolver resolver, java.lang.String userId, java.lang.String streamName)Deprecated.since 0.0.8.ActivityStreamgetUserStream(ResourceResolver resolver, java.lang.String userId, java.lang.String streamName, boolean create)Gets the distinct activity stream for the given user.ActivityStreamgetUserStream(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.MutableActivitynewActivity()Creates a new mutable activity for populating with the input data.MutableActivitynewActivity(JSONObject jsonObject)Creates a new mutable activity populated with input data of a JSON object.MutableActivityObjectnewActivityObject()Creates a new mutable activity object for populating with the input data.MutableMediaLinknewMediaLink()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. Ifnullthe 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. Ifnullthe 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 ornullif 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 ornullto use the default stream- Returns:
- the activity stream or
nullif 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 ornullto use the default stream- Returns:
- the activity stream or
nullif 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 ornullto use the default stream- Returns:
- the activity stream or
nullif 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 andcreateistruea new stream is created.- Parameters:
containerResource- the container resourcename- the stream name- Returns:
- the stream or
nullif 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
nullif 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
nullif 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 ornullto use the default stream- Returns:
- the activity stream or
nullif 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 ornullto use the default stream- Returns:
- the activity stream or
nullif 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 ornullto use the default stream- Returns:
- the stream
- Throws:
ActivityException- if an error occurs
-
-