@PathVariable final String action,
@PathVariable final String type,
HttpServletRequest request, HttpServletResponse response)
throws JsonGenerationException, JsonMappingException, IOException {
try {
final TypeSearchResult typeItem = TypeSearchResult.getTypeSearchResult(type);
log.debug("***************/api/survey/hashtag/{type}/{action}.json************");
if (typeItem.equals(TypeSearchResult.TWEETPOLL)) {
if ("remove".equals(action)) {
setSuccesResponse();
getTweetPollService().removeHashtagFromTweetPoll(null, null);
} else if ("add".equals(action)) {
final Map<String, Object> jsonResponse = new HashMap<String, Object>();
final HashTagBean bean = ConvertDomainBean
.convertHashTagDomain(getTweetPollService()
.addHashtagToTweetPoll(
getTweetPollService()
.getTweetPollById(id),
new HashTagBean(hashtag)));
log.debug("New TweetPoll HT Bean: "+bean);
if (bean.getHashTagName().isEmpty()) {
setFailedResponse();
} else {
jsonResponse.put("hashtag", bean);
setItemResponse(jsonResponse);
}
}
} else if (typeItem.equals(TypeSearchResult.POLL)) {
if ("remove".equals(action)) {
log.debug("Remove option has been disabled");
setSuccesResponse();
} else if ("add".equals(action)) {
final Map<String, Object> jsonResponse = new HashMap<String, Object>();
final HashTagBean bean = ConvertDomainBean
.convertHashTagDomain(getPollService()
.addHashTagToPoll(
getPollService().getPollById(id),
new HashTagBean(hashtag)));
log.debug("New TweetPoll HT Bean: " + bean);
if (bean.getHashTagName().isEmpty()) {
setFailedResponse();
} else {
jsonResponse.put("hashtag", bean);
setItemResponse(jsonResponse);
}
setSuccesResponse();
}
} else if (typeItem.equals(TypeSearchResult.SURVEY)) {
//TODO: no yet.
setSuccesResponse();
}
log.debug("***************/api/survey/hashtag/{type}/{action}.json************");
} catch (Exception e) {