Search in sources :

Example 1 with SchedulingI

use of org.bedework.calsvci.SchedulingI in project bw-calendar-engine by Bedework.

the class InReply method process.

@Override
public ProcessResult process(final EventInfo ei) throws CalFacadeException {
    /* Process a response we as the organizer, or their proxy, received from
     * an attendee
     */
    final ProcessResult pr = new ProcessResult();
    final SchedulingI sched = getSvc().getScheduler();
    BwEvent ev = ei.getEvent();
    final EventInfo colEi = sched.getStoredMeeting(ev);
    /* The event should have a calendar set to the inbox it came from.
     * That inbox may be owned by somebody other than the current user if a
     * calendar user has delegated control of their inbox to some other user
     * e.g. secretary.
     */
    pr.attendeeAccepting = true;
    check: {
        if (colEi == null) {
            // No corresponding stored meeting
            break check;
        }
        if (ev.getOriginator() == null) {
            pr.sr.errorCode = CalFacadeException.schedulingNoOriginator;
            break check;
        }
        String attUri = null;
        /* Should be exactly one attendee */
        if (!ev.getSuppressed()) {
            final Collection<BwAttendee> atts = ev.getAttendees();
            if ((atts == null) || (atts.size() != 1)) {
                pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
                break check;
            }
            final BwAttendee att = atts.iterator().next();
            if (!att.getPartstat().equals(acceptPartstat)) {
                pr.attendeeAccepting = false;
            }
            attUri = att.getAttendeeUri();
        }
        if (ei.getNumOverrides() > 0) {
            for (final EventInfo oei : ei.getOverrides()) {
                ev = oei.getEvent();
                final Collection<BwAttendee> atts = ev.getAttendees();
                if ((atts == null) || (atts.size() != 1)) {
                    pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
                    break check;
                }
                final BwAttendee att = atts.iterator().next();
                if (!att.getPartstat().equals(acceptPartstat)) {
                    pr.attendeeAccepting = false;
                }
                if (attUri == null) {
                    attUri = att.getAttendeeUri();
                } else if (!attUri.equals(att.getAttendeeUri())) {
                    pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
                    break check;
                }
            }
        }
        if (attUri == null) {
            pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
            break check;
        }
        /*TODO If the sequence of the incoming event is lower than the sequence on the
       * calendar event we ignore it.
       */
        final boolean vpoll = colEi.getEvent().getEntityType() == IcalDefs.entityTypeVpoll;
        if (vpoll) {
            if (!updateOrganizerPollCopy(colEi, ei, attUri, pr.sr)) {
                break check;
            }
        } else if (!updateOrganizerCopy(colEi, ei, attUri, pr.sr)) {
            break check;
        }
        pr.removeInboxEntry = false;
    }
    return pr;
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) SchedulingI(org.bedework.calsvci.SchedulingI) BwAttendee(org.bedework.calfacade.BwAttendee)

Example 2 with SchedulingI

use of org.bedework.calsvci.SchedulingI in project bw-calendar-engine by Bedework.

the class InCancel method process.

/**
 * @param ei the incoming event
 * @return ScheduleResult
 * @throws CalFacadeException on error
 */
@Override
public ProcessResult process(final EventInfo ei) throws CalFacadeException {
    /* We, as an attendee, received a CANCEL from the organizer.
     *
     */
    final ProcessResult pr = new ProcessResult();
    final BwEvent ev = ei.getEvent();
    final SchedulingI sched = getSvc().getScheduler();
    pr.removeInboxEntry = true;
    check: {
        if (ev.getOriginator() == null) {
            pr.sr.errorCode = CalFacadeException.schedulingNoOriginator;
            break check;
        }
        final BwPreferences prefs = getSvc().getPrefsHandler().get();
        final EventInfo colEi = sched.getStoredMeeting(ei.getEvent());
        if (colEi == null) {
            break check;
        }
        final BwEvent colEv = colEi.getEvent();
        if (prefs.getScheduleAutoCancelAction() == BwPreferences.scheduleAutoCancelSetStatus) {
            if (colEv.getSuppressed()) {
                if (colEi.getOverrides() != null) {
                    for (final EventInfo oei : colEi.getOverrides()) {
                        final BwEvent oev = oei.getEvent();
                        oev.setStatus(BwEvent.statusCancelled);
                        oev.setSequence(ev.getSequence());
                    }
                }
            } else {
                colEv.setStatus(BwEvent.statusCancelled);
                colEv.setSequence(ev.getSequence());
            }
            getSvc().getEventsHandler().update(colEi, true, null);
        } else {
            getSvc().getEventsHandler().delete(colEi, false);
        }
        pr.removeInboxEntry = false;
    }
    return pr;
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) SchedulingI(org.bedework.calsvci.SchedulingI)

Example 3 with SchedulingI

use of org.bedework.calsvci.SchedulingI in project bw-calendar-engine by Bedework.

the class InRefresh method process.

/**
 * @param ei the event
 * @return ScheduleResult
 * @throws CalFacadeException
 */
@Override
public ProcessResult process(final EventInfo ei) throws CalFacadeException {
    final SchedulingI sched = getSvc().getScheduler();
    final BwEvent ev = ei.getEvent();
    final ProcessResult pr = new ProcessResult();
    pr.noInboxChange = true;
    /* Refresh request from attendee - send our copy
     */
    /* Should be exactly one attendee. */
    Collection<BwAttendee> atts = ev.getAttendees();
    if ((atts == null) || (atts.size() != 1)) {
        return null;
    }
    BwAttendee att = atts.iterator().next();
    /* We can only do this if there is an active copy */
    EventInfo calEi = sched.getStoredMeeting(ev);
    if (calEi == null) {
        return null;
    }
    calEi.getEvent().setScheduleMethod(ScheduleMethods.methodTypeRequest);
    /* Just send a copy to the attendee. */
    pr.sr = sched.schedule(calEi, att.getAttendeeUri(), null, false);
    if (pr.sr.errorCode == null) {
        getSvc().getEventsHandler().delete(ei, false);
    }
    return pr;
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) SchedulingI(org.bedework.calsvci.SchedulingI) BwAttendee(org.bedework.calfacade.BwAttendee)

Aggregations

BwEvent (org.bedework.calfacade.BwEvent)3 EventInfo (org.bedework.calfacade.svc.EventInfo)3 SchedulingI (org.bedework.calsvci.SchedulingI)3 BwAttendee (org.bedework.calfacade.BwAttendee)2 BwPreferences (org.bedework.calfacade.svc.BwPreferences)1