org.apache.sling.sample.slingshot.ratings.impl

## Class RatingsServiceImpl

- java.lang.Object
- - org.apache.sling.sample.slingshot.ratings.impl.RatingsServiceImpl

All Implemented Interfaces:
  RatingsService

    public class RatingsServiceImpl
    extends Object
    implements RatingsService

Implementation of the ratings service

### Field Summary

Fields
`static String` `RESOURCETYPE_RATINGS` The resource type for the rating holder.

### Constructor Summary

Constructors
Constructor and Description
`RatingsServiceImpl()`

### Method Summary

All Methods Instance Methods Concrete 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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### RESOURCETYPE_RATINGS

    public static final String RESOURCETYPE_RATINGS

The resource type for the rating holder.

See Also:
  Constant Field Values

### Constructor Detail

#### RatingsServiceImpl

    public RatingsServiceImpl()

### Method Detail

#### getRatingsResourcePath

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

Description copied from interface: `RatingsService`
Return the path to the ratings resource for a resource.

Specified by:
  `getRatingsResourcePath` in interface `RatingsService`
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.
See Also:
  `RatingsService.getRatingsResourcePath(org.apache.sling.api.resource.Resource)`

#### getRating

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

Description copied from interface: `RatingsService`
Get the overall rating for a resource.

Specified by:
  `getRating` in interface `RatingsService`
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.
See Also:
  `RatingsService.getRating(org.apache.sling.api.resource.Resource)`

#### getRating

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

Description copied from interface: `RatingsService`
Get the rating of a user for a resource.

Specified by:
  `getRating` in interface `RatingsService`
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.
See Also:
  `RatingsService.getRating(org.apache.sling.api.resource.Resource, java.lang.String)`

#### setRating

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

Description copied from interface: `RatingsService`
Set the rating of a user for a resource.

Specified by:
  `setRating` in interface `RatingsService`
Parameters:
  `resource` - The content resource, this is usually an entry.
  `userId` - The user id
Throws:
  `org.apache.sling.api.resource.PersistenceException`
See Also:
  `org.apache.sling.sample.slingshot.ratings.RatingsService#setRating(org.apache.sling.api.resource.Resource, java.lang.String, int)`