Search in sources :

Example 71 with EventInfo

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

the class XpropertyRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    BwXproperty entity = (BwXproperty) pop();
    if (top() instanceof EventInfo) {
        EventInfo ei = (EventInfo) top();
        BwEvent e = ei.getEvent();
        if (e instanceof BwEventProxy) {
            e = ((BwEventProxy) e).getRef();
        }
        // XXX From before 4.0
        if (entity.getName().equals(BwXproperty.bedeworkAlias) || entity.getName().equals(BwXproperty.bedeworkSubmitAlias)) {
            entity.setValue(Util.buildPath(false, entity.getValue()));
        }
        e.addXproperty(entity);
    }
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwXproperty(org.bedework.calfacade.BwXproperty) BwEvent(org.bedework.calfacade.BwEvent) BwEventProxy(org.bedework.calfacade.BwEventProxy)

Example 72 with EventInfo

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

the class EventBwRequestStatusRule method end.

public void end(String ns, String name) throws Exception {
    BwRequestStatus entity = (BwRequestStatus) pop();
    EventInfo ei = (EventInfo) top();
    BwEvent e = ei.getEvent();
    if (e instanceof BwEventProxy) {
        e = ((BwEventProxy) e).getRef();
    }
    e.addRequestStatus(entity);
}
Also used : BwRequestStatus(org.bedework.calfacade.BwRequestStatus) EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) BwEventProxy(org.bedework.calfacade.BwEventProxy)

Example 73 with EventInfo

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

the class EventRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    if (!(top() instanceof EventInfo)) {
        warn("Top is not an event");
        warn(top().toString());
        return;
    }
    if (globals.entityError) {
        warn("Not restoring event because of previous error");
        warn(top().toString());
        return;
    }
    EventInfo ei = (EventInfo) top();
    BwEvent entity = ei.getEvent();
    if (entity instanceof BwEventProxy) {
        entity = ((BwEventProxy) entity).getRef();
    }
    boolean override = (entity instanceof BwEventAnnotation) && (((BwEventAnnotation) entity).getOverride());
    boolean alias = (entity instanceof BwEventAnnotation) && !override;
    globals.counts[globals.events]++;
    if ((globals.counts[globals.events] % 100) == 0) {
        info("Restore event # " + globals.counts[globals.events]);
    }
    if (!override) {
        fixSharableEntity(entity, "Event");
    }
    if ((entity.getEntityType() == IcalDefs.entityTypeTodo) && entity.getNoStart() && (entity.getEndType() == StartEndComponent.endTypeNone)) {
        /* The end date should be sometime in the distant future. If it isn't make
       * it so.
       * A bug was creating essentially one day events.
       */
        Date sdt = BwDateTimeUtil.getDate(entity.getDtstart());
        Date edt = BwDateTimeUtil.getDate(entity.getDtend());
        // about 9 years of millis
        long years9 = 52L * 7L * 24L * 60L * 60L * 1000L * 9L;
        if ((edt.getTime() - sdt.getTime()) < years9) {
            // about 10 years
            Dur years10 = new Dur(520);
            net.fortuna.ical4j.model.Date newDt = new net.fortuna.ical4j.model.Date(sdt.getTime());
            DtEnd dtEnd = new DtEnd(new net.fortuna.ical4j.model.Date(years10.getTime(newDt)));
            entity.setDtend(BwDateTime.makeBwDateTime(dtEnd));
            warn("Fixed task uid=" + entity.getUid());
        }
    }
    // Out here for debugging
    BwEvent target = null;
    BwEvent master = null;
    try {
        if (override) {
            pop();
            if (!(top() instanceof EventInfo)) {
                warn("Not restoring event because of previous error");
                warn(top().toString());
                return;
            }
            if (debug) {
                trace("Add override to event ");
            }
            EventInfo masterei = (EventInfo) top();
            masterei.addOverride(ei);
            return;
        }
        if (alias) {
            BwEventAnnotation ann = (BwEventAnnotation) entity;
            /* It's an alias, save an entry in the alias table then remove the dummy target.
         * We'll update them all at the end
         */
            // XXX Never did get on table globals.aliasTbl.put(ann);
            target = ann.getTarget();
            BwPrincipal annOwner = globals.getPrincipal(ann.getOwnerHref());
            BwEvent ntarget = globals.rintf.getEvent(annOwner, target.getColPath(), target.getRecurrenceId(), target.getUid());
            if (ntarget == null) {
                error("Unknown target " + target);
            }
            ann.setTarget(ntarget);
            master = ann.getMaster();
            if (master.equals(target)) {
                ann.setMaster(ntarget);
            } else {
                BwEvent nmaster = globals.rintf.getEvent(annOwner, master.getColPath(), master.getRecurrenceId(), master.getUid());
                if (nmaster == null) {
                    error("Unknown master " + master);
                }
                ann.setMaster(nmaster);
            }
        }
        boolean ok = true;
        if ((entity.getUid() == null) || (entity.getUid().length() == 0)) {
            error("Unable to save event " + entity + ". Has no guid.");
            ok = false;
        }
        if (entity.getColPath() == null) {
            error("Unable to save event " + entity + ". Has no calendar.");
            ok = false;
        }
        BwEvent ev = ei.getEvent();
        if (ok && (globals.rintf != null) && globals.onlyUsersMap.check(ev)) {
            globals.currentUser = globals.getPrincipal(ev.getOwnerHref());
            globals.rintf.restoreEvent(ei);
        }
    } catch (CalFacadeException cfe) {
        if (cfe.getMessage().equals(CalFacadeException.noRecurrenceInstances)) {
            error("Event has no recurrence instances - not restored." + entity.getUid() + "\n" + atLine());
        } else {
            error("Unable to save event " + entity.getUid() + "\n" + atLine());
            cfe.printStackTrace();
        }
    } catch (Throwable t) {
        error("Unable to save event " + entity.getUid() + "\n" + atLine());
        t.printStackTrace();
    }
    pop();
}
Also used : Dur(net.fortuna.ical4j.model.Dur) EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) BwEventProxy(org.bedework.calfacade.BwEventProxy) Date(java.util.Date) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) BwPrincipal(org.bedework.calfacade.BwPrincipal) BwEventAnnotation(org.bedework.calfacade.BwEventAnnotation) DtEnd(net.fortuna.ical4j.model.property.DtEnd)

