if (!SecurityHelper.doesUserHavePermission(session.get(), authUser, permissibleObject, PERM.READ)) {
throw new SimpleMessageException("User is not authorized to set advisory on this content.");
}
// check if rating already exists
UserAdvisory userAdvisory = AdvisoryHelper.getUserAdvisory(session.get(), permissibleObject, authUser, getVoterGUID());
if (userAdvisory != null) {
throw new SimpleMessageException("Already voted.");
}
float totalAdvisory = (float) permissibleObject.getNumAdvisoryVotes() * permissibleObject.getAverageAdvisory();
totalAdvisory += advisory;
permissibleObject.setNumAdvisoryVotes(permissibleObject.getNumAdvisoryVotes() + 1);
float newAvg = totalAdvisory / (float) permissibleObject.getNumAdvisoryVotes();
permissibleObject.setAverageAdvisory(newAvg);
session.get().save(permissibleObject);
userAdvisory = new UserAdvisory();
userAdvisory.setPermissibleObject(permissibleObject);
userAdvisory.setRating(advisory);
userAdvisory.setVoter(authUser);
userAdvisory.setVoterGUID(getVoterGUID());
session.get().save(userAdvisory);
tx.commit();
return userAdvisory;
} catch (Throwable t) {