fid = folderId;      boolean isRemote = false; Mailbox mbox = mMailbox; if (method.equals(ICalTok.REPLY.toString())) { if (cur.hasOrganizer()) { ZOrganizer org = cur.getOrganizer(); if (!AccountUtil.addressMatchesAccount(getAccount(), org.getAddress())) { Account orgAccount = cur.getOrganizerAccount();  if (orgAccount == null) {  continue; }  if (false && Provisioning.onLocalServer(orgAccount)) { mbox = Mailbox.getMailboxByAccount(orgAccount); fid = Mailbox.ID_FOLDER_CALENDAR; } else {  String uri = AccountUtil.getSoapUri(orgAccount); if (uri != null) { try { String ical; StringWriter sr = null; try { sr = new StringWriter(); cur.newToICalendar().toICalendar(sr); ical = sr.toString(); } finally { if (sr != null) sr.close(); }  ZMailbox zmbox = ZMailbox.getMailbox(new AuthToken(orgAccount).getEncoded(), uri, null); zmbox.iCalReply(ical); } catch (Exception e) { ZimbraLog.misc.warn("could not save to remote sent folder (perm denied); continuing", e); } } else {  } continue; } } } }  Appointment appt = mbox.getAppointmentByUid(cur.getUid());
Appointment appt = mMailbox.getAppointmentByUid(cur.getUid());
   private void processInvitesAfterCreate(String method, int folderId, short volumeId, boolean createAppt,                                          ParsedMessage pm, List<Invite> invites)    throws ServiceException {       // since this is the first time we've seen this Invite Message, we need to process it       // and see if it updates an existing Appointment in the Appointments table, or whatever...       boolean updatedMetadata = false;       int fid;       for (Invite cur : invites) {           fid = folderId;           // The iCalendar object may be a REPLY to an event this mailbox user           // created on behalf of another user.  There won't be an Appointment           // in this user's mailbox!  The REPLY must be "forwarded" to the           // organizer mailbox, which may or may not be on this host.           boolean isRemote = false;           Mailbox mbox = mMailbox;           if (method.equals(ICalTok.REPLY.toString())) {               if (cur.hasOrganizer()) {                   ZOrganizer org = cur.getOrganizer();                   if (!AccountUtil.addressMatchesAccount(getAccount(), org.getAddress())) {                       Account orgAccount = cur.getOrganizerAccount();                       // Unknown organizer                       if (orgAccount == null) {                           // TODO: log something                           continue;                       }                       if (false && Provisioning.onLocalServer(orgAccount)) {                           mbox = Mailbox.getMailboxByAccount(orgAccount);                           fid = Mailbox.ID_FOLDER_CALENDAR;                       } else {                           // Organizer's mailbox is on a remote server.                           String uri = AccountUtil.getSoapUri(orgAccount);                           if (uri != null) {                               try {                                   String ical;                                   StringWriter sr = null;                                   try {                                       sr = new StringWriter();                                       cur.newToICalendar().toICalendar(sr);                                       ical = sr.toString();                                   } finally {                                       if (sr != null)                                           sr.close();                                   }                                   ZMailbox zmbox = ZMailbox.getMailbox(new AuthToken(orgAccount).getEncoded(), uri, null);                                   zmbox.iCalReply(ical);                               } catch (Exception e) {                                   ZimbraLog.misc.warn("could not save to remote sent folder (perm denied); continuing", e);                               }                           } else {                               // TODO: log something                           }                           continue;                       }                   }               }           }           Appointment appt = mbox.getAppointmentByUid(cur.getUid());           if (createAppt) {               if (appt == null) {                    // ONLY create an appointment if this is a REQUEST method...otherwise don't.                   if (method.equals(ICalTok.REQUEST.toString())) {                       appt = mbox.createAppointment(Mailbox.ID_FOLDER_CALENDAR, volumeId, "", cur.getUid(), pm, cur);                   } else {                       sLog.info("Mailbox " + getMailboxId()+" Message "+getId()+" SKIPPING Invite "+method+" b/c no Appointment could be found");                       return; // for now, just ignore this Invitation                   }               } else {                   // When updating an existing appointment, ignore the                   // passed-in folderId which will usually be Inbox.  Leave                   // the appointment in the folder it's currently in.                   appt.processNewInvite(pm, cur, false, appt.getFolderId(), volumeId);               }           }           if (appt != null) {               ApptInfo info = new ApptInfo(appt.getId(), cur.getComponentNum());               if (mApptInfos == null) {                   mApptInfos = new ArrayList<ApptInfo>();               }               mApptInfos.add(info);               updatedMetadata = true;           }       }              if (updatedMetadata)           saveMetadata();   }