Search in sources :

Example 1 with BwEventObj

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

the class EventRule method begin.

@Override
public void begin(final String ns, final String name, final Attributes att) throws Exception {
    super.begin(ns, kind, att);
    BwEvent ev = (BwEvent) pop();
    boolean override = (kind.equals(objectOverride));
    if (ev instanceof BwEventAnnotation) {
        BwEventAnnotation ann = (BwEventAnnotation) ev;
        ann.setOverride(override);
        ev = new BwEventProxy(ann);
        if (override) {
            /* The override is embedded in the event so the top() should be the master
         * Annotations will get the master and target set later.
         */
            EventInfo mei = (EventInfo) top();
            ann.setTarget(mei.getEvent());
            ann.setMaster(mei.getEvent());
        } else {
            /* Make up empty event object for us to fill in */
            BwEvent e = new BwEventObj();
            ann.setTarget(e);
            ann.setMaster(e);
        }
    } else if (override) {
        error("Restore error - override but not annotation.");
    }
    EventInfo ei = new EventInfo(ev);
    /* Initialise fields that may be missed when restoring earlier data */
    ev.setNoStart(false);
    push(ei);
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEventAnnotation(org.bedework.calfacade.BwEventAnnotation) BwEvent(org.bedework.calfacade.BwEvent) BwEventProxy(org.bedework.calfacade.BwEventProxy) BwEventObj(org.bedework.calfacade.BwEventObj)

Example 2 with BwEventObj

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

the class BwEventUtil method makeNewEvent.

private static EventInfo makeNewEvent(final IcalCallback cb, final int entityType, final String uid, final String colPath) throws CalFacadeException {
    final BwEvent ev = new BwEventObj();
    final EventInfo evinfo = new EventInfo(ev);
    // ev.setDtstamps();
    ev.setEntityType(entityType);
    ev.setCreatorHref(cb.getPrincipal().getPrincipalRef());
    ev.setOwnerHref(cb.getOwner().getPrincipalRef());
    ev.setUid(uid);
    ev.setColPath(colPath);
    final ChangeTable chg = evinfo.getChangeset(cb.getPrincipal().getPrincipalRef());
    // get that out of the way
    chg.changed(PropertyInfoIndex.UID, null, uid);
    evinfo.setNewEvent(true);
    return evinfo;
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) ChangeTable(org.bedework.calfacade.util.ChangeTable) BwEvent(org.bedework.calfacade.BwEvent) BwEventObj(org.bedework.calfacade.BwEventObj)

Example 3 with BwEventObj

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

the class BwFreeBusyUtil method toFreeBusy.

/**
 * @param cb
 * @param val
 * @return BwFreeBusy
 * @throws CalFacadeException
 */
public static EventInfo toFreeBusy(final IcalCallback cb, final VFreeBusy val) throws CalFacadeException {
    if (val == null) {
        return null;
    }
    boolean debug = getLog().isDebugEnabled();
    try {
        PropertyList pl = val.getProperties();
        if (pl == null) {
            // Empty VEvent
            return null;
        }
        BwEvent fb = new BwEventObj();
        EventInfo ei = new EventInfo(fb);
        ChangeTable chg = ei.getChangeset(cb.getPrincipal().getPrincipalRef());
        fb.setEntityType(IcalDefs.entityTypeFreeAndBusy);
        setDates(cb.getPrincipal().getPrincipalRef(), ei, (DtStart) pl.getProperty(Property.DTSTART), (DtEnd) pl.getProperty(Property.DTEND), (Duration) pl.getProperty(Property.DURATION));
        Iterator it = pl.iterator();
        while (it.hasNext()) {
            Property prop = (Property) it.next();
            String pval = prop.getValue();
            if ((pval != null) && (pval.length() == 0)) {
                pval = null;
            }
            PropertyInfoIndex pi = PropertyInfoIndex.fromName(prop.getName());
            if (pi == null) {
                debugMsg("Unknown property with name " + prop.getName() + " class " + prop.getClass() + " and value " + pval);
                continue;
            }
            switch(pi) {
                case ATTENDEE:
                    /* ------------------- Attendee -------------------- */
                    BwAttendee att = getAttendee(cb, (Attendee) prop);
                    fb.addAttendee(att);
                    chg.addValue(pi, att);
                    break;
                case COMMENT:
                    /* ------------------- Comment -------------------- */
                    // LANG
                    fb.addComment(null, pval);
                    chg.addValue(pi, pval);
                case DTEND:
                    break;
                case DTSTAMP:
                    /* ------------------- DtStamp -------------------- */
                    chg.changed(pi, fb.getDtstamp(), pval);
                    fb.setDtstamp(pval);
                case DTSTART:
                    break;
                case FREEBUSY:
                    /* ------------------- freebusy -------------------- */
                    FreeBusy fbusy = (FreeBusy) prop;
                    PeriodList perpl = fbusy.getPeriods();
                    Parameter par = getParameter(fbusy, "FBTYPE");
                    int fbtype;
                    if (par == null) {
                        fbtype = BwFreeBusyComponent.typeBusy;
                    } else if (par.equals(FbType.BUSY)) {
                        fbtype = BwFreeBusyComponent.typeBusy;
                    } else if (par.equals(FbType.BUSY_TENTATIVE)) {
                        fbtype = BwFreeBusyComponent.typeBusyTentative;
                    } else if (par.equals(FbType.BUSY_UNAVAILABLE)) {
                        fbtype = BwFreeBusyComponent.typeBusyUnavailable;
                    } else if (par.equals(FbType.FREE)) {
                        fbtype = BwFreeBusyComponent.typeFree;
                    } else {
                        if (debug) {
                            debugMsg("Unsupported parameter " + par.getName());
                        }
                        throw new IcalMalformedException("parameter " + par.getName());
                    }
                    BwFreeBusyComponent fbc = new BwFreeBusyComponent();
                    fbc.setType(fbtype);
                    Iterator perit = perpl.iterator();
                    while (perit.hasNext()) {
                        Period per = (Period) perit.next();
                        fbc.addPeriod(per);
                    }
                    fb.addFreeBusyPeriod(fbc);
                    chg.addValue(pi, fbc);
                    break;
                case ORGANIZER:
                    /* ------------------- Organizer -------------------- */
                    BwOrganizer org = getOrganizer(cb, (Organizer) prop);
                    fb.setOrganizer(org);
                    chg.addValue(pi, org);
                    break;
                case UID:
                    /* ------------------- Uid -------------------- */
                    chg.changed(pi, fb.getUid(), pval);
                    fb.setUid(pval);
                    break;
                default:
                    if (debug) {
                        debugMsg("Unsupported property with class " + prop.getClass() + " and value " + pval);
                    }
            }
        }
        return ei;
    } catch (CalFacadeException cfe) {
        throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : BwFreeBusyComponent(org.bedework.calfacade.BwFreeBusyComponent) EventInfo(org.bedework.calfacade.svc.EventInfo) VFreeBusy(net.fortuna.ical4j.model.component.VFreeBusy) FreeBusy(net.fortuna.ical4j.model.property.FreeBusy) PeriodList(net.fortuna.ical4j.model.PeriodList) Period(net.fortuna.ical4j.model.Period) BwEvent(org.bedework.calfacade.BwEvent) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) PropertyList(net.fortuna.ical4j.model.PropertyList) PropertyInfoIndex(org.bedework.util.calendar.PropertyIndex.PropertyInfoIndex) ChangeTable(org.bedework.calfacade.util.ChangeTable) Iterator(java.util.Iterator) Parameter(net.fortuna.ical4j.model.Parameter) Property(net.fortuna.ical4j.model.Property) BwAttendee(org.bedework.calfacade.BwAttendee) BwEventObj(org.bedework.calfacade.BwEventObj) BwOrganizer(org.bedework.calfacade.BwOrganizer)

Example 4 with BwEventObj

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

the class BwCalDAVEvent method getEvinfo.

/* ====================================================================
   *                      Private methods
   * ==================================================================== */
EventInfo getEvinfo() throws WebdavException {
    if (evi == null) {
        evi = new EventInfo(new BwEventObj());
        ev = evi.getEvent();
    }
    return evi;
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEventObj(org.bedework.calfacade.BwEventObj)

Example 5 with BwEventObj

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

the class EntityBuilder method makeEvent.

/**
 * @param expanded true if we are doing this for an expanded retrieval
 *                 that is, treat everything as instances.
 * @return an event object
 * @throws CalFacadeException on error
 */
@SuppressWarnings("unchecked")
EventInfo makeEvent(final String id, final boolean expanded) throws CalFacadeException {
    final boolean override = !expanded && getBool(PropertyInfoIndex.OVERRIDE);
    final boolean tryCache = (currentMode == guestMode) && publick;
    final String cacheKey = id + override;
    retrievals++;
    if (tryCache) {
        checkPurge();
        final EventCacheEntry ece = eventCache.get(cacheKey);
        if (ece != null) {
            hits++;
            ece.update();
            if (debug && ((retrievals % 500) == 0)) {
                debug("Retrievals: " + retrievals + " hits: " + hits + " purges: " + purges + " flushes: " + flushes + " size: " + eventCache.size());
            }
            return ece.ei;
        }
    }
    final BwEvent ev;
    if (override) {
        ev = new BwEventAnnotation();
        final BwEventAnnotation ann = (BwEventAnnotation) ev;
        ann.setOverride(true);
    } else {
        ev = new BwEventObj();
    }
    final EventInfo ei = new EventInfo(ev);
    /*
    Float score = (Float)sd.getFirstValue("score");

    if (score != null) {
      bwkey.setScore(score);
    }
    */
    restoreSharedEntity(ev);
    ev.setDeleted(getBool(PropertyInfoIndex.DELETED));
    ev.setName(getString(PropertyInfoIndex.NAME));
    ev.setCalSuite(getString(PropertyInfoIndex.CALSUITE));
    restoreCategories(ev);
    ev.setSummaries((Set<BwString>) restoreBwStringSet(PropertyInfoIndex.SUMMARY, false));
    ev.setDescriptions((Set<BwLongString>) restoreBwStringSet(PropertyInfoIndex.DESCRIPTION, true));
    ev.setEntityType(makeEntityType(getString(PropertyInfoIndex.ENTITY_TYPE)));
    ev.setClassification(getString(PropertyInfoIndex.CLASS));
    ev.setLink(getString(PropertyInfoIndex.URL));
    ev.setGeo(restoreGeo());
    ev.setStatus(getString(PropertyInfoIndex.STATUS));
    ev.setCost(getString(PropertyInfoIndex.COST));
    ev.setOrganizer(restoreOrganizer());
    ev.setDtstamp(getString(PropertyInfoIndex.DTSTAMP));
    ev.setLastmod(getString(PropertyInfoIndex.LAST_MODIFIED));
    ev.setCreated(getString(PropertyInfoIndex.CREATED));
    ev.setStag(getString(PropertyInfoIndex.SCHEDULE_TAG));
    ev.setPriority(getInteger(PropertyInfoIndex.PRIORITY));
    ev.setSequence(getInt(PropertyInfoIndex.SEQUENCE));
    ev.setLocationUid(getString(PropertyInfoIndex.LOCATION_UID));
    ev.setUid(getString(PropertyInfoIndex.UID));
    ev.setTransparency(getString(PropertyInfoIndex.TRANSP));
    ev.setPercentComplete(getInteger(PropertyInfoIndex.PERCENT_COMPLETE));
    ev.setCompleted(getString(PropertyInfoIndex.COMPLETED));
    ev.setScheduleMethod(getInt(PropertyInfoIndex.SCHEDULE_METHOD));
    ev.setOriginator(getString(PropertyInfoIndex.ORIGINATOR));
    ev.setScheduleState(getInt(PropertyInfoIndex.SCHEDULE_STATE));
    ev.setOrganizerSchedulingObject(getBoolean(PropertyInfoIndex.ORGANIZER_SCHEDULING_OBJECT));
    ev.setAttendeeSchedulingObject(getBoolean(PropertyInfoIndex.ATTENDEE_SCHEDULING_OBJECT));
    ev.setRelatedTo(restoreRelatedTo());
    ev.setXproperties(restoreXprops());
    restoreReqStat(ev);
    ev.setCtoken(getString(PropertyInfoIndex.CTOKEN));
    ev.setRecurring(getBoolean(PropertyInfoIndex.RECURRING));
    ev.setRecurrenceId(getString(PropertyInfoIndex.RECURRENCE_ID));
    ev.setRrules(getStringSet(PropertyInfoIndex.RRULE));
    ev.setExrules(getStringSet(PropertyInfoIndex.EXRULE));
    ev.setRdates(restoreBwDateTimeSet(PropertyInfoIndex.RDATE));
    ev.setExdates(restoreBwDateTimeSet(PropertyInfoIndex.EXDATE));
    ev.setDtstart(unindexDate(PropertyInfoIndex.DTSTART));
    ev.setDtend(unindexDate(PropertyInfoIndex.DTEND));
    ev.setNoStart(Boolean.parseBoolean(getString(PropertyInfoIndex.NO_START)));
    ev.setEndType(getString(PropertyInfoIndex.END_TYPE).charAt(0));
    ev.setDuration(getString(PropertyInfoIndex.DURATION));
    ev.setAlarms(restoreAlarms());
    /* uuu Attachment */
    final boolean vpoll = ev.getEntityType() == IcalDefs.entityTypeVpoll;
    ev.setAttendees(restoreAttendees(vpoll));
    ev.setRecipients(getStringSet(PropertyInfoIndex.RECIPIENT));
    ev.setComments((Set<BwString>) restoreBwStringSet(PropertyInfoIndex.COMMENT, false));
    restoreContacts(ev);
    ev.setResources((Set<BwString>) restoreBwStringSet(PropertyInfoIndex.RESOURCES, false));
    if (vpoll) {
        final Set<String> pollItems = getStringSet(PropertyInfoIndex.POLL_ITEM);
        if (!Util.isEmpty(pollItems)) {
            for (final String s : pollItems) {
                ev.addPollItem(s);
            }
        }
        ev.setPollMode(getString(PropertyInfoIndex.POLL_MODE));
        ev.setPollWinner(getInteger(PropertyInfoIndex.POLL_WINNER));
        ev.setPollProperties(getString(PropertyInfoIndex.POLL_PROPERTIES));
    }
    if (tryCache) {
        synchronized (eventCache) {
            eventCache.put(cacheKey, new EventCacheEntry(cacheKey, ei));
        }
    }
    return ei;
}
Also used : BwLongString(org.bedework.calfacade.BwLongString) EventInfo(org.bedework.calfacade.svc.EventInfo) BwEventAnnotation(org.bedework.calfacade.BwEventAnnotation) BwEvent(org.bedework.calfacade.BwEvent) BwString(org.bedework.calfacade.BwString) BwLongString(org.bedework.calfacade.BwLongString) BwString(org.bedework.calfacade.BwString) BwEventObj(org.bedework.calfacade.BwEventObj)

Aggregations

BwEventObj (org.bedework.calfacade.BwEventObj)14 BwEvent (org.bedework.calfacade.BwEvent)13 EventInfo (org.bedework.calfacade.svc.EventInfo)10 BwAttendee (org.bedework.calfacade.BwAttendee)5 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)5 Period (net.fortuna.ical4j.model.Period)3 BwEventProxy (org.bedework.calfacade.BwEventProxy)3 BwFreeBusyComponent (org.bedework.calfacade.BwFreeBusyComponent)3 BwOrganizer (org.bedework.calfacade.BwOrganizer)3 BwString (org.bedework.calfacade.BwString)3 ArrayList (java.util.ArrayList)2 TreeSet (java.util.TreeSet)2 VFreeBusy (net.fortuna.ical4j.model.component.VFreeBusy)2 BwCalendar (org.bedework.calfacade.BwCalendar)2 BwDateTime (org.bedework.calfacade.BwDateTime)2 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)2 ScheduleResult (org.bedework.calfacade.ScheduleResult)2 ChangeTable (org.bedework.calfacade.util.ChangeTable)2 EventPeriod (org.bedework.calfacade.util.Granulator.EventPeriod)2 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)2