* org.apache.james.imap.api.process.ImapProcessor.Responder)
*/
protected void doProcess(FetchRequest request, final ImapSession session, String tag, ImapCommand command, final Responder responder) {
final boolean useUids = request.isUseUids();
final IdRange[] idSet = request.getIdSet();
final FetchData fetch = request.getFetch();
try {
final Long changedSince = fetch.getChangedSince();
final MessageManager mailbox = getSelectedMailbox(session);
if (mailbox == null) {
throw new MailboxException("Session not in SELECTED state");
}
final boolean vanished = fetch.getVanished();
if (vanished && !EnableProcessor.getEnabledCapabilities(session).contains(ImapConstants.SUPPORTS_QRESYNC)) {
taggedBad(command, tag, responder, HumanReadableText.QRESYNC_NOT_ENABLED);
return;
}
if (vanished && changedSince == -1) {
taggedBad(command, tag, responder, HumanReadableText.QRESYNC_VANISHED_WITHOUT_CHANGEDSINCE);
return;
}
final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
MetaData metaData = mailbox.getMetaData(false, mailboxSession, org.apache.james.mailbox.MessageManager.MetaData.FetchGroup.NO_COUNT);
if (fetch.getChangedSince() != -1 || fetch.isModSeq()) {
// Enable CONDSTORE as this is a CONDSTORE enabling command
condstoreEnablingCommand(session, responder, metaData, true);
}
List<MessageRange> ranges = new ArrayList<MessageRange>();
for (int i = 0; i < idSet.length; i++) {
MessageRange messageSet = messageRange(session.getSelected(), idSet[i], useUids);
if (messageSet != null) {
MessageRange normalizedMessageSet = normalizeMessageRange(session.getSelected(), messageSet);
MessageRange batchedMessageSet = MessageRange.range(normalizedMessageSet.getUidFrom(), normalizedMessageSet.getUidTo());
ranges.add(batchedMessageSet);
}
}
if (vanished ) {
// TODO: From the QRESYNC RFC it seems ok to send the VANISHED responses after the FETCH Responses.
// If we do so we could prolly save one mailbox access which should give use some more speed up
respondVanished(mailboxSession, mailbox, ranges, changedSince, metaData, responder);
}
// if QRESYNC is enable its necessary to also return the UID in all cases
if (EnableProcessor.getEnabledCapabilities(session).contains(ImapConstants.SUPPORTS_QRESYNC)) {
fetch.setUid(true);
}
processMessageRanges(session, mailbox, ranges, fetch, useUids, mailboxSession, responder);
// Don't send expunge responses if FETCH is used to trigger this