예제 #1
0
  // 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;
  }
예제 #2
0
  // req: 24.2
  public void deleteMessageFromFolder(Message message, Folder folder) {
    Assert.notNull(message);
    Assert.isTrue(message.getId() != 0);
    Assert.notNull(folder);
    Assert.isTrue(folder.getId() != 0);

    Assert.isTrue(
        folder.getActor().equals(actorService.findByPrincipal()),
        "Only the owner of the folder can delete a message");

    folderService.removeMessage(folder, message);
  }
예제 #3
0
  /** Añade a las respectivas carpetas la primera vez que un mensaje es creado */
  private void addMessageToFolderFirst(Message message) {

    for (Folder f : message.getSender().getFolders()) {
      if (f.getName().equals("OutBox") && f.getIsSystem()) {
        folderService.addMessage(f, message);
      }
    }

    for (Actor recipient : message.getRecipients()) {
      for (Folder f : recipient.getFolders()) {
        if (f.getName().equals("InBox") && f.getIsSystem()) {
          folderService.addMessage(f, message);
        }
      }
    }
  }