if ((currentUser != null) && !statusUser.getDomain().equals(currentUser.getDomain())) {
throw new DomainViolationException("User " + currentUser + " tried to access " +
" status : " + abstractStatus);
}
StatusDTO statusDTO = new StatusDTO();
statusDTO.setStatusId(abstractStatus.getStatusId());
statusDTO.setStatusDate(abstractStatus.getStatusDate());
statusDTO.setGeoLocalization(abstractStatus.getGeoLocalization());
statusDTO.setActivated(statusUser.getActivated());
StatusType type = abstractStatus.getType();
if (type == null) {
statusDTO.setType(StatusType.STATUS);
} else {
statusDTO.setType(abstractStatus.getType());
}
if (abstractStatus.getType().equals(StatusType.SHARE)) {
Share share = (Share) abstractStatus;
AbstractStatus originalStatus = statusRepository.findStatusById(share.getOriginalStatusId());
if (originalStatus != null) { // Find the original status
statusDTO.setTimelineId(share.getStatusId());
statusDTO.setSharedByUsername(share.getUsername());
statusUser = userService.getUserByLogin(originalStatus.getLogin());
addStatusToLine(statuses, statusDTO, originalStatus, statusUser, usergroups, favoriteLine);
} else {
log.debug("Original status has been deleted");
}
} else if (abstractStatus.getType().equals(StatusType.MENTION_SHARE)) {
MentionShare mentionShare = (MentionShare) abstractStatus;
AbstractStatus originalStatus = statusRepository.findStatusById(mentionShare.getOriginalStatusId());
if (originalStatus != null) { // Find the status that was shared
statusDTO.setTimelineId(mentionShare.getStatusId());
statusDTO.setSharedByUsername(mentionShare.getUsername());
statusUser = userService.getUserByLogin(mentionShare.getLogin());
addStatusToLine(statuses, statusDTO, originalStatus, statusUser, usergroups, favoriteLine);
} else {
log.debug("Mentioned status has been deleted");
}
} else if (abstractStatus.getType().equals(StatusType.MENTION_FRIEND)) {
MentionFriend mentionFriend = (MentionFriend) abstractStatus;
statusDTO.setTimelineId(mentionFriend.getStatusId());
statusDTO.setSharedByUsername(mentionFriend.getUsername());
statusUser = userService.getUserByLogin(mentionFriend.getFollowerLogin());
statusDTO.setFirstName(statusUser.getFirstName());
statusDTO.setLastName(statusUser.getLastName());
statusDTO.setAvatar(statusUser.getAvatar());
statusDTO.setUsername(statusUser.getUsername());
statuses.add(statusDTO);
} else if (abstractStatus.getType().equals(StatusType.ANNOUNCEMENT)) {
Announcement announcement = (Announcement) abstractStatus;
AbstractStatus originalStatus = statusRepository.findStatusById(announcement.getOriginalStatusId());
if (originalStatus != null) { // Find the status that was announced
statusDTO.setTimelineId(announcement.getStatusId());
statusDTO.setSharedByUsername(announcement.getUsername());
statusUser = userService.getUserByLogin(originalStatus.getLogin());
addStatusToLine(statuses, statusDTO, originalStatus, statusUser, usergroups, favoriteLine);
} else {
log.debug("Announced status has been deleted");
}
} else { // Normal status
statusDTO.setTimelineId(abstractStatus.getStatusId());
addStatusToLine(statuses, statusDTO, abstractStatus, statusUser, usergroups, favoriteLine);
}
} else {
log.debug("Deleted user : {}", abstractStatus.getLogin());
}
} else {
log.debug("Deleted status : {}", statusId);
}
}
for(StatusDTO statusDTO : statuses)
statusDTO.setShareByMe(shareByMe(statusDTO));
return statuses;
}