Package org.xwiki.like
Interface LikeManager
-
@Role public interface LikeManager
General manager to handle likes.- Since:
- 12.7RC1
- Version:
- $Id: 7998e5f76de5215e683c65676f41c67303ca895c $
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clearCache()
Clear all data from caches.void
clearCache(EntityReference target)
Clear like data related to the given reference from cache.long
countUserLikes(UserReference source)
Retrieve the total number of likes performed by a user.long
getEntityLikes(EntityReference target)
Retrieve like information a specific entity.org.xwiki.security.authorization.Right
getLikeRight()
List<UserReference>
getLikers(EntityReference target, int offset, int limit)
Retrieve the users who liked the given reference.List<EntityReference>
getUserLikes(UserReference source, int offset, int limit)
Retrieve the likes performed by the given user.boolean
isLiked(UserReference source, EntityReference target)
Check if an entity is liked by an user without loading all likers.boolean
removeLike(UserReference source, EntityReference target)
Allow a user to unlike an entity.long
saveLike(UserReference source, EntityReference target)
Create a page like and save it.
-
-
-
Method Detail
-
saveLike
long saveLike(UserReference source, EntityReference target) throws LikeException
Create a page like and save it.- Parameters:
source
- the user who performs the like.target
- the page or object to like.- Returns:
- the new number of likes.
- Throws:
LikeException
- in case of problem when saving the like.
-
getUserLikes
List<EntityReference> getUserLikes(UserReference source, int offset, int limit) throws LikeException
Retrieve the likes performed by the given user.- Parameters:
source
- the user for whom to retrieve the entity likes.offset
- the offset used for pagination.limit
- the limit number of results to retrieve for pagination.- Returns:
- a list of references liked by this user.
- Throws:
LikeException
- in case of problem when getting the like.
-
countUserLikes
long countUserLikes(UserReference source) throws LikeException
Retrieve the total number of likes performed by a user.- Parameters:
source
- the user who performs the likes to count.- Returns:
- the total number of likes performed.
- Throws:
LikeException
- in case of problem when getting the information.- Since:
- 12.9RC1
-
getEntityLikes
long getEntityLikes(EntityReference target) throws LikeException
Retrieve like information a specific entity.- Parameters:
target
- the page or object for which to retrieve the like information.- Returns:
- the number of likes for that entity.
- Throws:
LikeException
- in case of problem when getting the like.
-
removeLike
boolean removeLike(UserReference source, EntityReference target) throws LikeException
Allow a user to unlike an entity.- Parameters:
source
- the user who performs the unlike.target
- the entity to unlike.- Returns:
true
if the entity has been properly unliked.- Throws:
LikeException
- in case of problem when removing the like.
-
isLiked
boolean isLiked(UserReference source, EntityReference target) throws LikeException
Check if an entity is liked by an user without loading all likers.- Parameters:
source
- the user who might have liked.target
- the entity which might have been liked.- Returns:
true
if the user liked the page already.- Throws:
LikeException
- in case of problem for loading the result.
-
getLikers
List<UserReference> getLikers(EntityReference target, int offset, int limit) throws LikeException
Retrieve the users who liked the given reference.- Parameters:
target
- the page that has been liked.offset
- the offset used for pagination.limit
- the limit used for pagination.- Returns:
- a list of user references of users who liked this page.
- Throws:
LikeException
- in case of problem for performing the query.- Since:
- 12.9RC1
-
getLikeRight
org.xwiki.security.authorization.Right getLikeRight()
- Returns:
- a dedicated programmatic right for Like feature.
-
clearCache
void clearCache(EntityReference target)
Clear like data related to the given reference from cache.- Parameters:
target
- the reference for which data should be cleared.- Since:
- 12.9RC1
-
clearCache
void clearCache()
Clear all data from caches.- Since:
- 12.9RC1
-
-