model.put("message", "Tweet Not Valid..");
} else {
tweetId = filterValue(tweetId);
model.put("tweetId", tweetId);
log.info("search code->"+tweetId);
final TweetPollSwitch tweetPoll = getTweetPollService()
.getTweetPollDao().retrieveTweetsPollSwitch(tweetId);
model.addAttribute("tp_switch", tweetPoll);
final Boolean validateLimitVotes = getTweetPollService().validateLimitVotes(tweetPoll.getTweetPoll());
final Boolean restrictVotesByDate = getTweetPollService().validateVotesByDate(tweetPoll.getTweetPoll());
//NOTE: tweetpoll should be published to able to vote !!
if (tweetPoll == null || !tweetPoll.getTweetPoll().getPublishTweetPoll()) {
log.debug("tweetpoll answer not found");
model.put("message", getMessage("tp_no_valid"));
} else if (tweetPoll.getTweetPoll().getCompleted()) {
log.debug("tweetpoll is archived");
model.put("message", getMessage("tweetpoll.votes.completed"));
pathVote = "completeTweetVote";
// Validate Limit Votes
} else if(validateLimitVotes) {
log.debug("tweetpoll reached limit votes");
model.put("message", getMessage("tweetpoll.votes.limited"));
pathVote = "LimitTweetVote";
} else {
log.info("Validate Votting");
log.info("IP" + IP);
try {
getTweetPollService().validateIpVote(IP,
tweetPoll.getTweetPoll());
if (!tweetPoll.getTweetPoll().getCaptcha()) {
getTweetPollService().tweetPollVote(tweetPoll, IP,
Calendar.getInstance().getTime());
model.put("message", getMessage("tweetpoll.votes.acepted"));
pathVote = "tweetVoted";
log.debug("VOTED");