예제 #1
0
 public static void buildDefault(String mailbox) {
   // TODO fix me
   if (MailboxHolder.get(mailbox, "INBOX") == null) {
     new MailboxBuilder(mailbox).mailbox("INBOX").subscribed().exists().build();
   }
   if (MailboxHolder.get(mailbox, "INBOX.Drafts") == null) {
     new MailboxBuilder(mailbox).mailbox("INBOX.Drafts").subscribed().exists().build();
   }
   if (MailboxHolder.get(mailbox, "INBOX.Sent") == null) {
     new MailboxBuilder(mailbox).mailbox("INBOX.Sent").subscribed().exists().build();
   }
 }
예제 #2
0
  public Mailbox build() {
    try {
      String tmpName = name;
      String path = name;
      String parent = null;

      int lastIndexOf = name.lastIndexOf(".");

      if (lastIndexOf != -1) {
        tmpName = name.substring(lastIndexOf + 1);
        parent = name.substring(0, lastIndexOf);
      }

      Mailbox mailbox = new Mailbox();

      mailbox.name = tmpName;
      mailbox.address = new InternetAddress(address);
      mailbox.path = path;
      mailbox.parent = parent;
      mailbox.subscribed = subscribed;
      mailbox.exists = exists;
      mailbox.addAll(messages);
      mailbox.error = error;

      MailboxHolder.add(mailbox);

      return mailbox;
    } catch (AddressException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
  }