@Override
public synchronized void addRatingToContent(String contentId, int vote) throws ApsSystemException{
try {
RatingSearchBean searchBean = new RatingSearchBean();
searchBean.setContentId(contentId);
Rating rating = this.getRatingDAO().getRating(searchBean);
if (rating == null){
rating = new Rating();
int key = this.getKeyGeneratorManager().getUniqueKeyCurrentValue();
rating.setId(key);
rating.setContentId(contentId);
rating.setVote(1, vote);
this.getRatingDAO().addRating(rating);
} else {
rating.setVote(rating.getVoters()+1, rating.getSumvote()+vote);
this.getRatingDAO().updateRating(rating);
}
this.notifyEvent(contentId, -1, ContentFeedbackChangedEvent.CONTENT_RATING, ContentFeedbackChangedEvent.INSERT_OPERATION_CODE);
} catch (Throwable t) {
ApsSystemUtils.logThrowable(t, this, "addRatingToContent");