@Override
protected void doProcess(DeleteRequest request, ImapSession session, String tag, ImapCommand command, Responder responder) {
final MailboxPath mailboxPath = PathConverter.forSession(session).buildFullPath(request.getMailboxName());
try {
final SelectedMailbox selected = session.getSelected();
if (selected != null && selected.getPath().equals(mailboxPath)) {
session.deselect();
}
final MailboxManager mailboxManager = getMailboxManager();
mailboxManager.deleteMailbox(mailboxPath, ImapSessionUtils.getMailboxSession(session));
unsolicitedResponses(session, responder, false);
okComplete(command, tag, responder);
} catch (MailboxNotFoundException e) {
LOGGER.debug("Delete failed for mailbox {} as it doesn't exist", mailboxPath, e);
no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX);
} catch (TooLongMailboxNameException e) {
LOGGER.debug("The mailbox name length is over limit: {}", mailboxPath.getName(), e);
taggedBad(command, tag, responder, HumanReadableText.FAILURE_MAILBOX_NAME);
} catch (MailboxException e) {
LOGGER.error("Delete failed for mailbox {}", mailboxPath, e);
no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
}
}