Package com.metadot.book.connectr.server.domain

Examples of com.metadot.book.connectr.server.domain.UserAccount


      User user = twitter.verifyCredentials();
      log.info("Twitter user found:" + user.getName());
      request.getSession().removeAttribute("requestToken");
      String sid = ((Integer) user.getId()).toString();

      UserAccount u = new UserAccount(sid, AuthenticationProvider.TWITTER);
      // use screen name for uid
      u.setName(user.getScreenName());
      UserAccount connectr = new LoginHelper().loginStarts(request.getSession(), u);
      log.info("User id:" + connectr.getId().toString());

    } catch (TwitterException e) {
      e.printStackTrace();
    }
View Full Code Here


       */
      String url = "https://graph.facebook.com/me?access_token=" + token;
      log.info("requesting user info: " + url);
      resp = UrlFetcher.get(url);
      log.info("Response: " + resp);
      UserAccount connectr = extractUserInfo(resp);
      connectr = new LoginHelper().loginStarts(request.getSession(), connectr);
      log.info("User id is logged in:" + connectr.getId().toString());

      /*
       * All done. Let's go home.
       */
      response.sendRedirect(LoginHelper.getApplitionURL(request));
View Full Code Here


  private UserAccount extractUserInfo(String resp) {
    log.info("Extracting user info");
    JSONObject j;
    UserAccount u = null;
    try {
      j = new JSONObject(resp);
      String first = j.getString("first_name");
      String last = j.getString("last_name");
      String id = j.getString("id");
      log.info("User info from JSON: " + first + " " + last + " id = " + id);
      u = new UserAccount(id, AuthenticationProvider.FACEBOOK);
      u.setName(first + " " + last);
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return u;
  }
View Full Code Here

  public Boolean initiateUserFeedUpdate() {

    PersistenceManager pm = PMF.getNonTxnPm();

    try {
      UserAccount user = LoginHelper.getLoggedInUser(getThreadLocalRequest().getSession(), pm);
      Queue queue = QueueFactory.getQueue("userfeedupdates");
      // add a task to update all feeds for the friends of the given user.
      // the 'notify' parameter will trigger channel API notification
      // afterwards (if channel API is enabled)
      queue.add(url("/feedupdateuser").param("uid", user.getUniqueId()).param("notify", "true"));
    }
    catch (Exception e) {
      logger.warning(e.getMessage());
      return false;
    }
View Full Code Here

    List<String> fetchlist = new ArrayList<String>();
    StreamItem entry = null;

    try {
      // do a query that fetches the stream items based on the UserAccount id.
      UserAccount user = LoginHelper.getLoggedInUser(getThreadLocalRequest().getSession(), pm);
      Long userid = user.getId();
      String qstring = null;
      if (sdate == null) {
        qstring = " where ukeys == :u1";
      }
      else if (prior) {
View Full Code Here

    String query = "select from " + UserAccount.class.getName() + " where id == :userId";
    Query q = pm.newQuery(query);
    q.setUnique(true);

    try {
      UserAccount u = (UserAccount) q.execute(id);
      u.setLastActive(new Date());
      return u;
    } finally {
      if (localPM) {
        pm.close();
      }
View Full Code Here

      }
    }
  }

  public UserAccount loginStarts(HttpSession session, UserAccount user) {
    UserAccount aUser = UserAccount.findOrCreateUser(user);
    UserAccount u = null;

    // update user info under transactional control
    PersistenceManager pm = PMF.getTxnPm();
    Transaction tx = pm.currentTransaction();
    try {
      for (int i = 0; i < NUM_RETRIES; i++) {
        tx = pm.currentTransaction();
        tx.begin();
        u = (UserAccount) pm.getObjectById(UserAccount.class, aUser.getId());
        String channelId = ChannelServer.createChannel(u.getUniqueId());
        u.setChannelId(channelId);
        u.setLastActive(new Date());
        u.setLastLoginOn(new Date());
        try {
          tx.commit();
          // update session if successful
          session.setAttribute("userId", String.valueOf(u.getId()));
          session.setAttribute("loggedin", true);
          break;
        }
        catch (JDOCanRetryException e1) {
          if (i == (NUM_RETRIES - 1)) {
View Full Code Here

  @Override
  public UserAccountDTO getLoggedInUserDTO() {
    UserAccountDTO userDTO;
    HttpSession session = getThreadLocalRequest().getSession();

    UserAccount u = LoginHelper.getLoggedInUser(session, null);
    if (u == null)
      return null;
    userDTO = UserAccount.toDTO(u);
    return userDTO;
  }
View Full Code Here

TOP

Related Classes of com.metadot.book.connectr.server.domain.UserAccount

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.