if (!originalFolder.getNewFolder().mkdir())
throw new IOException("Could not create folder " + originalFolder.getNewFolder());
if (!originalFolder.getTmpFolder().mkdir())
throw new IOException("Could not create folder " + originalFolder.getTmpFolder());
} catch (IOException e) {
throw new MailboxException("Failed to save Mailbox " + mailbox, e);
}
}
else {
if (!originalFolder.getRootFile().renameTo(folder.getRootFile()))
throw new MailboxException("Failed to save Mailbox " + mailbox,
new IOException("Could not rename folder " + originalFolder));
}
}
} catch (MailboxNotFoundException e) {
// it cannot be found and is thus new
MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
if (!folder.exists()) {
boolean success = folder.getRootFile().exists();
if (!success) success = folder.getRootFile().mkdirs();
if (!success)
throw new MailboxException("Failed to save Mailbox " + mailbox);
success = folder.getCurFolder().mkdir();
success = success && folder.getNewFolder().mkdir();
success = success && folder.getTmpFolder().mkdir();
if (!success)
throw new MailboxException("Failed to save Mailbox " + mailbox, new IOException("Needed folder structure can not be created"));
}
try {
folder.setUidValidity(mailbox.getUidValidity());
} catch (IOException ioe) {
throw new MailboxException("Failed to save Mailbox " + mailbox, ioe);
}
}
}