mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Rating Service minor improvements.
Added afterPropertiesSet to prevent rating schemes with minimum > maximum. Changed 'fivestar' scheme range from 0..5 to 1..5 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21046 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -20,14 +20,15 @@
|
||||
package org.alfresco.repo.rating;
|
||||
|
||||
import org.alfresco.service.cmr.rating.RatingScheme;
|
||||
import org.alfresco.service.cmr.rating.RatingServiceException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
/*
|
||||
* @author Neil McErlean
|
||||
* @since 3.4
|
||||
*/
|
||||
public class RatingSchemeImpl implements RatingScheme, BeanNameAware
|
||||
public class RatingSchemeImpl implements RatingScheme, BeanNameAware, InitializingBean
|
||||
{
|
||||
private final RatingSchemeRegistry ratingSchemeRegistry;
|
||||
|
||||
@@ -62,19 +63,45 @@ public class RatingSchemeImpl implements RatingScheme, BeanNameAware
|
||||
{
|
||||
this.maxRating = maxRating;
|
||||
}
|
||||
|
||||
//TODO afterPropertiesSet assert Max > Min
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
if (this.minRating > this.maxRating)
|
||||
{
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Illegal rating limits for ").append(name)
|
||||
.append(". Min > Max. ")
|
||||
.append(minRating).append(" > ").append(maxRating);
|
||||
throw new RatingServiceException(msg.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.rating.RatingScheme#getMaxRating()
|
||||
*/
|
||||
public int getMaxRating()
|
||||
{
|
||||
return this.maxRating;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.rating.RatingScheme#getMinRating()
|
||||
*/
|
||||
public int getMinRating()
|
||||
{
|
||||
return this.minRating;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.rating.RatingScheme#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
|
Reference in New Issue
Block a user