Search in sources :

Example 41 with BwEventProxy

use of org.bedework.calfacade.BwEventProxy in project bw-calendar-engine by Bedework.

the class InRequest method initAttendeeCopy.

private boolean initAttendeeCopy(final CalSvcI svci, final String newColPath, final BwEvent ev, final String uri) throws CalFacadeException {
    ev.setColPath(newColPath);
    ev.setAttendeeSchedulingObject(true);
    ev.setOrganizerSchedulingObject(false);
    if (!(ev instanceof BwEventProxy) && ev.getSuppressed()) {
        return true;
    }
    BwAttendee att = ev.findAttendee(uri);
    if (att == null) {
        // Error?
        if (debug) {
            trace("Schedule - no attendee with uri " + uri + " for " + svci.getPrincipal().getPrincipalRef());
        }
        return false;
    }
    // att.setScheduleStatus(IcalDefs.deliveryStatusSuccess);
    if ((att.getPartstat() == null) || att.getPartstat().equals(IcalDefs.partstatValNeedsAction)) {
        if (att.getPartstat() == null) {
            att.setPartstat(IcalDefs.partstatValNeedsAction);
        }
        ev.setTransparency(IcalDefs.transparencyTransparent);
    // Apple ical seems to expect an x-prop.
    // ev.addXproperty(new BwXproperty(BwXproperty.appleNeedsReply,
    // null, "TRUE"));
    }
    return true;
}
Also used : BwEventProxy(org.bedework.calfacade.BwEventProxy) BwAttendee(org.bedework.calfacade.BwAttendee)

Example 42 with BwEventProxy

use of org.bedework.calfacade.BwEventProxy in project bw-calendar-engine by Bedework.

the class InRequest method updateAttendeeCopy.

/**
 * Update our (the attendees) copy of the event from the inbox copy. We
 * should have received cancellations for any instances we are no longer
 * attending. This could include extra instances (fewer exdates) for which we
 * have received no notifications.
 *
 * <p>The partstat on those instances should be currently set to NEEDS-ACTION
 * and we need to add some information to the event to allow us to highlight
 * those instances.
 *
 * <p>This may be why Apple is adding a needs reply x-prop?
 *
 * @param ourCopy
 * @param inCopy
 * @param attUri - our attendee uri
 * @return boolean true for OK
 * @throws CalFacadeException
 */
private boolean updateAttendeeCopy(final EventInfo ourCopy, final EventInfo inCopy, final String attUri) throws CalFacadeException {
    /* Update from an incoming inbox event. The incoming event may be a partial
     * recurring event, that is we may have a suppressed master and an incomplete
     * set of overrides.
     *
     * If the master is suppressed we simply update from each supplied override.
     *
     * We do not remove overrides if they are not in the incoming event. We need
     * an explicit CANCEL.
     */
    BwEvent ourEv = ourCopy.getEvent();
    BwEvent inEv = inCopy.getEvent();
    boolean ourMaster = !(ourEv instanceof BwEventProxy);
    boolean inMaster = !(inEv instanceof BwEventProxy);
    if (ourMaster != inMaster) {
        throw new CalFacadeException("Only one master event for updateAttendeeCopy");
    }
    boolean ourRecurMaster = ourMaster && ourEv.getRecurring();
    if (!inMaster || !inEv.getSuppressed()) {
        if (debug) {
            trace("Update the master event or single recurrence");
        }
        if (!updateAttendeeFields(ourCopy, inCopy, attUri)) {
            return false;
        }
    }
    if (!ourRecurMaster) {
        return true;
    }
    if (inCopy.getOverrides() != null) {
        // Go through all the overrides
        Collection<Recurrence> recurrences = null;
        for (EventInfo inOvei : inCopy.getOverrides()) {
            BwEvent inOv = inOvei.getEvent();
            String rid = inOv.getRecurrenceId();
            EventInfo ourOvei = findOverride(ourCopy, rid);
            if (ourOvei.getEvent().unsaved()) {
                if (recurrences == null) {
                    recurrences = getRecurrences(ourCopy);
                }
                Recurrence rec = null;
                for (Recurrence r : recurrences) {
                    if (rid.equals(r.recurrenceId)) {
                        rec = r;
                        break;
                    }
                }
                if (rec == null) {
                    // Not in set
                    BwDateTime bwrdt = BwDateTime.fromUTC(rid.length() == 8, rid);
                    ourEv.addRdate(bwrdt);
                }
            }
            if (!updateAttendeeCopy(ourOvei, inOvei, attUri)) {
                return false;
            }
        }
    }
    /* The incoming event may have exdates that are not in the
       attendee copy. Remove each of those and add an override cancelling
       that instance.
     */
    final Set<BwDateTime> inExdates = inCopy.getEvent().getExdates();
    if (!Util.isEmpty(inExdates)) {
        final Set<BwDateTime> ourExdates = ourCopy.getEvent().getExdates();
        for (final BwDateTime exdt : inExdates) {
            if (!Util.isEmpty(ourExdates) && ourExdates.contains(exdt)) {
                continue;
            }
            final EventInfo ourOvei = findOverride(ourCopy, exdt.getDate());
            ourOvei.getEvent().setStatus(BwEvent.statusCancelled);
        }
    }
    return true;
}
Also used : Recurrence(org.bedework.icalendar.RecurUtil.Recurrence) EventInfo(org.bedework.calfacade.svc.EventInfo) BwDateTime(org.bedework.calfacade.BwDateTime) BwEvent(org.bedework.calfacade.BwEvent) BwString(org.bedework.calfacade.BwString) BwEventProxy(org.bedework.calfacade.BwEventProxy) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

BwEventProxy (org.bedework.calfacade.BwEventProxy)42 BwEvent (org.bedework.calfacade.BwEvent)33 EventInfo (org.bedework.calfacade.svc.EventInfo)24 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)19 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)12 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)11 BwDateTime (org.bedework.calfacade.BwDateTime)9 BwAttendee (org.bedework.calfacade.BwAttendee)7 BwCalendar (org.bedework.calfacade.BwCalendar)7 ArrayList (java.util.ArrayList)5 TreeSet (java.util.TreeSet)5 BwXproperty (org.bedework.calfacade.BwXproperty)5 Dur (net.fortuna.ical4j.model.Dur)4 BwRecurrenceInstance (org.bedework.calfacade.BwRecurrenceInstance)4 Collection (java.util.Collection)3 DateTime (net.fortuna.ical4j.model.DateTime)3 BwCategory (org.bedework.calfacade.BwCategory)3 BwContact (org.bedework.calfacade.BwContact)3 BwEventObj (org.bedework.calfacade.BwEventObj)3 BwString (org.bedework.calfacade.BwString)3