*/
@Override
@PreAuthorize("hasPermission(#userFrom.id, 'USER', 'ProfilePermission.SEND_PRIVATE_MESSAGES')")
public PrivateMessage sendDraft(long id, String title, String body,
JCUser recipient, JCUser userFrom) throws NotFoundException {
PrivateMessage pm = new PrivateMessage(recipient, userFrom, title, body);
pm.setId(id);
pm.setRead(false);
pm.setStatus(PrivateMessageStatus.SENT);
this.getDao().saveOrUpdate(pm);
userDataCache.incrementNewMessageCountFor(recipient.getUsername());
securityService.deleteFromAcl(pm);
securityService.createAclBuilder().grant(GeneralPermission.READ).to(recipient).on(pm).flush();
securityService.createAclBuilder().grant(GeneralPermission.READ).to(userFrom).on(pm).flush();
if (isSendNotificationMessage(recipient)) {
mailService.sendReceivedPrivateMessageNotification(recipient, pm);
}
logger.debug("Private message(was draft) to user {} was sent. Message id={}",
recipient.getUsername(), pm.getId());
return pm;
}