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");