public Message findOne(int messageId) { Message result; result = messageRepository.findOne(messageId); Assert.notNull(result, "message.findOne.UnknownID"); checkActor(result); return result; }
// req: 24.1 public Collection<Message> findAllByFolder(Folder folder) { Assert.notNull(folder); Assert.isTrue( folder.getActor().equals(actorService.findByPrincipal()), "Only the owner of the folder can display them"); Collection<Message> result; result = messageRepository.findAllByFolderId(folder.getId()); return result; }
// req: 24.2 private Message save(Message message) { Assert.notNull(message); Assert.isTrue( message.getSender().equals(actorService.findByPrincipal()), "Only the sender can save the message"); message.setMoment(new Date()); Message result; result = messageRepository.save(message); return result; }