Wiki source code of Like API

Last modified by Eleni Cojocariu on 2026/08/12 16:21

Show last authors
1 The Like API records that a user likes an entity, counts the likes an entity received, and lists the users who liked it.
2
3 Call it from wiki pages through the [[Like Script Service>>documentation.xs.dev.like.script-service.WebHome]], and from a Component through the [[Like Java API>>documentation.xs.dev.like.java-api.WebHome]].
4
5 How the feature behaves is explained on three pages:
6
7 * [[Likes as Ratings>>documentation.xs.dev.like.ratings.WebHome]] — what the Ratings settings make of a like, and where likes are kept.
8 * [[Like Right>>documentation.xs.dev.like.right.WebHome]] — who is allowed to like.
9 * [[Like Caches>>documentation.xs.dev.like.caches.WebHome]] — why a like count can go stale.
10
11 [[Like Storage Properties>>documentation.xs.dev.like.storage-properties.WebHome]] lists the two ##xwiki.properties## keys that change where the average rating of a like is kept.
12
13 What readers actually click comes from the [[Like Application>>extensions:Extension.Like Application.WebHome]], which builds on this API and is documented for [[users>>documentation.xs.user.like.WebHome]] and [[administrators>>documentation.xs.admin.like.WebHome]].
14
15 The Components of the feature, and what flows between them:
16
17 {{plantuml}}
18 @startuml
19 !theme bluegray
20 skinparam componentStyle rectangle
21
22 component "**LikeScriptService**\n$services.like" as SS
23 component "**LikeManager**\nsaveLike, removeLike, isLiked, getLikers" as LM
24 component "**LikeManagerCacheHelper**\ncount cache + exist cache" as CACHE
25 component "**LikeConfiguration**\nfrom XWiki.Like.LikeConfiguration" as LC
26 component "**LikeRatingsConfiguration**\nfrom xwiki.properties" as CONF
27 component "**RatingsManager**\nidentifier = like" as RM
28 queue "LikeEvent\nUnlikeEvent" as EV
29 database "Solr\nratings core\nmanagerId = like" as SOLR
30
31 SS --> LM
32 SS --> LC : enabled, always display
33 LM --> CACHE : reads first, invalidates on write
34 LM --> RM : saveRating, removeRating, countRatings, getRatings
35 LM --> EV : notifies
36 LC ..> CACHE : capacity
37 CONF ..> RM : configures
38 RM --> SOLR
39 EV ..> CACHE : trigger further invalidation
40 @enduml
41 {{/plantuml}}

Get Connected