Search in sources :

Example 31 with BwEvent

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

the class CalintfHelper method unindexEntity.

protected void unindexEntity(final EventInfo ei) throws CalFacadeException {
    final BwEvent ev = ei.getEvent();
    if (ev.getRecurrenceId() != null) {
        // Cannot index single instance
        warn("Tried to unindex a recurrence instance");
        return;
    }
    getIndexer(ev).unindexEntity(ev.getHref());
}
Also used : BwEvent(org.bedework.calfacade.BwEvent)

Example 32 with BwEvent

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

the class DtStartPropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    try {
        BwEvent ev = ui.getEvent();
        boolean scheduleReply = ev.getScheduleMethod() == ScheduleMethods.methodTypeReply;
        // No dates valid for reply
        DtstartPropType dt = (DtstartPropType) ui.getProp();
        DatesState ds = (DatesState) ui.getState(DatesState.stateName);
        if (ds == null) {
            ds = new DatesState(ev);
            ui.saveState(DatesState.stateName, ds);
        }
        ChangeTableEntry cte = ui.getCte();
        if (ui.isRemove()) {
            if (!scheduleReply && (ev.getEntityType() != IcalDefs.entityTypeTodo)) {
                return new UpdateResult("Entity requires start date");
            }
            cte.setDeleted(ev.getDtstart());
            ds.start = null;
            return UpdateResult.getOkResult();
        }
        if (ui.isAdd()) {
            if (!ev.getNoStart()) {
                return new UpdateResult("Entity already has start date - cannot add");
            }
            ds.start = BwDateTime.makeBwDateTime(dt);
            cte.setAdded(ds.start);
            return UpdateResult.getOkResult();
        }
        /* Changing dtstart - either value or parameters */
        if (ev.getNoStart()) {
            return new UpdateResult("Entity has no start date - cannot change");
        }
        Holder<BwDateTime> resdt = new Holder<BwDateTime>();
        UpdateResult ur = makeDt(ev.getDtstart(), resdt, ui);
        if (!ur.getOk()) {
            return ur;
        }
        if (resdt.value != null) {
            cte.setChanged(ev.getDtstart(), resdt.value);
            ds.start = resdt.value;
        }
        return UpdateResult.getOkResult();
    } catch (CalFacadeException cfe) {
        throw new WebdavException(cfe);
    }
}
Also used : BwDateTime(org.bedework.calfacade.BwDateTime) Holder(javax.xml.ws.Holder) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry) DtstartPropType(ietf.params.xml.ns.icalendar_2.DtstartPropType) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 33 with BwEvent

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

the class ExdatePropUpdater method applyUpdate.

public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    try {
        BwEvent ev = ui.getEvent();
        ChangeTableEntry cte = ui.getCte();
        Set<BwDateTime> evDts = ev.getExdates();
        DateDatetimePropertyType dt = (DateDatetimePropertyType) ui.getProp();
        String dtUTC = XcalUtil.getUTC(dt, ui.getTzs());
        if (ui.isRemove()) {
            removeDt(dtUTC, evDts, cte);
            return UpdateResult.getOkResult();
        }
        BwDateTime prdt = BwDateTime.makeBwDateTime(dt);
        if (ui.isAdd()) {
            addDt(prdt, evDts, cte);
            return UpdateResult.getOkResult();
        }
        /* Changing exdate maybe just changing the parameters (UTC unchanged) or
       * an actual value change. Second case is really a remove and add
       */
        BwDateTime newdt = BwDateTime.makeBwDateTime((DateDatetimePropertyType) ui.getUpdprop());
        if (prdt.getDate().equals(newdt.getDate())) {
            // tzid or date only?
            if (prdt.getTzid().equals(newdt.getTzid()) && (prdt.getDateType() == newdt.getDateType())) {
                // Unchanged
                return UpdateResult.getOkResult();
            } else {
                evDts.remove(prdt);
                evDts.add(newdt);
                cte.addChangedValue(newdt);
            }
        }
        /* Do remove then add */
        removeDt(prdt.getDate(), evDts, cte);
        addDt(newdt, evDts, cte);
        return UpdateResult.getOkResult();
    } catch (WebdavException we) {
        throw we;
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : BwDateTime(org.bedework.calfacade.BwDateTime) DateDatetimePropertyType(ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry)

Example 34 with BwEvent

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

the class LangTextListPropUpdater method applyUpdate.

public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    BwEvent ev = ui.getEvent();
    Collection<String> adds = new ArrayList<String>();
    Collection<String> removes = new ArrayList<String>();
    /* Figure out what we need to add/remove */
    TextListPropertyType prop = (TextListPropertyType) ui.getProp();
    String lang = UpdaterUtil.getLang(ui.getProp());
    if (ui.isAdd()) {
        adds.addAll(prop.getText());
    } else if (ui.isRemove()) {
        removes.addAll(prop.getText());
    } else {
        // Diff the prop value and the updProp value
        TextListPropertyType updProp = (TextListPropertyType) ui.getUpdprop();
        List<String> oldVals = prop.getText();
        List<String> updVals = updProp.getText();
        for (String s : updVals) {
            if (!oldVals.contains(s)) {
                adds.add(s);
            }
        }
        for (String s : oldVals) {
            if (!updVals.contains(s)) {
                removes.add(s);
            }
        }
    }
    for (String s : adds) {
        addValue(ev, new BwString(lang, s), ui);
    }
    for (String s : removes) {
        if (!removeValue(ev, new BwString(lang, s), ui)) {
            break;
        }
    }
    return UpdateResult.getOkResult();
}
Also used : TextListPropertyType(ietf.params.xml.ns.icalendar_2.TextListPropertyType) ArrayList(java.util.ArrayList) BwEvent(org.bedework.calfacade.BwEvent) List(java.util.List) ArrayList(java.util.ArrayList) BwString(org.bedework.calfacade.BwString) BwString(org.bedework.calfacade.BwString)

