Appointment.FreeBusyActualData fbaDat = (Appointment.FreeBusyActualData)iter.next();
Appointment.ReplyInfo repInfo = (Appointment.ReplyInfo)iter.next();
    public static Element encodeInvite(Element parent, ZimbraContext lc, Appointment apptOrNull, Invite invite, int fields) {        boolean allFields = true;                if (fields != NOTIFY_FIELDS) {            allFields = false;            if (!needToOutput(fields, Change.MODIFIED_INVITE)) {                return parent;            }        }                    Element e = parent.addElement(MailService.E_INVITE_COMPONENT);        e.addAttribute(MailService.A_APPT_COMPONENT_NUM, invite.getComponentNum());                // currently the RSVP attribute is the only attribute that changes        e.addAttribute(MailService.A_APPT_RSVP, invite.needsReply());                if (allFields) {            try {                e.addAttribute("x_uid", invite.getUid());                                Appointment appt = invite.getAppointment();                if (appt != null)                    e.addAttribute(MailService.A_APPT_ID, lc.formatItemId(appt));                                if (invite.thisAcctIsOrganizer(appt.getMailbox().getAccount())) {                    e.addAttribute(MailService.A_APPT_ISORG, true);                }                                Recurrence.IRecurrence recur = invite.getRecurrence();                if (recur != null) {                    Element recurElt = e.addElement(MailService.E_APPT_RECUR);                    recur.toXml(recurElt);                }            } catch(ServiceException ex) {                ex.printStackTrace();            }                        e.addAttribute(MailService.A_APPT_TYPE, invite.getType());                        e.addAttribute(MailService.A_APPT_STATUS, invite.getStatus());            e.addAttribute(MailService.A_APPT_FREEBUSY, invite.getFreeBusy());            e.addAttribute(MailService.A_APPT_FREEBUSY_ACTUAL, invite.getFreeBusyActual());                        if (apptOrNull != null) {                try {                    List /*Appointment.FreeBusyActualData*/ fbas = apptOrNull.getFreeBusyActual(apptOrNull.getMailbox().getAccount(), invite);                    Element fbaElt = e.addElement(MailService.A_APPT_MY_REPLIES);                                        for (Iterator iter = fbas.iterator(); iter.hasNext();) {                        Appointment.FreeBusyActualData fbaDat = (Appointment.FreeBusyActualData)iter.next();                                                Element curElt = fbaElt.addElement(MailService.E_INSTANCE);                        if (fbaDat.mRecurId != null) {                            fbaDat.mRecurId.toXml(curElt);                        }                        curElt.addAttribute(MailService.A_APPT_FREEBUSY_ACTUAL, fbaDat.mFba);                    }                } catch (ServiceException ex) {                    // XXX fixme, need to fix error handling for all the ToXML stuff!                }            }            e.addAttribute(MailService.A_APPT_TRANSPARENCY, invite.getTransparency());                        if (invite.isAllDayEvent())                e.addAttribute(MailService.A_APPT_ALLDAY, true);                        if (invite.getStartTime() != null) {                Element startElt = e.addElement(MailService.E_APPT_START_TIME);                ParsedDateTime dtStart = invite.getStartTime();                startElt.addAttribute(MailService.A_APPT_DATETIME, dtStart.getDateTimePartString());                String tzName = dtStart.getTZName();                if (tzName != null) {                    startElt.addAttribute(MailService.A_APPT_TIMEZONE, tzName);                }            }                        ParsedDateTime dtEnd = invite.getEndTime();            if (dtEnd != null) {                Element endElt = e.addElement(MailService.E_APPT_END_TIME);                endElt.addAttribute(MailService.A_APPT_DATETIME, dtEnd.getDateTimePartString());                String tzName = dtEnd.getTZName();                if (tzName != null) {                    endElt.addAttribute(MailService.A_APPT_TIMEZONE, tzName);                }            }                        ParsedDuration dur = invite.getDuration();            if (dur != null) {                dur.toXml(e);            }                        e.addAttribute(MailService.A_NAME, invite.getName());            e.addAttribute(MailService.A_APPT_LOCATION, invite.getLocation());                        // Organizer            Organizer org = invite.getOrganizer();            if (org != null) {                Element orgElt = e.addUniqueElement(MailService.E_APPT_ORGANIZER);                orgElt.addAttribute(MailService.A_DISPLAY, CalendarUtils.paramVal(org, Parameter.CN));                orgElt.addAttribute(MailService.A_URL, org.getCalAddress().toASCIIString());            }                        // Attendee(s)            Collection /*Invite.Attendee*/ ats = invite.getAttendees();            for (Iterator atsIter = ats.iterator();atsIter.hasNext();) {                Element atElt = e.addElement(MailService.E_APPT_ATTENDEE);                                Attendee at = (Attendee)atsIter.next();                                // display name                 atElt.addAttribute(MailService.A_DISPLAY, CalendarUtils.paramVal(at,Parameter.CN ));                                // role                String role = CalendarUtils.paramVal(at, Parameter.ROLE);                atElt.addAttribute(MailService.A_APPT_ROLE, IcalXmlStrMap.sRoleMap.toXml(role));                                // participation status                String partStat = CalendarUtils.paramVal(at, Parameter.PARTSTAT);                atElt.addAttribute(MailService.A_APPT_PARTSTAT, IcalXmlStrMap.sPartStatMap.toXml(partStat));                                // uri                atElt.addAttribute(MailService.A_URL, at.getCalAddress().toASCIIString());            }        }        return e;    }