use of com.zimbra.soap.type.MsgContent in project zm-mailbox by Zimbra.
the class GetMsg 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);
ItemIdFormatter ifmt = new ItemIdFormatter(zsc);
GetMsgRequest req = zsc.elementToJaxb(request);
MsgSpec msgSpec = req.getMsg();
ItemId iid = new ItemId(msgSpec.getId(), zsc);
String part = msgSpec.getPart();
MsgContent wantContent = msgSpec.getWantContent();
wantContent = wantContent == null ? MsgContent.full : wantContent;
boolean raw = msgSpec.getRaw() != null ? msgSpec.getRaw() : false;
boolean alwaysUseContentUrl = msgSpec.getUseContentUrl() != null ? msgSpec.getUseContentUrl() : false;
boolean read = msgSpec.getMarkRead() != null ? msgSpec.getMarkRead() : false;
int maxSize = msgSpec.getMaxInlinedLength() != null ? msgSpec.getMaxInlinedLength() : 0;
boolean wantHTML = msgSpec.getWantHtml() != null ? msgSpec.getWantHtml() : false;
boolean neuter = msgSpec.getNeuter() != null ? msgSpec.getNeuter() : true;
Set<String> headers = null;
for (AttributeName hdr : msgSpec.getHeaders()) {
if (headers == null)
headers = new HashSet<String>();
headers.add(hdr.getName());
}
boolean needGroupInfo = msgSpec.getNeedCanExpand() != null ? msgSpec.getNeedCanExpand() : false;
Element response = zsc.createElement(MailConstants.GET_MSG_RESPONSE);
if (iid.hasSubpart()) {
// calendar item
CalendarItem calItem = getCalendarItem(octxt, mbox, iid);
if (raw) {
throw ServiceException.INVALID_REQUEST("Cannot request RAW formatted subpart message", null);
} else {
String recurIdZ = msgSpec.getRecurIdZ();
if (recurIdZ == null) {
// If not specified, try to get it from the Invite.
int invId = iid.getSubpartId();
Invite[] invs = calItem.getInvites(invId);
if (invs.length > 0) {
RecurId rid = invs[0].getRecurId();
if (rid != null)
recurIdZ = rid.getDtZ();
}
}
ToXML.encodeInviteAsMP(response, ifmt, octxt, calItem, recurIdZ, iid, part, maxSize, wantHTML, neuter, headers, false, needGroupInfo);
}
} else {
Message msg = getMsg(octxt, mbox, iid, read);
int fields = ToXML.NOTIFY_FIELDS;
if (msgSpec.getWantImapUid()) {
fields |= Change.IMAP_UID;
}
if (msgSpec.getWantModifiedSequence()) {
fields |= Change.MODSEQ;
}
if (raw) {
ToXML.encodeMessageAsMIME(response, ifmt, octxt, msg, part, false, /* mustInline */
alwaysUseContentUrl, /* mustNotInline */
false, /* serializeType */
fields);
} else {
ToXML.encodeMessageAsMP(response, ifmt, octxt, msg, part, maxSize, wantHTML, neuter, headers, false, /* serializeType */
needGroupInfo, LC.mime_encode_missing_blob.booleanValue(), wantContent, fields);
}
}
return response;
}
Aggregations