Package com.simpletwitter.models

Examples of com.simpletwitter.models.TwitterUser


public class TwitterUserProfileController {
  protected final Log logger = LogFactory.getLog(getClass());

  @RequestMapping(value = "/twitteruser.html", method = RequestMethod.GET)
  public ModelAndView listAllUsers(HttpServletRequest request) {
    TwitterUser currUser = Authenticator.isValid(request);
    ModelAndView mv = new ModelAndView();
    if (currUser != null) {
      Set<TwitterUser> allUserList = TwitterUserService
          .getAllUserList(currUser);
      mv.setViewName("twitteruserprofile");
View Full Code Here


  }

  @RequestMapping(value = "/twitteruser.html", method = RequestMethod.GET, params = "objid")
  public ModelAndView viewUser(@RequestParam(value = "objid") String objId,
      HttpServletRequest request) {
    TwitterUser currUser = Authenticator.isValid(request);
    ModelAndView mv = new ModelAndView();
    if (currUser != null) {
      TwitterUser tuser = TwitterUserService.getUser(Long.valueOf(objId));
      Set<TwitterUser> allUserList = TwitterUserService
          .getAllUserList(currUser);
      Set<Tweet> tweets = TweetService.getTweets(Long.valueOf(objId));
      mv.setViewName("twitteruserprofile");
      mv.addObject("fuser", tuser);
View Full Code Here

  @RequestMapping(value = "/follow.html", method = RequestMethod.POST, params = "bean=fuser")
  public ModelAndView handleRequest(
      @ModelAttribute("user") TwitterUser tuser,
      HttpServletRequest request) throws Exception {
    TwitterUser currUser = Authenticator.isValid(request);
    ModelAndView mv = new ModelAndView();
    if (currUser != null) {
      Long objId = tuser.getObjId();
      TwitterUser fuser = TwitterUserService.getUser(objId);
      if (!currUser.equals(fuser)) {
        Set<TwitterUser> followers = fuser.getFollowers();
        if (!followers.add(currUser)) {
          followers.remove(currUser);
        }
        TwitterUserService.updateUser(fuser);
        currUser = TwitterUserService.getUser(currUser.getObjId());
View Full Code Here

public class TweetServiceTest {

  @Test
  public void test() {
    TwitterUser user = TwitterUserService.getUser(3L);
    Set<TwitterUser> following = user.getFollowing();
    Set<Tweet> tweetStream = TweetService.getTweetStream(3L, following);
    for (Tweet tweet : tweetStream) {
      System.out.println(tweet.getTwitterUser().getObjId() + "date: "
          + tweet.getDateCreated());
    }
View Full Code Here

  @RequestMapping(method = RequestMethod.POST, params = "bean=TwitterUser")
  public ModelAndView handleRequest(
      @ModelAttribute("TwitterUser") TwitterUser tuser,
      HttpServletRequest request) throws Exception {
    ModelAndView mv = new ModelAndView();
    TwitterUser validateUser = LoginService.validateUser(tuser);
    if (validateUser != null) {
      saveUserToSession(request, validateUser);
      forwardToHomePage(mv, validateUser);
    } else {
      loginFailed(mv, "Username password combination does not match");
View Full Code Here

  @RequestMapping(method = RequestMethod.GET)
  public ModelAndView handleGetRequest(HttpServletRequest request)
      throws Exception {
    ModelAndView mv = new ModelAndView();
    HttpSession session = request.getSession();
    TwitterUser tuser = (TwitterUser) session.getAttribute("twitteruser");
    if (tuser != null) {
      forwardToHomePage(mv, tuser);
    } else {
      loginFailed(mv, null);
    }
View Full Code Here

    mv.addObject("followcount", followCount);
    mv.addObject("tweetcount", tweetCount);
  }

  private void loginFailed(ModelAndView mv, String errorMsg) {
    TwitterUser tuser = new TwitterUser();
    mv.addObject("TwitterUser", tuser);
    if (errorMsg != null) {
      mv.addObject("errormsg", errorMsg);
    }
    mv.setViewName("loginorregister");
View Full Code Here

public class DatabaseManagerTest {

  @Test
  public void test() {
    DatabaseManager da = DatabaseManager.getInstance();
    TwitterUser tu = new TwitterUser();
    tu.setUsername("kp");
    tu.setPassword("kp");
    tu.setDateCreated(new Date());
    TwitterUser createObject = da.createObject(tu);
    System.out.println(createObject);
  }
View Full Code Here

public class TwitterUserServiceTest {

  @Test
  public void test() {
    TwitterUser t = null;
    Set<TwitterUser> allUserList = TwitterUserService.getAllUserList(t);
    for (TwitterUser twitterUser : allUserList) {
      System.out.println(twitterUser);
    }
  }
View Full Code Here

    System.out.println(followCount);
  }

  @Test
  public void testfollowrelation() {
    TwitterUser user = TwitterUserService.getUser(1L);
    TwitterUser user2 = TwitterUserService.getUser(3L);
    Set<TwitterUser> following = user2.getFollowing();
    TwitterUser fuser = TwitterUserService.getUser(7L);
    Set<TwitterUser> followers = fuser.getFollowers();
    if (!followers.add(user2)) {
      followers.remove(user2);
    }
    TwitterUserService.updateUser(fuser);
    user2 = TwitterUserService.getUser(3L);
View Full Code Here

TOP

Related Classes of com.simpletwitter.models.TwitterUser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.