use of com.zimbra.cs.service.mail.ParseMimeMessage.InviteParserResult in project zm-mailbox by Zimbra.
the class SetCalendarItem method getSetCalendarItemData.
static SetCalendarItemData getSetCalendarItemData(ZimbraSoapContext zsc, OperationContext octxt, Account acct, Mailbox mbox, Element e, ParseMimeMessage.InviteParser parser) throws ServiceException {
String partStatStr = e.getAttribute(MailConstants.A_CAL_PARTSTAT, IcalXmlStrMap.PARTSTAT_NEEDS_ACTION);
// <M>
Element msgElem = e.getElement(MailConstants.E_MSG);
// check to see whether the entire message has been uploaded under separate cover
String attachmentId = msgElem.getAttribute(MailConstants.A_ATTACHMENT_ID, null);
Element contentElement = msgElem.getOptionalElement(MailConstants.E_CONTENT);
InviteParserResult ipr = null;
MimeMessage mm = null;
if (attachmentId != null) {
ParseMimeMessage.MimeMessageData mimeData = new ParseMimeMessage.MimeMessageData();
mm = SendMsg.parseUploadedMessage(zsc, attachmentId, mimeData);
} else if (contentElement != null) {
mm = ParseMimeMessage.importMsgSoap(msgElem);
} else {
CalSendData dat = handleMsgElement(zsc, octxt, msgElem, acct, mbox, parser);
mm = dat.mMm;
ipr = parser.getResult();
}
if (ipr == null && msgElem.getOptionalElement(MailConstants.E_INVITE) != null) {
ipr = parser.parse(zsc, octxt, mbox.getAccount(), msgElem.getElement(MailConstants.E_INVITE));
// in the <inv> but not in mime parts.
if (ipr != null && ipr.mInvite != null && mm != null) {
String desc = Invite.getDescription(mm, MimeConstants.CT_TEXT_PLAIN);
String descHtml = Invite.getDescription(mm, MimeConstants.CT_TEXT_HTML);
if ((desc != null && desc.length() > 0) || (descHtml != null && descHtml.length() > 0)) {
ipr.mInvite.setDescription(desc, descHtml);
}
}
}
ParsedMessage pm = new ParsedMessage(mm, mbox.attachmentsIndexingEnabled());
Invite inv = (ipr == null ? null : ipr.mInvite);
if (inv == null || inv.getDTStamp() == -1) {
//zdsync if -1 for 4.5 back compat
CalendarPartInfo cpi = pm.getCalendarPartInfo();
ZVCalendar cal = null;
if (cpi != null && CalendarItem.isAcceptableInvite(mbox.getAccount(), cpi)) {
cal = cpi.cal;
}
if (cal == null) {
throw ServiceException.FAILURE("SetCalendarItem could not build an iCalendar object", null);
}
// not applicable in the SetCalendarItem case
boolean sentByMe = false;
Invite iCalInv = Invite.createFromCalendar(acct, pm.getFragment(acct.getLocale()), cal, sentByMe).get(0);
if (inv == null) {
inv = iCalInv;
} else {
//zdsync
inv.setDtStamp(iCalInv.getDTStamp());
//zdsync
inv.setFragment(iCalInv.getFragment());
}
}
inv.setPartStat(partStatStr);
SetCalendarItemData sadata = new SetCalendarItemData();
sadata.invite = inv;
sadata.message = pm;
return sadata;
}
Aggregations