Search in sources :

Example 76 with EventInfo

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

the class OwnerRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    error("OwnerRule called");
    BwPrincipal p = doPrincipal();
    if (top() instanceof OwnerUidKey) {
        OwnerUidKey key = (OwnerUidKey) top();
        key.setOwnerHref(p.getPrincipalRef());
        globals.inOwnerKey = false;
        return;
    }
    if (top() instanceof BwAdminGroup) {
        BwAdminGroup ag = (BwAdminGroup) top();
        if (name.equals("owner")) {
            ag.setOwnerHref(p.getPrincipalRef());
        } else if (name.equals("owner-key")) {
            // PRE3.5
            ag.setOwnerHref(p.getPrincipalRef());
        } else {
            ag.setGroupOwnerHref(p.getPrincipalRef());
        }
        globals.inOwnerKey = false;
        return;
    }
    BwOwnedDbentity o = null;
    if (top() == null) {
        error("Null stack top when setting owner.  Match: " + getDigester().getMatch());
        return;
    }
    if (top() instanceof EventInfo) {
        o = ((EventInfo) top()).getEvent();
    } else if (!(top() instanceof BwOwnedDbentity)) {
        if (top() instanceof BwOrganizer) {
        // No owner now
        } else if (top() instanceof BwView) {
        // No owner now
        } else if (top() instanceof SkipThis) {
        } else {
            // We expect organizer in old data
            warn("top() is not BwOwnedDbentity:" + top().getClass().getCanonicalName());
            warn("  match: " + getDigester().getMatch());
        }
        globals.inOwnerKey = false;
        return;
    } else {
        o = (BwOwnedDbentity) top();
    }
    o.setOwnerHref(p.getPrincipalRef());
    globals.inOwnerKey = false;
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) EventInfo(org.bedework.calfacade.svc.EventInfo) BwOwnedDbentity(org.bedework.calfacade.base.BwOwnedDbentity) SkipThis(org.bedework.icalendar.IcalTranslator.SkipThis) BwAdminGroup(org.bedework.calfacade.svc.BwAdminGroup) OwnerUidKey(org.bedework.dumprestore.restore.OwnerUidKey) BwOrganizer(org.bedework.calfacade.BwOrganizer) BwView(org.bedework.calfacade.svc.BwView)

Example 77 with EventInfo

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

the class ContactKeyRule method storeEntity.

@Override
public void storeEntity(final OwnerUidKey key) throws Exception {
    BwContact ent;
    try {
        ent = globals.rintf.getContact(key.getUid());
    } catch (Throwable t) {
        throw new Exception(t);
    }
    if (ent == null) {
        throw new Exception("Missing contact with key " + key + " for " + top());
    }
    if (top() instanceof EventInfo) {
        BwEvent ev = ((EventInfo) top()).getEvent();
        ev.addContact(ent);
        return;
    }
    throw new Exception("Unhandled class for contacts " + top());
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) BwContact(org.bedework.calfacade.BwContact)

Example 78 with EventInfo

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

the class ContainerPathRule method field.

public void field(String name) throws Throwable {
    if (name.equals("path")) {
        /* If the top is an override skip this - container is set already. */
        BwEventAnnotation ann = null;
        BwEvent e = null;
        if (top() instanceof EventInfo) {
            EventInfo ei = (EventInfo) getTop(EventInfo.class, name);
            e = ei.getEvent();
            if (e instanceof BwEventProxy) {
                ann = ((BwEventProxy) e).getRef();
                if (ann.getOverride()) {
                    // Overrides have everything set already
                    return;
                }
            }
        }
        BwCalendar cal = globals.rintf.getCalendar(stringFld());
        if (cal == null) {
            error("No calendar for path " + stringFld());
        }
        if (top() instanceof BwShareableContainedDbentity) {
            BwShareableContainedDbentity scde = (BwShareableContainedDbentity) top();
            scde.setColPath(stringFld());
        } else if (top() instanceof EventInfo) {
            if (ann != null) {
                /* Could be target or master */
                String match = getDigester().getMatch();
                if (match.contains("/target/")) {
                    ann.getTarget().setColPath(stringFld());
                } else if (match.contains("/master/")) {
                    ann.getMaster().setColPath(stringFld());
                } else {
                    ann.setColPath(stringFld());
                }
            }
            e.setColPath(stringFld());
        } else {
            handleException(new Exception("Unexpected stack top "));
        }
    } else {
        unknownTag(name);
    }
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEventAnnotation(org.bedework.calfacade.BwEventAnnotation) BwShareableContainedDbentity(org.bedework.calfacade.base.BwShareableContainedDbentity) BwEvent(org.bedework.calfacade.BwEvent) BwCalendar(org.bedework.calfacade.BwCalendar) BwEventProxy(org.bedework.calfacade.BwEventProxy)

Example 79 with EventInfo

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

the class CreatorRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    error("CreatorRule called");
    BwPrincipal p = doPrincipal();
    BwShareableDbentity o;
    if (top() instanceof EventInfo) {
        o = ((EventInfo) top()).getEvent();
    } else {
        o = (BwShareableDbentity) top();
    }
    if (o == null) {
        error("Null stack top when setting creator");
        return;
    }
    o.setCreatorHref(p.getPrincipalRef());
    globals.inOwnerKey = false;
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) EventInfo(org.bedework.calfacade.svc.EventInfo) BwShareableDbentity(org.bedework.calfacade.base.BwShareableDbentity)

