Package io.meeds.social.reaction.service
Interface ReactionService
public interface ReactionService
Reactions framework: a reaction is a like decorated with a typed option. The
fact of reacting rides the existing like path (for likeable objects); the
chosen type is stored as a metadata item of type
METADATA_TYPE_NAME. A plain like stores no metadata
item: the absence of item means 'like'.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncountReactionsByOption(String objectType, String objectId, String username) voiddeleteReaction(String objectType, String objectId, String username) Deletes the current user reaction on an object (unlikes it as well).voiddeleteReactionItem(String objectType, String objectId, long reactorIdentityId) Deletes the typed reaction item of a reactor on an object without touching the like.getReactionOptions(String objectType) getReactions(String objectType, String objectId, String reactionId, long offset, long limit, String username) voidsetReaction(String objectType, String objectId, String reactionId, String username) Sets (creates or changes) the current user reaction on an object.
-
Field Details
-
LIKE_REACTION_ID
- See Also:
-
METADATA_TYPE_NAME
- See Also:
-
REACTION_CREATED_EVENT_NAME
- See Also:
-
REACTION_UPDATED_EVENT_NAME
- See Also:
-
REACTION_DELETED_EVENT_NAME
- See Also:
-
-
Method Details
-
getReactionOptions
List<ReactionOption> getReactionOptions()- Returns:
- every registered
ReactionOptionsorted by rank
-
getReactionOptions
- Parameters:
objectType- Object type the options are suggested for- Returns:
- registered
ReactionOptionsupporting the given object type, sorted by rank
-
setReaction
void setReaction(String objectType, String objectId, String reactionId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Sets (creates or changes) the current user reaction on an object. Creating a reaction likes the object as well; changing an existing reaction only switches the stored type without re-firing the like lifecycle.- Parameters:
objectType- Object type, 'activity' being the only bound type for now (comments are activities)objectId- Object technical identifierreactionId- One of the registeredReactionOptionidsusername- User name (login identifier) of the reactor- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the target object doesn't existIllegalAccessException- when the user can't view the target objectIllegalArgumentException- when the reaction id isn't registered or the object type isn't supported
-
deleteReaction
void deleteReaction(String objectType, String objectId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Deletes the current user reaction on an object (unlikes it as well).- Parameters:
objectType- Object typeobjectId- Object technical identifierusername- User name (login identifier) of the reactor- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the target object doesn't exist or the user hasn't reacted to itIllegalAccessException- when the user can't view the target object
-
countReactionsByOption
Map<String,Long> countReactionsByOption(String objectType, String objectId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException - Parameters:
objectType- Object typeobjectId- Object technical identifierusername- User name (login identifier) used for the view ACL check- Returns:
- reactors count per reaction option id, 'like' included
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the target object doesn't existIllegalAccessException- when the user can't view the target object
-
getReactions
List<Reaction> getReactions(String objectType, String objectId, String reactionId, long offset, long limit, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException - Parameters:
objectType- Object typeobjectId- Object technical identifierreactionId- Optional reaction option id to filter on, null for alloffset- Query offsetlimit- Query limitusername- User name (login identifier) used for the view ACL check- Returns:
- paged
Reactionlist of the object reactors - Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the target object doesn't existIllegalAccessException- when the user can't view the target object
-
deleteReactionItem
Deletes the typed reaction item of a reactor on an object without touching the like. Internal cleanup path (no ACL): called by the glue listener on the like-deletion lifecycle so an unlike made through the legacy endpoints doesn't leave an orphan typed reaction behind. No-op when the reactor holds no typed reaction on the object.- Parameters:
objectType- Object typeobjectId- Object technical identifierreactorIdentityId- Identity id of the reactor whose item to delete
-