org.apache.sling.sample.slingshot.ratings

## Interface RatingsService

All Known Implementing Classes:
  RatingsServiceImpl

    public interface RatingsService

Service for handling the ratings

### Method Summary

All Methods Instance Methods Abstract Methods
`double` `getRating(org.apache.sling.api.resource.Resource resource)` Get the overall rating for a resource.
`double` `getRating(org.apache.sling.api.resource.Resource resource, String userId)` Get the rating of a user for a resource.
`String` `getRatingsResourcePath(org.apache.sling.api.resource.Resource resource)` Return the path to the ratings resource for a resource.
`void` `setRating(org.apache.sling.api.resource.Resource resource, String userId, double rating)` Set the rating of a user for a resource.

### Method Detail

#### getRatingsResourcePath

    String getRatingsResourcePath(org.apache.sling.api.resource.Resource resource)

Return the path to the ratings resource for a resource.

Parameters:
  `resource` - The content resource, this is usually an entry.
Returns:
  The path to the ratings resource or `null` if the passed in content resource is not part of Slingshot.

#### getRating

    double getRating(org.apache.sling.api.resource.Resource resource)

Get the overall rating for a resource.

Parameters:
  `resource` - The content resource, this is usually an entry.
Returns:
  The rating or `0` if the passed in content resource is not part of Slingshot.

#### getRating

    double getRating(org.apache.sling.api.resource.Resource resource,
                     String userId)

Get the rating of a user for a resource.

Parameters:
  `resource` - The content resource, this is usually an entry.
  `userId` - The user id
Returns:
  The rating or `0` if the passed in content resource is not part of Slingshot.

#### setRating

    void setRating(org.apache.sling.api.resource.Resource resource,
                   String userId,
                   double rating)
            throws org.apache.sling.api.resource.PersistenceException

Set the rating of a user for a resource.

Parameters:
  `resource` - The content resource, this is usually an entry.
  `userId` - The user id
Throws:
  `org.apache.sling.api.resource.PersistenceException`