private void highestModSeq(Responder responder, MetaData metaData, SelectedMailbox selected) {
   final StatusResponse untaggedOk;
   if (metaData.isModSeqPermanent()) {
     final long highestModSeq = metaData.getHighestModSeq();
     untaggedOk =
         statusResponseFactory.untaggedOk(
             HumanReadableText.HIGHEST_MOD_SEQ, ResponseCode.highestModSeq(highestModSeq));
   } else {
     untaggedOk =
         statusResponseFactory.untaggedOk(HumanReadableText.NO_MOD_SEQ, ResponseCode.noModSeq());
   }
   responder.respond(untaggedOk);
 }
  private boolean unseen(
      Responder responder, MessageUid firstUnseen, SelectedMailbox selected, MailboxSession session)
      throws MailboxException {
    if (firstUnseen != null) {
      final MessageUid unseenUid = firstUnseen;
      int msn = selected.msn(unseenUid);

      if (msn == SelectedMailbox.NO_SUCH_MESSAGE) {
        if (session.getLog().isDebugEnabled()) {
          session
              .getLog()
              .debug(
                  "No message found with uid "
                      + unseenUid
                      + " in mailbox "
                      + selected.getPath().getFullName(session.getPathDelimiter()));
        }
        return false;
      }

      final StatusResponse untaggedOk =
          statusResponseFactory.untaggedOk(HumanReadableText.unseen(msn), ResponseCode.unseen(msn));
      responder.respond(untaggedOk);
    }
    return true;
  }
 private void uidNext(Responder responder, MessageManager.MetaData metaData)
     throws MailboxException {
   final MessageUid uid = metaData.getUidNext();
   final StatusResponse untaggedOk =
       statusResponseFactory.untaggedOk(HumanReadableText.UIDNEXT, ResponseCode.uidNext(uid));
   responder.respond(untaggedOk);
 }
 private void uidValidity(Responder responder, MessageManager.MetaData metaData)
     throws MailboxException {
   final long uidValidity = metaData.getUidValidity();
   final StatusResponse untaggedOk =
       statusResponseFactory.untaggedOk(
           HumanReadableText.UID_VALIDITY, ResponseCode.uidValidity(uidValidity));
   responder.respond(untaggedOk);
 }
 private void taggedOk(
     Responder responder,
     String tag,
     ImapCommand command,
     MetaData metaData,
     HumanReadableText text) {
   final boolean writeable = metaData.isWriteable() && !openReadOnly;
   final ResponseCode code;
   if (writeable) {
     code = ResponseCode.readWrite();
   } else {
     code = ResponseCode.readOnly();
   }
   final StatusResponse taggedOk = statusResponseFactory.taggedOk(tag, command, text, code);
   responder.respond(taggedOk);
 }
  /**
   * @see
   *     org.apache.james.imap.processor.AbstractMailboxProcessor#doProcess(org.apache.james.imap.api.message.request.ImapRequest,
   *     org.apache.james.imap.api.process.ImapSession, java.lang.String,
   *     org.apache.james.imap.api.ImapCommand,
   *     org.apache.james.imap.api.process.ImapProcessor.Responder)
   */
  protected void doProcess(
      M request, ImapSession session, String tag, ImapCommand command, Responder responder) {
    final String mailboxName = request.getMailboxName();
    try {
      final MailboxPath fullMailboxPath =
          PathConverter.forSession(session).buildFullPath(mailboxName);

      respond(tag, command, session, fullMailboxPath, request, responder);

    } catch (MailboxNotFoundException e) {
      session.getLog().debug("Select failed as mailbox does not exist " + mailboxName, e);
      responder.respond(
          statusResponseFactory.taggedNo(tag, command, HumanReadableText.FAILURE_NO_SUCH_MAILBOX));
    } catch (MailboxException e) {
      session.getLog().info("Select failed for mailbox " + mailboxName, e);
      no(command, tag, responder, HumanReadableText.SELECT);
    }
  }