Commits

dianmora committed 80b3f17

Comments (0)

Files changed (1)

encuestame-mvc/src/main/java/org/encuestame/mvc/controller/json/survey/TweetPollJsonController.java

             if(!tweetPoll.getPublishTweetPoll()){
             log.debug("action ANSWER--->"+type);
             if ("add".equals(type)) {
-                final QuestionAnswerBean answerBean = new QuestionAnswerBean(answer);
-                answerBean.setShortUrlType(ShortUrlProvider.get(shortUrl));
-                log.debug("new answer bean:{ "+answerBean.toString());
-                final TweetPollSwitch tweetPollSwitch = getTweetPollService()
-                      .createTweetPollQuestionAnswer(answerBean, tweetPoll, request);
-                log.debug("new answer bean DOMAIN "+tweetPollSwitch.toString());
-                //log.debug("action questionAnswer "+questionAnswer);
-                jsonResponse.put("newAnswer", ConvertDomainBean.convertTweetPollSwitchToBean(tweetPollSwitch));
-                setItemResponse(jsonResponse);
+            	if((answer.isEmpty()) || (answer == null)){
+            		   throw new EnmeFailOperation("Answer can not valid");
+            	} else {
+            		 final QuestionAnswerBean answerBean = new QuestionAnswerBean(answer);
+                     answerBean.setShortUrlType(ShortUrlProvider.get(shortUrl));
+                     log.debug("new answer bean:{ "+answerBean.toString());
+                     final TweetPollSwitch tweetPollSwitch = getTweetPollService()
+                           .createTweetPollQuestionAnswer(answerBean, tweetPoll, request);
+                     log.debug("new answer bean DOMAIN "+tweetPollSwitch.toString());
+                     //log.debug("action questionAnswer "+questionAnswer);
+                     jsonResponse.put("newAnswer", ConvertDomainBean.convertTweetPollSwitchToBean(tweetPollSwitch));
+                     setItemResponse(jsonResponse);
+            	}
+               
             } else if("remove".equals(type)) {
                 getTweetPollService().removeQuestionAnswer(getTweetPollService().getQuestionAnswerById(answerId));
                 setSuccesResponse();