Example 35 with BwEvent

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

the class LocationPropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    try {
        final BwEvent ev = ui.getEvent();
        final ChangeTableEntry cte = ui.getCte();
        BwString val = new BwString(UpdaterUtil.getLang(ui.getProp()), ((TextPropertyType) ui.getProp()).getText());
        final BwLocation evLoc = ev.getLocation();
        BwString evVal = null;
        if (evLoc != null) {
            evVal = evLoc.getAddress();
        }
        if (ui.isRemove()) {
            if (evVal == null) {
                return new UpdateResult("Entity has no " + ui.getPropName() + " property - cannot remove");
            }
            val = null;
        } else if (ui.isAdd()) {
            if (evVal != null) {
                return new UpdateResult("Entity already has " + ui.getPropName() + " property - cannot add");
            }
        } else if (!ui.isChange()) {
            final ParameterUpdater.UpdateInfo langUpd = UpdaterUtil.findLangUpdate(ui.getParamUpdates());
            if (langUpd == null) {
                return new UpdateResult("No update specified for " + ui.getPropName());
            }
            String lang = val.getLang();
            if (langUpd.isRemove()) {
                lang = null;
            } else if (langUpd.isAdd()) {
                lang = ((TextParameterType) langUpd.getParam()).getText();
            } else if (langUpd.getUpdparam() != null) {
                lang = ((TextParameterType) langUpd.getUpdparam()).getText();
            }
            if (!Util.equalsString(lang, val.getLang())) {
                val = new BwString(lang, val.getValue());
            }
        } else {
            if (!val.equals(evVal)) {
                return new UpdateResult("Values don't match for update to " + ui.getPropName());
            }
            val = new BwString(UpdaterUtil.getLang(ui.getUpdprop()), ((TextPropertyType) ui.getUpdprop()).getText());
        }
        if (val == null) {
            cte.setDeleted(ev.getLocation());
            ev.setLocation(null);
        } else if (Util.cmpObjval(val, evVal) != 0) {
            BwLocation loc = ui.getIcalCallback().findLocation(val);
            if (loc == null) {
                loc = BwLocation.makeLocation();
                loc.setAddress(val);
                ui.getIcalCallback().addLocation(loc);
            }
            if (cte.setChanged(evLoc, loc)) {
                ev.setLocation(loc);
            }
        }
        return UpdateResult.getOkResult();
    } catch (final CalFacadeException cfe) {
        throw new WebdavException(cfe);
    }
}
Also used : BwLocation(org.bedework.calfacade.BwLocation) TextParameterType(ietf.params.xml.ns.icalendar_2.TextParameterType) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry) BwString(org.bedework.calfacade.BwString) BwString(org.bedework.calfacade.BwString) TextPropertyType(ietf.params.xml.ns.icalendar_2.TextPropertyType) ParameterUpdater(org.bedework.caldav.bwserver.ParameterUpdater) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

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