use of org.bedework.inoutsched.processors.InRequest 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;
}
Aggregations