public StatusWapper obtainWeibo(Timeline tm, JcUser jcUser, int page) { StatusWapper statusWapper = null; int i = 0; try { statusWapper = tm.getUserTimeline(COUNT_PER_PAGE, page, jcUser); LOG.debug(++callCount + "st call weibo api (now is userTimeline)"); } catch (WeiboException e) { LOG.error("occured a exception when obtaining weibo use weibo api" + e); LOG.error(++callCount + "st call weibo api (now is comments) cause error"); // outOfLimit = true; jcUser.setOutOfLimit(true); return null; } // download pictures and/or obtain comments List<Status> statuses = statusWapper.getStatuses(); for (i = 0; i < statuses.size(); i++) { Status s = statuses.get(i); Place place = new Place(); try { if (s.getLatitude() != -1 && s.getLongitude() != -1) s.setFormatedAddress(place.formattedAddress(s.getLatitude(), s.getLongitude())); else s.setFormatedAddress(null); } catch (Exception e) { LOG.error("occured a exception when format address " + e); LOG.error("try again"); try { if (s.getLatitude() != -1 && s.getLongitude() != -1) s.setFormatedAddress(place.formattedAddress(s.getLatitude(), s.getLongitude())); else s.setFormatedAddress(null); } catch (Exception e2) { LOG.error("occured a exception when format address " + e2); s.setFormatedAddress(null); } } if (s.getCommentsCount() > 0) s.setComments(obtainComments(s)); statuses.set(i, downloadImage(s)); // if (callCount >= limit || outOfLimit == true) if (jcUser.isOutOfLimit()) break; } LOG.debug("this time get statues count is" + statuses.size()); int index = 0; // if (callCount >= limit || outOfLimit == true) if (jcUser.isOutOfLimit()) index = i; else index = i + 1; int len = statuses.size(); int times = len - index; for (int j = 0; j < times; j++) { Status s = statuses.remove(index); LOG.debug( "removing id:" + s.getId() + ", creatAt:" + StringUtil.formatDate(s.getCreatedAt(), "yyyy-MM-dd HH:mm")); } LOG.debug("after remove get statues count is" + statuses.size()); LOG.debug("after remove get statusWapper.statues count is" + statusWapper.getStatuses().size()); return statusWapper; }