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 inbox = existingFolder;
MailFolder newBox = createMailbox(user, newMailboxName);
long[] uids = inbox.getMessageUids();
for (int i = 0; i < uids.length; i++) {
long uid = uids[i];
inbox.copyMessage(uid, newBox);
}