@Override public synchronized DomainEntity vote(UUID pollId, UUID pollOptionId, HttpServletRequest request) {
Assert.notNull(pollId);
Assert.notNull(pollOptionId);
Poll poll = dao.find(Poll.class, pollId);
PollOption option = dao.find(PollOption.class, pollOptionId);
User user = userManager.getActiveUser(request);
String IPAddress = request.getRemoteAddr();
if (poll.getUserVote(user, IPAddress, dao) == null) {
if (poll.isAllowAnonymousVotes() | !user.isAnonymous()) {
option.vote();
dao.update(option);
if (poll.isStoreVotes()) {
PollVote pollVote = new PollVote();
pollVote.setVoteTime(new Date());
pollVote.setIP(IPAddress);
if (!user.isAnonymous()) pollVote.setAuthor((UserImpl) user);
pollVote.setOption(option);
dao.create(pollVote);
}
}
}