use of com.zimbra.soap.mail.message.OpenIMAPFolderRequest in project zm-mailbox by Zimbra.
the class ZMailbox method fetchImapFolderChunk.
@VisibleForTesting
public OpenIMAPFolderResponse fetchImapFolderChunk(OpenIMAPFolderParams params) throws ServiceException {
OpenIMAPFolderRequest req = new OpenIMAPFolderRequest();
req.setFolderId(params.getFolderId().toString());
req.setLimit(params.getLimit());
if (params.getCursorId() != null) {
req.setCursor(new ImapCursorInfo(params.getCursorId()));
}
return invokeJaxb(req);
}
use of com.zimbra.soap.mail.message.OpenIMAPFolderRequest in project zm-mailbox by Zimbra.
the class OpenImapFolder method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Mailbox mbox = getRequestedMailbox(zsc);
OperationContext octxt = getOperationContext(zsc, context);
OpenIMAPFolderRequest req = zsc.elementToJaxb(request);
OpenIMAPFolderResponse resp = new OpenIMAPFolderResponse();
ItemId folderId = new ItemId(req.getFolderId(), zsc);
if (!folderId.belongsTo(mbox)) {
ZimbraLog.imap.info("Proxying request: OpenImapFolder folder=%s", folderId);
return proxyRequest(request, context, folderId.getAccountId());
}
int limit = req.getLimit();
ImapCursorInfo cursor = req.getCursor();
Integer cursorMsgId = null;
if (cursor != null) {
cursorMsgId = new ItemId(cursor.getId(), mbox.getAccountId()).getId();
}
Pair<List<ImapMessage>, Boolean> openFolderResults = mbox.openImapFolder(octxt, folderId.getId(), limit, cursorMsgId);
List<ImapMessage> msgs = openFolderResults.getFirst();
boolean hasMore = openFolderResults.getSecond();
Integer msgId = null;
for (ImapMessage msg : msgs) {
msgId = msg.getMsgId();
int imapUid = msg.getImapUid();
String type = msg.getType().toString();
int flags = msg.getFlags();
String tags = msg.getTags() == null ? null : Joiner.on(",").join(msg.getTags());
ImapMessageInfo info = new ImapMessageInfo(msgId, imapUid, type, flags, tags);
resp.addImapMessageInfo(info);
}
if (hasMore && msgId != null) {
resp.setCursor(new ImapCursorInfo(msgId.toString()));
}
resp.setHasMore(hasMore);
return zsc.jaxbToElement(resp);
}
Aggregations