if (components != null) msg.processInvitesAfterCreate(methodStr, folder.getId(), volumeId, !noICal, pm, components);
if (components != null) { try { msg.processInvitesAfterCreate(methodStr, folder.getId(), volumeId, !noICal, pm, components); } catch (Exception e) { ZimbraLog.calendar.warn("Unable to process iCalendar attachment", e); } }
    static Message create(int id, Folder folder, Conversation conv, ParsedMessage pm,                          int msgSize, String digest, short volumeId, boolean unread,                          int flags, long tags, DraftInfo dinfo, boolean noICal, ZVCalendar cal)      throws ServiceException {        if (folder == null || !folder.canContain(TYPE_MESSAGE))            throw MailServiceException.CANNOT_CONTAIN();        if (!folder.canAccess(ACL.RIGHT_INSERT))            throw ServiceException.PERM_DENIED("you do not have the required rights on the folder");                Mailbox mbox = folder.getMailbox();        List<Invite> components = null;        String methodStr = null;        if (cal != null) {            Account acct = mbox.getAccount();            // XXX: shouldn't we just be checking flags for Flag.FLAG_FROM_ME?            //   boolean sentByMe = (flags & Flag.FLAG_FROM_ME) != 0;            boolean sentByMe = false;            try {                String pmSender = pm.getSender();                if (pmSender != null && pmSender.length() > 0) {                    String sender = new InternetAddress(pmSender).getAddress();                    sentByMe = AccountUtil.addressMatchesAccount(acct, sender);                }            } catch (AddressException e) {                throw ServiceException.INVALID_REQUEST("unable to parse invite sender: " + pm.getSender(), e);            }            try {                components = Invite.createFromCalendar(acct, pm.getFragment(), cal, sentByMe, mbox, id);                methodStr = cal.getPropVal(ICalTok.METHOD, ICalTok.PUBLISH.toString());            } catch (ServiceException e) {                ZimbraLog.calendar.warn("Unable to process iCalendar attachment", e);            }        }        UnderlyingData data = new UnderlyingData();        data.id          = id;        data.type        = TYPE_MESSAGE;        if (conv != null)            data.parentId = conv.getId();        data.folderId    = folder.getId();        data.indexId     = id;        data.imapId      = id;        data.volumeId    = volumeId;        data.date        = (int) (pm.getReceivedDate() / 1000);        data.size        = msgSize;        data.blobDigest  = digest;        data.flags       = flags;        data.tags        = tags;        data.sender      = pm.getParsedSender().getSortString();        data.subject     = pm.getNormalizedSubject();        data.metadata    = encodeMetadata(DEFAULT_COLOR, pm, flags, dinfo, null);        data.unreadCount = unread ? 1 : 0;         data.contentChanged(mbox);        DbMailItem.create(mbox, data);        Message msg = new Message(mbox, data);        // process the components in this invite (must do this last so blob is created, etc)        if (components != null)            msg.processInvitesAfterCreate(methodStr, folder.getId(), volumeId, !noICal, pm, components);        msg.finishCreation(conv);        return msg;    }