List of usage examples for org.springframework.ui ModelMap toString
public String toString()
From source file:org.encuestame.mvc.page.TweetPollController.java
/** * reCAPTCHA validate process.//from w ww.j a va 2 s . c om * @param req {@link HttpServletRequest}. * @param challenge recaptcha_challenge_field parameter * @param response recaptcha_response_field paremeter * @param code code vote * @param result {@link BindingResult}. * @param model {@link ModelMap}. * @return view to redirect. * @throws UnknownHostException */ @RequestMapping(value = "/tweetpoll/vote/process", method = RequestMethod.POST) public String processSubmit(HttpServletRequest req, @RequestParam("recaptcha_challenge_field") String challenge, @RequestParam("recaptcha_response_field") String response, @RequestParam("vote_code") String code, @ModelAttribute("captchaForm") UtilVoteCaptcha vote, BindingResult result, ModelMap model) throws UnknownHostException { setCss(model, "tweetpoll"); log.info("recaptcha_challenge_field " + challenge); log.info("recaptcha_rforgotesponse_field " + response); log.info("code " + code.toString()); log.info("vote " + vote.toString()); log.info("model " + model.toString()); challenge = filterValue(challenge); response = filterValue(response); code = filterValue(code); vote = (UtilVoteCaptcha) model.get("captchaForm"); log.info("vote2--> " + vote.toString()); final String IP = getIpClient(req); //security service final SecurityOperations securityService = getServiceManager().getApplicationServices() .getSecurityService(); //check if captcha is valid final ReCaptchaResponse reCaptchaResponse = getReCaptcha().checkAnswer(req.getRemoteAddr(), challenge, response); //validation layer final ValidateOperations validation = new ValidateOperations(securityService); validation.validateCaptcha(reCaptchaResponse, result); log.info("reCaptchaResponse " + reCaptchaResponse.getErrorMessage()); log.info("reCaptchaResponse " + reCaptchaResponse.isValid()); log.info("result.hasErrors() " + result.hasErrors()); if (result.hasErrors()) { //build new reCAPTCHA final String errMsg = reCaptchaResponse.getErrorMessage(); final String html = getReCaptcha().createRecaptchaHtml(errMsg, null); vote.setCaptcha(html); vote.setCodeVote(code); model.addAttribute("captchaForm", vote); result.reject("form.problems"); //reload page. return "voteCaptcha"; } else { //Find Answer To Vote. final TweetPollSwitch tweetPoll = getTweetPollService().getTweetPollDao() .retrieveTweetsPollSwitch(code); model.addAttribute("switch", tweetPoll); //Validate Code. if (tweetPoll == null || !tweetPoll.getTweetPoll().getPublishTweetPoll()) { log.debug("tweetpoll answer not found"); return "badTweetVote"; //model.addAttribute("message", "Tweet Not Valid."); } else { // Vote try { getTweetPollService().validateIpVote(IP, tweetPoll.getTweetPoll()); getTweetPollService().tweetPollVote(tweetPoll, IP, Calendar.getInstance().getTime()); return "tweetVoted"; } catch (Exception e) { log.error("Bad tweetpoll process submit --- >" + e); return "repeatedTweetVote"; } } } }