Example 74 with EventInfo

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

the class EventStringKeyRule method field.

public void field(String name) throws Throwable {
    try {
        /* Top should now be an event object */
        EventInfo ei = (EventInfo) getTop(EventInfo.class, name);
        BwEventAnnotation ann = null;
        BwEvent e = ei.getEvent();
        if (e instanceof BwEventProxy) {
            ann = ((BwEventProxy) e).getRef();
            if (ann.getOverride()) {
                // Overrides have everything set already
                return;
            }
            String match = getDigester().getMatch();
            if (match.contains("/target/")) {
                e = ann.getTarget();
            } else if (match.contains("/master/")) {
                e = ann.getMaster();
            } else {
                e = ann;
            }
        }
        if (name.equals("uid")) {
            e.setUid(stringFld());
        } else if (name.equals("recurrenceId")) {
            e.setRecurrenceId(stringFld());
        } else {
            unknownTag(name);
        }
    } catch (Throwable t) {
        handleException(t);
    }
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEventAnnotation(org.bedework.calfacade.BwEventAnnotation) BwEvent(org.bedework.calfacade.BwEvent) BwEventProxy(org.bedework.calfacade.BwEventProxy)

Example 75 with EventInfo

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

the class OrganizerRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    BwOrganizer entity = (BwOrganizer) pop();
    EventInfo ei = (EventInfo) getTop(EventInfo.class, name);
    BwEvent e = ei.getEvent();
    e.setOrganizer(entity);
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) BwOrganizer(org.bedework.calfacade.BwOrganizer)

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