Package com.appspot.piment.model

Examples of com.appspot.piment.model.WeiboMap


  }

  public List<WeiboMap> syncUserMessage(UserMap user) {

  // 前回同期化された最後の履歴レコードを取り出す
  WeiboMap lastestCreateWeiboMap = weiboMapDao.getNewestItem(user.getId(), WeiboSource.Sina);

  // sinaから前回の同期化以降対象ユーザが発表した新メッセージを取得する
  List<Status> newUserMessages = sinaWeiboApi.getUserTimeline(lastestCreateWeiboMap != null ? lastestCreateWeiboMap.getSinaWeiboId() : null, null);

  log.info("Sina message --> 同期化件数:" + newUserMessages.size());

  // メッセージ単位で同期化処理を行う
  Status status = null;
  try {
    for (int i = newUserMessages.size() - 1; i >= 0; i--) {
    status = newUserMessages.get(i);
    if (this.weiboMapDao.getBySinaWeiboId(status.getId(), user.getId()) == null) {
      syncSinaUserMessage(user, status, new WeiboMap());
    } else {
      log.info("Sina message --> [" + status.getId() + "] 同期化済みでスキップする。");
    }
    }
  } catch (ApiLimitedException e) {
View Full Code Here


    }
    }

    Long sinaWeiboId = comment.getStatus().getId();

    WeiboMap weiboMap = this.weiboMapDao.getBySinaWeiboId(sinaWeiboId, user.getId());

    if (weiboMap != null && StringUtils.isNotBlank(String.valueOf(weiboMap.getTqqWeiboId()))) {

    Response response = null;
    Throwable throwable = null;

    TqqWeiboApi tqqApi = null;

    String commentUserId = String.valueOf(comment.getUser().getId());
    String tqqWeiboId = String.valueOf(weiboMap.getTqqWeiboId());
    String commentMsg = comment.getText();

    if (commentUserId.equals(this.tqqWeiboApi.getUsetId())) {
      tqqApi = this.tqqWeiboApi;
    } else {
View Full Code Here

      String retweetId = null;
      Status retweetedStatus = status.getRetweeted_status();
      log.info("Sina Message --> Retweet [" + retweetedStatus.getId() + "]");

      WeiboMap processedWeibo = this.weiboMapDao.getBySinaWeiboId(retweetedStatus.getId(), userMap.getId());
      if (processedWeibo != null) {
        retweetId = String.valueOf(processedWeibo.getTqqWeiboId());
      } else {

        originalMsg = sinaWeiboApi.getOriginalMsg(retweetedStatus.getText().trim());

        StringBuilder retweetMsg = new StringBuilder();
        retweetMsg.append("Sina@").append(retweetedStatus.getUser().getName()).append("//");
        retweetMsg.append(originalMsg);
       
        // 長調整
        if(retweetMsg.length() > 140){
          String sinaURL = "... " + SinaWeiboApi.getStatusPageURL(retweetedStatus.getUser().getId(), retweetedStatus.getId());
          retweetMsg = retweetMsg.delete((140 - sinaURL.length()), retweetMsg.length());
          retweetMsg.append(sinaURL);
        }
       
        try {
          middleResponse = tqqRobotWeiboApi.sendMessage(originalMsg, retweetMsg.toString(), retweetedStatus.getBmiddle_pic(), null);
        } catch (Exception e) {
          middleResponse = new Response();
          middleResponse.setMsg(e.getMessage());
          log.warning("Retweet --> 例外!!!" + e.getMessage());
        }
        log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~X");
        if (middleResponse != null && middleResponse.isOK()) {
        log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Y");
        log.info("Sina Message --> Retweet Successed!!!");
        // データストアへ保存する

        // 同期化履歴レコードの初期化
        WeiboMap retweetWeiboMap = new WeiboMap();
        retweetWeiboMap.setSinaWeiboId(retweetedStatus.getId());
        retweetWeiboMap.setTqqWeiboId(Long.valueOf(middleResponse.getData().getId()));
        retweetWeiboMap.setUserMapId(null);
        retweetWeiboMap.setSource(WeiboSource.Sina);
        retweetWeiboMap.setStatus(WeiboStatus.SUCCESSED);
        weiboMapDao.save(retweetWeiboMap);
        retweetId = middleResponse.getData().getId();
        }
      }
      log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Q");
View Full Code Here

  public List<WeiboMap> syncUserMessage(UserMap user) {

  try {

    // 前回同期化された最後の履歴レコードを取り出す
    WeiboMap lastestCreateWeiboMap = weiboMapDao.getNewestItem(user.getId(), WeiboSource.Tqq);

    // sinaから前回の同期化以降対象ユーザが発表した新メッセージを取得する
    List<MessageResponse> newUserMessages = tqqWeiboApi.getUserTimeline(lastestCreateWeiboMap != null ? lastestCreateWeiboMap.getTqqWeiboId() : null);

    log.info("Tqq message --> 同期化件数:" + newUserMessages.size());

    // メッセージ単位で同期化処理を行う
    MessageResponse msgResponse = null;
    for (int i = newUserMessages.size() - 1; i >= 0; i--) {
    msgResponse = newUserMessages.get(i);

    if (this.weiboMapDao.getByTqqWeiboId(Long.valueOf(msgResponse.getData().getId())) == null) {
      syncTqqUserMessage(user, msgResponse, new WeiboMap());
    } else {
      log.info("Tqq message --> [" + msgResponse.getData().getId() + "] 同期化済みでスキップする。");
    }
    }
View Full Code Here

TOP

Related Classes of com.appspot.piment.model.WeiboMap

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.