Search in sources :

Example 56 with BwEvent

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

the class Dumpling method dumpCollection.

private void dumpCollection(final Iterator<T> it) throws Throwable {
    while (it.hasNext()) {
        final DumpEntity d = unwrap(it.next());
        globals.counts[countIndex]++;
        if ((globals.counts[countIndex] % 100) == 0) {
            info("        ... " + globals.counts[countIndex]);
        }
        if (d instanceof BwResource) {
            dumpResource((BwResource) d);
            continue;
        }
        if (d instanceof BwCalendar) {
            dumpCollection((BwCalendar) d);
            continue;
        }
        if (d instanceof BwEvent) {
            dumpEvent((BwEvent) d);
            continue;
        }
        /* Just dump any remaining classes - no special treatment */
        d.dump(xml);
    }
}
Also used : DumpEntity(org.bedework.calfacade.base.DumpEntity) BwResource(org.bedework.calfacade.BwResource) BwEvent(org.bedework.calfacade.BwEvent) BwCalendar(org.bedework.calfacade.BwCalendar)

Example 57 with BwEvent

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

the class BwStringRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    if (name.equals("bwstring")) {
        // 3.5 onwards we wrapped with a tag. Do nothing
        return;
    }
    BwString entity = (BwString) pop();
    if (top() instanceof BwRequestStatus) {
        BwRequestStatus rs = (BwRequestStatus) top();
        rs.setDescription(entity);
        return;
    }
    if (top() instanceof BwCategory) {
        BwCategory cat = (BwCategory) top();
        if (name.equals("keyword")) {
            cat.setWord(entity);
        } else if (name.equals("desc")) {
            cat.setDescription(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwContact) {
        BwContact ent = (BwContact) top();
        if (name.equals("value")) {
            ent.setCn(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwLocation) {
        BwLocation loc = (BwLocation) top();
        if (name.equals("addr")) {
            loc.setAddress(entity);
        } else if (name.equals("subaddr")) {
            loc.setSubaddress(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwFilterDef) {
        BwFilterDef f = (BwFilterDef) top();
        if (name.equals("display-name")) {
            f.addDisplayName(entity);
        } else if (name.equals("subaddr")) {
            f.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwAlarm) {
        BwAlarm a = (BwAlarm) top();
        if (name.equals("description")) {
            a.addDescription(entity);
            if (entity.getLang() != null) {
                a.addXproperty(new BwXproperty(entity.getLang(), null, entity.getValue()));
            } else {
                a.addDescription(entity);
            }
            return;
        }
        if (name.equals("summary")) {
            a.addSummary(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    EventInfo ei = (EventInfo) top();
    BwEvent e = ei.getEvent();
    if (e instanceof BwEventProxy) {
        e = ((BwEventProxy) e).getRef();
    }
    if (name.equals("comment")) {
        e.addComment(entity);
    } else if (name.equals("description")) {
        e.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
    } else if (name.equals("resource")) {
        e.addResource(entity);
    } else if (name.equals("summary")) {
        e.addSummary(entity);
    } else {
        unknownTag(name);
    }
}
Also used : BwLongString(org.bedework.calfacade.BwLongString) BwLocation(org.bedework.calfacade.BwLocation) BwRequestStatus(org.bedework.calfacade.BwRequestStatus) EventInfo(org.bedework.calfacade.svc.EventInfo) BwXproperty(org.bedework.calfacade.BwXproperty) BwCategory(org.bedework.calfacade.BwCategory) BwFilterDef(org.bedework.calfacade.BwFilterDef) BwEvent(org.bedework.calfacade.BwEvent) BwString(org.bedework.calfacade.BwString) BwContact(org.bedework.calfacade.BwContact) BwEventProxy(org.bedework.calfacade.BwEventProxy) BwAlarm(org.bedework.calfacade.BwAlarm)

Example 58 with BwEvent

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

the class AlarmRule method end.

public void end(String ns, String name) throws Exception {
    BwAlarm entity = (BwAlarm) pop();
    globals.counts[globals.valarms]++;
    if (!(top() instanceof EventInfo)) {
        warn("Expected an event info object: found " + top());
        return;
    }
    BwEvent ev = ((EventInfo) top()).getEvent();
    if (entity.getOwnerHref() == null) {
        entity.setOwnerHref(ev.getOwnerHref());
    }
    entity.setEvent(ev);
    ev.addAlarm(entity);
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) BwAlarm(org.bedework.calfacade.BwAlarm)

Example 59 with BwEvent

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

the class InScheduler method processScheduleUpdateEvent.

private ProcessMessageResult processScheduleUpdateEvent(final ScheduleUpdateEvent msg) {
    try (final CalSvcI svci = getSvci(msg.getOwnerHref())) {
        if (debug) {
            trace("ScheduleUpdateEvent for principal " + msg.getOwnerHref());
        }
        final EventInfo ei = svci.getEventsHandler().get(getParentPath(msg.getHref()), getName(msg.getHref()));
        if (ei == null) {
            // Event deleted?.
            if (debug) {
                trace("InSchedule event deleted?");
            }
            return ProcessMessageResult.NO_ACTION;
        }
        final BwEvent ev = ei.getEvent();
        SchedProcessor proc = null;
        switch(msg.getChange()) {
            case attendeeChange:
                {
                    proc = new SchedAttendeeUpdate(svci);
                    break;
                }
            default:
                warn("InSchedule: unhandled change type for " + ev.getOwnerHref() + " " + msg.getChange());
        }
        if (proc == null) {
            return ProcessMessageResult.PROCESSED;
        }
        final SchedProcResult pr = proc.process(ei);
        if (debug) {
            trace("InSchedule " + pr.sr);
        }
        return ProcessMessageResult.PROCESSED;
    } 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 : SchedProcessor(org.bedework.inoutsched.processors.SchedProcessor) CalFacadeStaleStateException(org.bedework.calfacade.exc.CalFacadeStaleStateException) SchedProcResult(org.bedework.inoutsched.processors.SchedProcessor.SchedProcResult) EventInfo(org.bedework.calfacade.svc.EventInfo) CalSvcI(org.bedework.calsvci.CalSvcI) BwEvent(org.bedework.calfacade.BwEvent) SchedAttendeeUpdate(org.bedework.inoutsched.processors.SchedAttendeeUpdate)

Example 60 with BwEvent

use of org.bedework.calfacade.BwEvent 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)

Aggregations

BwEvent (org.bedework.calfacade.BwEvent)160 EventInfo (org.bedework.calfacade.svc.EventInfo)80 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)55 BwEventProxy (org.bedework.calfacade.BwEventProxy)33 ChangeTableEntry (org.bedework.calfacade.util.ChangeTableEntry)26 BwAttendee (org.bedework.calfacade.BwAttendee)25 BwDateTime (org.bedework.calfacade.BwDateTime)25 BwString (org.bedework.calfacade.BwString)24 UpdateResult (org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)23 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)23 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)21 BwCalendar (org.bedework.calfacade.BwCalendar)21 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)20 BwXproperty (org.bedework.calfacade.BwXproperty)16 TreeSet (java.util.TreeSet)15 BwEventObj (org.bedework.calfacade.BwEventObj)13 ArrayList (java.util.ArrayList)12 Period (net.fortuna.ical4j.model.Period)12 BwCategory (org.bedework.calfacade.BwCategory)10 BwContact (org.bedework.calfacade.BwContact)10