/** @see ImapHost#deleteMailbox */
public void deleteMailbox( User user, String mailboxName )
throws MailboxException, AuthorizationException
{
ImapMailbox toDelete = getMailbox( user, mailboxName, true );
if ( store.getChildren( toDelete ).isEmpty() ) {
long[] uids = toDelete.getMessageUids();
for ( int i = 0; i < uids.length; i++ ) {
long uid = uids[i];
SimpleImapMessage imapMessage = toDelete.getMessage( uid );
toDelete.deleteMessage( imapMessage.getUid() );
}
store.deleteMailbox( toDelete );
}
else {
if ( toDelete.isSelectable() ) {
// TODO delete all messages.
store.setSelectable( toDelete, false );
}
else {
throw new MailboxException( "Can't delete a non-selectable mailbox with children." );