!abstractStatus.getType().equals(StatusType.STATUS) &&
!abstractStatus.getType().equals(StatusType.SHARE) &&
!abstractStatus.getType().equals(StatusType.ANNOUNCEMENT)) {
log.debug("Cannot reply to a status of this type");
throw new ReplyStatusException();
}
if (abstractStatus != null &&
abstractStatus.getType().equals(StatusType.SHARE)) {
log.debug("Replacing the share by the original status");
Share share = (Share) abstractStatus;
AbstractStatus abstractRealStatus = statusRepository.findStatusById(share.getOriginalStatusId());
abstractStatus = abstractRealStatus;
} else if (abstractStatus != null &&
abstractStatus.getType().equals(StatusType.ANNOUNCEMENT)) {
log.debug("Replacing the announcement by the original status");
Announcement announcement = (Announcement) abstractStatus;
AbstractStatus abstractRealStatus = statusRepository.findStatusById(announcement.getOriginalStatusId());
abstractStatus = abstractRealStatus;
}
Status status = (Status) abstractStatus;
Group group = null;
if (status.getGroupId() != null) {
group = groupService.getGroupById(status.getDomain(), status.getGroupId());
if (group.isArchivedGroup()) {
throw new ArchivedGroupException();
}
}
if (!status.getReplyTo().equals("")) {
log.debug("Replacing the status by the status at the origin of the disucssion");
// Original status is also a reply, replying to the real original status instead
AbstractStatus abstractRealOriginalStatus = statusRepository.findStatusById(status.getDiscussionId());
if (abstractRealOriginalStatus == null ||
!abstractRealOriginalStatus.getType().equals(StatusType.STATUS)) {
throw new ReplyStatusException();
}
Status realOriginalStatus = (Status) abstractRealOriginalStatus;
Status replyStatus = createStatus(
content,