if (invites[i] != null && invites[i].getMethod().equals(Method.REQUEST.getValue())) {
if (invites[i] != null && (invites[i].getMethod().equals(Method.REQUEST.getValue()) || invites[i].getMethod().equals(Method.PUBLISH.getValue())) ) {
    public Element handle(Element request, Map context) throws ServiceException {        long startTime = sWatch.start();        try {            ZimbraContext lc = getZimbraContext(context);            Account acct = getRequestedAccount(lc);            Mailbox mbox = getRequestedMailbox(lc);            OperationContext octxt = lc.getOperationContext();                        ParsedItemID pid = ParsedItemID.parse(request.getAttribute("id"));            int compNum = (int)request.getAttributeLong("comp");                        sLog.info("<CancelAppointment id="+pid+" comp="+compNum+">");                        synchronized (mbox) {                Appointment appt = mbox.getAppointmentById(octxt, pid.getItemIDInt());                 Invite inv = appt.getInvite(pid.getSubIdInt(), compNum);                if (appt == null) {                    throw MailServiceException.NO_SUCH_APPOINTMENT(inv.getUid(), " for CancelAppointmentRequest("+pid+","+compNum+")");                }                                Invite defaultInv = appt.getDefaultInvite();                if (defaultInv.getMailItemId() != pid.getSubIdInt()) {                    throw ServiceException.INVALID_REQUEST("Specified Invite ID "+pid+" is not the Default Invite for appt "+appt.getId(), null);                }/******* * TIM: remove the "cancel a single instance of a recurring appointment" from here,  * and put it in the "CancelAppointmentException" API.  The reason is that, from the  * client's perspective, cancelling a particular instance is the same thing as  * cancelling a particular exception --- or at least it is easier to think about it  * that way.  Leaving this commented-out code here for now until I've thought about  * it a little longer.... *                  Element recurElt = request.getOptionalElement("inst");                if (recurElt != null) {                    if (inv.hasRecurId()) {                        throw MailServiceException.CANNOT_CANCEL_INSTANCE_OF_EXCEPTION(" for CancelAppointmentRequest("+pid+","+compNum+")");                    }                    cancelInstance(octxt, request, acct, mbox, inv, recurElt);                } else {                *****/                                    // if recur is not set, then we're cancelling the entire appointment...                                        // first, pull a list of all the invites and THEN start cancelling them: since cancelling them                    // will remove them from the appointment's list, we can get really confused if we just directly                    // iterate through the list...                                        Invite invites[] = new Invite[appt.numInvites()];                    for (int i = appt.numInvites()-1; i>=0; i--) {                        try {                            invites[i] = appt.getInvite(i);                        } catch (MailServiceException.NoSuchItemException e) {                            sLog.info("Error couldn't load invite "+i+" for appointment "+appt.getId(), e);                        }                    }                                        for (int i = invites.length-1; i >= 0; i--) {                        if (invites[i] != null && invites[i].getMethod().equals(Method.REQUEST.getValue())) {                            cancelInvite(octxt, request, acct, mbox, appt, invites[i]);                        }                    }//                }            } // synchronized on mailbox                        Element response = lc.createElement(MailService.CANCEL_APPOINTMENT_RESPONSE);            return response;        } finally {            sWatch.stop(startTime);        }            }