This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Managing Ratings



Rating a Resource

In order to rate a resource based on our judgment, you can use the registry instance. Rating a resource can be done using the following line of code:

registry.rateResource("c1/c2/r2 " , 4);

Retrieving the Average Rating of a Resource

An average of all ratings of a particular resource can be retrieved. This can be done using the following line of code:

registry.getAverageRating("c1/c2/r2");

Retrieving the Rating Given to the Resource by a Particular User

When a rating given by a particular user for a resource is needed, it can be done using the following line of code:

registry.getRating("c1/c2/r2", "wso2_admin"); // rating given for r2 by wso2 admin

See also Comments and Ratings to learn how to manage rating in the Management Console.