/** * @see ImapHostManager#renameMailbox */ @Override public void renameMailbox(GreenMailUser user, String oldMailboxName, String newMailboxName) throws FolderException, AuthorizationException { MailFolder existingFolder = getFolder(user, oldMailboxName, true); // TODO: check permissions. // Handle case where existing is INBOX // - just create new folder, move all messages, // and leave INBOX (with children) intact. String userInboxName = getQualifiedMailboxName(user, INBOX_NAME); if (userInboxName.equals(existingFolder.getFullName())) { MailFolder newBox = createMailbox(user, newMailboxName); long[] uids = existingFolder.getMessageUids(); for (long uid : uids) { existingFolder.copyMessage(uid, newBox); } existingFolder.deleteAllMessages(); return; } store.renameMailbox(existingFolder, newMailboxName); }