public class TweetController {
@RequestMapping(value = "/tweet.html", method = RequestMethod.POST, params = "bean=tweet")
public ModelAndView handleRequest(@ModelAttribute("tweet") Tweet tweet,
HttpServletRequest request) throws Exception {
TwitterUser currUser = Authenticator.isValid(request);
ModelAndView mv = new ModelAndView();
if (currUser != null) {
if (tweet.getTweetMessage() != null
&& !"".equals(tweet.getTweetMessage())) {
if (tweet.getTweetMessage().length() <= 100) {
tweet.setDateCreated(new Date());
tweet.setTwitterUser(currUser);
TweetService.createTweet(tweet);
} else {
mv.addObject("tweetlengtherror",
"Not more than 100 charcters are allowed");
}
}
Set<Tweet> tweets = TweetService.getTweetStream(
currUser.getObjId(), currUser.getFollowing());
Set<TwitterUser> allUserList = TwitterUserService
.getAllUserList(currUser);
Map<String, Integer> followCount = TwitterUserService
.getFollowCount(currUser.getObjId());
int tweetCount = TwitterUserService.getTweetCount(currUser);
Tweet eTweet = new Tweet();
mv.addObject("tweet", eTweet);
mv.setViewName("twitterhomepage");
mv.addObject("tweets", tweets);