@Override
 public void afterFiltering() throws ServiceException {
   if (filed && !kept) {
     ZimbraLog.filter.info(
         "Deleting original message %d after filing to another folder.", messageId);
     mailbox.delete(octxt, messageId, MailItem.Type.MESSAGE);
   }
 }
Beispiel #2
0
  /**
   * Delete all DELE'ed messages and return number deleted. Optionally mark RETR'ed messages as read
   * if the delete option is "read".
   *
   * @throws Pop3CmdException the messages were partially deleted
   */
  int expungeDeletes() throws ServiceException, Pop3CmdException {
    Mailbox mbox = MailboxManager.getInstance().getMailboxById(id);
    int count = 0;
    int failed = 0;
    for (Pop3Message p3msg : messages) {
      if (p3msg.isDeleted()) {
        try {
          switch (deleteOption) {
            case keep: // Leave DELE'ed messages in Inbox, and flag them as POPED.
              updateFlags(mbox, p3msg.getId(), true, false);
              break;
            case read: // Leave DELE'ed messages in Inbox, and flag them as POPED and READ.
              updateFlags(mbox, p3msg.getId(), true, true);
              break;
            case trash: // Move DELE'ed messages to Trash, and flag them as POPED and READ.
              updateFlags(mbox, p3msg.getId(), true, true);
              mbox.move(opContext, p3msg.getId(), MailItem.Type.MESSAGE, Mailbox.ID_FOLDER_TRASH);
              break;
            case delete: // Hard-delete DELE'ed messages.
              mbox.delete(opContext, p3msg.getId(), MailItem.Type.MESSAGE);
              break;
            default:
              assert false : deleteOption;
          }
          count++;
        } catch (ServiceException e) {
          ZimbraLog.pop.warn("Failed to expunge delete", e);
          failed++;
        }
        numDeleted--;
        deletedSize -= p3msg.getSize();
      } else if (p3msg.isRetrieved()) {
        try {
          switch (deleteOption) {
            case read: // Flag RETR'ed messages as READ.
              updateFlags(mbox, p3msg.getId(), false, true);
              break;
          }
        } catch (ServiceException e) {
          ZimbraLog.pop.warn("Failed to update flags", e);
        }
      }
    }

    if (count > 0) {
      try {
        mbox.resetRecentMessageCount(opContext);
      } catch (ServiceException e) {
        ZimbraLog.pop.info("error resetting mailbox recent message count", e);
      }
    }
    if (failed > 0) {
      throw new Pop3CmdException("deleted " + count + "/" + (count + failed) + " message(s)");
    }
    return count;
  }
 @Override
 public void discard() throws ServiceException {
   ZimbraLog.filter.info("Discarding existing message with id %d.", messageId);
   mailbox.delete(octxt, messageId, MailItem.Type.MESSAGE);
   filtered = true;
 }