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 Details

  • Method Details

    • getReactionOptions

      List<ReactionOption> getReactionOptions()
      Returns:
      every registered ReactionOption sorted by rank
    • getReactionOptions

      List<ReactionOption> getReactionOptions(String objectType)
      Parameters:
      objectType - Object type the options are suggested for
      Returns:
      registered ReactionOption supporting 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 identifier
      reactionId - One of the registered ReactionOption ids
      username - User name (login identifier) of the reactor
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the target object doesn't exist
      IllegalAccessException - when the user can't view the target object
      IllegalArgumentException - 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 type
      objectId - Object technical identifier
      username - 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 it
      IllegalAccessException - 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 type
      objectId - Object technical identifier
      username - 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 exist
      IllegalAccessException - 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 type
      objectId - Object technical identifier
      reactionId - Optional reaction option id to filter on, null for all
      offset - Query offset
      limit - Query limit
      username - User name (login identifier) used for the view ACL check
      Returns:
      paged Reaction list of the object reactors
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the target object doesn't exist
      IllegalAccessException - when the user can't view the target object
    • deleteReactionItem

      void deleteReactionItem(String objectType, String objectId, long reactorIdentityId)
      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 type
      objectId - Object technical identifier
      reactorIdentityId - Identity id of the reactor whose item to delete