@Test public void processShouldResponseNoWithFailureWhenMailboxDoesNotExist() throws Exception { doThrow(MailboxNotFoundException.class).when(mockMailboxManager).getAllAnnotations(eq(inbox), eq(mailboxSession)); when(mockStatusResponseFactory.taggedNo(any(String.class), any(ImapCommand.class), any(HumanReadableText.class), any(ResponseCode.class))) .thenReturn(statusResponse); processor.process(annotationRequestBuilder.build(), mockResponder, mockImapSession); verify(mockStatusResponseFactory, times(1)).taggedNo(any(String.class), any(ImapCommand.class), humanTextCaptor.capture(), captorResponsecode.capture()); verify(mockResponder).respond(statusResponse); verifyNoMoreInteractions(mockResponder); assertThat(humanTextCaptor.getAllValues()).containsOnly(HumanReadableText.FAILURE_NO_SUCH_MAILBOX); assertThat(captorResponsecode.getAllValues()).containsOnly(ResponseCode.tryCreate()); }
/** * Issues a TRY CREATE response. * * @param session * not null * @param tag * not null * @param command * not null * @param responder * not null * @param e * not null */ private void tryCreate(ImapSession session, String tag, ImapCommand command, Responder responder, MailboxNotFoundException e) { final Logger logger = session.getLog(); if (logger.isDebugEnabled()) { logger.debug("Cannot open mailbox: ", e); } no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, StatusResponse.ResponseCode.tryCreate()); }
/** * Issues a TRY CREATE response. * * @param session * not null * @param tag * not null * @param command * not null * @param responder * not null * @param e * not null */ private void tryCreate(ImapSession session, String tag, ImapCommand command, Responder responder, MailboxNotFoundException e) { LOGGER.debug("Cannot open mailbox: ", e); no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, StatusResponse.ResponseCode.tryCreate()); }
no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, ResponseCode.tryCreate()); } else {
no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, StatusResponse.ResponseCode.tryCreate()); } else {
@Override protected void doProcess(SetAnnotationRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) { final MailboxManager mailboxManager = getMailboxManager(); final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session); final String mailboxName = message.getMailboxName(); try { MailboxPath mailboxPath = PathConverter.forSession(session).buildFullPath(mailboxName); mailboxManager.updateAnnotations(mailboxPath, mailboxSession, message.getMailboxAnnotations()); okComplete(command, tag, responder); } catch (MailboxNotFoundException e) { LOGGER.info("{} failed for mailbox {}", command.getName(), mailboxName, e); no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, StatusResponse.ResponseCode.tryCreate()); } catch (AnnotationException e) { LOGGER.info("{} failed for mailbox {}", command.getName(), mailboxName, e); no(command, tag, responder, new HumanReadableText(HumanReadableText.MAILBOX_ANNOTATION_KEY, e.getMessage())); } catch (MailboxException e) { LOGGER.error("{} failed for mailbox {}", command.getName(), mailboxName, e); no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING); } }
@Override protected void doProcess(GetAnnotationRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) { try { proceed(message, session, tag, command, responder); } catch (MailboxNotFoundException e) { LOGGER.info("The command: {} is failed because not found mailbox {}", command.getName(), message.getMailboxName()); no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, ResponseCode.tryCreate()); } catch (MailboxException e) { LOGGER.error("GetAnnotation on mailbox {} failed for user {}", message.getMailboxName(), ImapSessionUtils.getUserName(session), e); no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING); } }