Example 80 with EventInfo

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

the class IcalTranslator method makeIc.

private Icalendar makeIc(final BwCalendar col, final Icalendar ic, final Calendar cal, final boolean diff, final boolean mergeAttendees) throws CalFacadeException {
    try {
        if (cal == null) {
            return ic;
        }
        PropertyList pl = cal.getProperties();
        Property prop = pl.getProperty(Property.PRODID);
        if (prop != null) {
            ic.setProdid(prop.getValue());
        }
        prop = pl.getProperty(Property.VERSION);
        if (prop != null) {
            ic.setVersion(prop.getValue());
        }
        ic.setMethod(getMethod(cal));
        prop = pl.getProperty(Property.CALSCALE);
        if (prop != null) {
            ic.setCalscale(prop.getValue());
        }
        Collection<CalendarComponent> clist = orderedComponents(cal.getComponents());
        for (CalendarComponent comp : clist) {
            if (comp instanceof VFreeBusy) {
                EventInfo ei = BwEventUtil.toEvent(cb, col, ic, comp, diff, mergeAttendees);
                if (ei != null) {
                    ic.addComponent(ei);
                }
            } else if (comp instanceof VTimeZone) {
                ic.addTimeZone(doTimeZone((VTimeZone) comp));
            } else if ((comp instanceof VEvent) || (comp instanceof VToDo) || (comp instanceof VPoll) || (comp instanceof VAvailability)) {
                EventInfo ei = BwEventUtil.toEvent(cb, col, ic, comp, diff, mergeAttendees);
                if (ei != null) {
                    ic.addComponent(ei);
                }
            }
        }
        return ic;
    } catch (CalFacadeException cfe) {
        throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) EventInfo(org.bedework.calfacade.svc.EventInfo) CalendarComponent(net.fortuna.ical4j.model.component.CalendarComponent) VFreeBusy(net.fortuna.ical4j.model.component.VFreeBusy) VTimeZone(net.fortuna.ical4j.model.component.VTimeZone) VAvailability(net.fortuna.ical4j.model.component.VAvailability) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) PropertyList(net.fortuna.ical4j.model.PropertyList) VPoll(net.fortuna.ical4j.model.component.VPoll) Property(net.fortuna.ical4j.model.Property) VToDo(net.fortuna.ical4j.model.component.VToDo)

Aggregations

EventInfo (org.bedework.calfacade.svc.EventInfo)111 BwEvent (org.bedework.calfacade.BwEvent)80 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)37 BwCalendar (org.bedework.calfacade.BwCalendar)27 BwEventProxy (org.bedework.calfacade.BwEventProxy)24 BwAttendee (org.bedework.calfacade.BwAttendee)19 ArrayList (java.util.ArrayList)16 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)15 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)15 BwString (org.bedework.calfacade.BwString)11 BwDateTime (org.bedework.calfacade.BwDateTime)10 BwEventObj (org.bedework.calfacade.BwEventObj)10 TreeSet (java.util.TreeSet)9 BwXproperty (org.bedework.calfacade.BwXproperty)9 BwPrincipal (org.bedework.calfacade.BwPrincipal)7 CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)7 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)7 Calendar (net.fortuna.ical4j.model.Calendar)6 Period (net.fortuna.ical4j.model.Period)6 BwOrganizer (org.bedework.calfacade.BwOrganizer)6