Search in sources :

Example 1 with InCancel

use of org.bedework.inoutsched.processors.InCancel in project bw-calendar-engine by Bedework.

the class InScheduler method processEntityQueuedEvent.

private ProcessMessageResult processEntityQueuedEvent(final EntityQueuedEvent msg) {
    /* These are events that are placed in the inbox.
     */
    EventInfo ei = null;
    try (final CalSvcI svci = getSvci(msg.getOwnerHref())) {
        if (debug) {
            trace("InSchedule inbox entry for principal " + msg.getOwnerHref());
        }
        ei = getInboxEvent(svci, msg.getName());
        if (ei == null) {
            // Event deleted from inbox.
            if (debug) {
                trace("InSchedule event deleted from inbox");
            }
            return ProcessMessageResult.NO_ACTION;
        }
        final BwEvent ev = ei.getEvent();
        final int method = ev.getScheduleMethod();
        if (debug) {
            trace("InSchedule event for " + msg.getOwnerHref() + " " + msg.getName() + " with method " + ScheduleMethods.methods[method] + "\n" + ev);
            if (ev.getSuppressed()) {
                for (final EventInfo oei : ei.getOverrides()) {
                    trace("Override: " + oei.getEvent());
                }
            }
        }
        InProcessor proc = null;
        switch(method) {
            case Icalendar.methodTypeCancel:
                proc = new InCancel(svci);
                break;
            case Icalendar.methodTypeRequest:
            case Icalendar.methodTypePollStatus:
                proc = new InRequest(svci);
                break;
            case Icalendar.methodTypeReply:
                proc = new InReply(svci);
                break;
            case Icalendar.methodTypeRefresh:
                proc = new InRefresh(svci);
                break;
            default:
                warn("InSchedule: unhandled method for " + ev.getOwnerHref() + " " + method);
        }
        if (proc == null) {
            deleteEvent(ei, false, false);
            return ProcessMessageResult.PROCESSED;
        }
        final ProcessResult pr = proc.process(ei);
        if (debug) {
            trace("InSchedule " + pr.sr);
        }
        if (!pr.noInboxChange) {
            proc.pendingToInbox(ei, ev.getOwnerHref(), pr.attendeeAccepting, pr.removeInboxEntry);
        }
        deleteEvent(ei, false, false);
        return ProcessMessageResult.PROCESSED;
    } catch (final CalFacadeForbidden cff) {
        if (debug) {
            trace("Forbidden exception" + cff);
        }
        if (ei != null) {
            try {
                deleteEvent(ei, false, false);
            } catch (final Throwable ignored) {
            }
        }
        return ProcessMessageResult.FAILED_NORETRIES;
    } catch (final CalFacadeStaleStateException csse) {
        if (debug) {
            trace("Stale state exception");
        }
        rollback(getSvc());
        return ProcessMessageResult.STALE_STATE;
    } catch (final Throwable t) {
        rollback(getSvc());
        error(t);
    }
    return ProcessMessageResult.FAILED;
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) InRequest(org.bedework.inoutsched.processors.InRequest) InRefresh(org.bedework.inoutsched.processors.InRefresh) ProcessResult(org.bedework.inoutsched.processors.InProcessor.ProcessResult) CalFacadeForbidden(org.bedework.calfacade.exc.CalFacadeForbidden) BwEvent(org.bedework.calfacade.BwEvent) InReply(org.bedework.inoutsched.processors.InReply) CalFacadeStaleStateException(org.bedework.calfacade.exc.CalFacadeStaleStateException) CalSvcI(org.bedework.calsvci.CalSvcI) InProcessor(org.bedework.inoutsched.processors.InProcessor) InCancel(org.bedework.inoutsched.processors.InCancel)

Aggregations

BwEvent (org.bedework.calfacade.BwEvent)1 CalFacadeForbidden (org.bedework.calfacade.exc.CalFacadeForbidden)1 CalFacadeStaleStateException (org.bedework.calfacade.exc.CalFacadeStaleStateException)1 EventInfo (org.bedework.calfacade.svc.EventInfo)1 CalSvcI (org.bedework.calsvci.CalSvcI)1 InCancel (org.bedework.inoutsched.processors.InCancel)1 InProcessor (org.bedework.inoutsched.processors.InProcessor)1 ProcessResult (org.bedework.inoutsched.processors.InProcessor.ProcessResult)1 InRefresh (org.bedework.inoutsched.processors.InRefresh)1 InReply (org.bedework.inoutsched.processors.InReply)1 InRequest (org.bedework.inoutsched.processors.InRequest)1