@Component @Singleton @Named(value="like") @Unstable public class LikeScriptService extends Object implements org.xwiki.script.service.ScriptService
Constructor and Description |
---|
LikeScriptService() |
Modifier and Type | Method and Description |
---|---|
Optional<Long> |
countUserLikes(UserReference userReference)
Count the number of likes performed by the given user.
|
boolean |
displayButton(EntityReference entityReference)
Check if the display button should be displayed: should be
true if the like feature is enabled
(see LikeConfiguration.isEnabled() ) and if current user is authorized to use like
(see isAuthorized(EntityReference) ) or if the configuration is set to always display it
(see LikeConfiguration.alwaysDisplayButton() ). |
List<UserReference> |
getLikers(EntityReference target,
int offset,
int limit)
Return the likers of a reference.
|
Optional<Long> |
getLikes(EntityReference entityReference)
Retrieve like information for the given reference.
|
List<EntityReference> |
getUserLikes(UserReference userReference,
int offset,
int limit)
Retrieve likes performed by the given user.
|
boolean |
isAuthorized(EntityReference entityReference)
Check if current user is allowed to use Like on the given reference.
|
boolean |
isEnabled() |
boolean |
isLiked(EntityReference entityReference)
Determine if the current user already liked the given reference.
|
Optional<Long> |
like(EntityReference entityReference)
Perform a like on the given reference with the current user, only if allowed.
|
Optional<Long> |
unlike(EntityReference entityReference)
Perform a unlike on the given reference with the current user, only if allowed.
|
public boolean isAuthorized(EntityReference entityReference)
entityReference
- the reference on which to use like.true
only if current user is not guest and has Like right on the reference.public boolean displayButton(EntityReference entityReference)
true
if the like feature is enabled
(see LikeConfiguration.isEnabled()
) and if current user is authorized to use like
(see isAuthorized(EntityReference)
) or if the configuration is set to always display it
(see LikeConfiguration.alwaysDisplayButton()
).entityReference
- the reference for which to display the buttontrue
only if the button should be displayed.@Unstable public boolean isEnabled()
true
if the Like feature is enabled.public Optional<Long> like(EntityReference entityReference)
entityReference
- the reference on which to perform a like.public Optional<Long> unlike(EntityReference entityReference)
entityReference
- the reference on which to perform a like.public Optional<Long> getLikes(EntityReference entityReference)
entityReference
- the reference for which to retrieve like information.public List<EntityReference> getUserLikes(UserReference userReference, int offset, int limit)
userReference
- the user for whom to retrieve likes.offset
- the offset used for pagination.limit
- the limit used for pagination.@Unstable public Optional<Long> countUserLikes(UserReference userReference)
userReference
- the user for whom to count likes.public boolean isLiked(EntityReference entityReference)
entityReference
- the reference for which to check if the current liked it or not already.true
if the entity has been already liked.@Unstable public List<UserReference> getLikers(EntityReference target, int offset, int limit)
target
- the reference being liked.offset
- the start offset for pagination.limit
- the limit of results for pagination.Copyright © 2004–2021 XWiki. All rights reserved.