// default path
final RequestSourceType requestSourceType = RequestSourceType.getSource(type_form);
final String isEmbedded = !requestSourceType.equals(RequestSourceType.EMBEDDED) ? "" : "embedded/";
log.debug("isEmbedded * " + isEmbedded);
String pathVote = "poll/" + isEmbedded + "voted";
Poll poll = new Poll();
// Check IP in BlackListFile - Validation
final String IP = getIpClient(req);
final Boolean checkBannedIp = checkIPinBlackList(IP);
if (checkBannedIp) {
// if banned send to banned view.
pathVote = "poll/ " + isEmbedded + "banned";
} else {
// Item id is poll id
if (itemId == null) {
// Exception musst be removed.
throw new EnMePollNotFoundException("poll id has not been found");
// if answer id is null return the request
} else if (responseId == null) {
//poll = getPollService().getPollById(itemId);
poll = getPollService().getPollByAnswerId(itemId, responseId, null);
model.addAttribute("poll", ConvertDomainBean.convertPollDomainToBean(poll));
RequestSessionMap.getCurrent(req).put("votePollError", Boolean.TRUE);
pathVote = "redirect:/poll/vote/" + itemId + "/" + slugName;
} else {
type = filterValue(type);
type_form = filterValue(type_form);
slugName = filterValue(slugName);
poll = getPollService().getPollByAnswerId(itemId, responseId, null);
// restrictions by date
final Boolean restrictVotesByDate = getPollService().restrictVotesByDate(poll);
// restrictions by quota
final Boolean restrictVotesByQuota = getPollService().restrictVotesByQuota(poll);
if (poll == null || !poll.getPublish()) {
log.warn("pll answer not found");
model.put("message", getMessage("poll.votes.bad"));
}
// Validate properties or options
else if (poll.getPollCompleted()) {
model.put("message", getMessage("poll.completed"));
pathVote = "poll/" + isEmbedded + "completed";
} else if (restrictVotesByQuota) {
model.put("message", getMessage("tweetpoll.votes.limited"));
pathVote = "poll/" + isEmbedded + "bad";
} else if (restrictVotesByDate) {
model.put("message", getMessage("poll.closed"));
pathVote = "poll/" + isEmbedded + "bad";
} else {
try {
model.put("pollAnswer", poll);
final PollResult result = getPollService().validatePollIP(IP, poll);
if (result == null) {
if (poll.getMultipleResponse().equals(AbstractSurvey.MultipleResponse.MULTIPLE)) {
for (int i = 0; i < multiplesVotes.length; i++) {
try {
final Long responseIdMultiple = Long.valueOf(multiplesVotes[i]);
getPollService().vote(poll, slugName, IP, responseIdMultiple);
} catch(Exception error) {
log.error("error on multivote " + error.getMessage());
error.printStackTrace();
}
model.put("message", getMessage("poll.votes.thanks"));
pathVote = "poll/" + isEmbedded + "voted";
}
} else if(poll.getMultipleResponse().equals(AbstractSurvey.MultipleResponse.SINGLE)) {
getPollService().vote(poll, slugName, IP,responseId);
model.put("message", getMessage("poll.votes.thanks"));
pathVote = "poll/" + isEmbedded + "voted";
}
} else {