Search in sources :

Example 6 with ChangeTableEntry

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

the class PriorityPropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    BwEvent ev = ui.getEvent();
    PriorityPropType pr = (PriorityPropType) ui.getProp();
    ChangeTableEntry cte = ui.getCte();
    BigInteger val = pr.getInteger();
    BigInteger evVal = null;
    if (ev.getPriority() != null) {
        evVal = BigInteger.valueOf(ev.getPriority());
    }
    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()) {
        return new UpdateResult("No update specified for " + ui.getPropName());
    } else {
        if (!val.equals(evVal)) {
            return new UpdateResult("Values don't match for update to " + ui.getPropName());
        }
        val = ((PriorityPropType) ui.getUpdprop()).getInteger();
    }
    if (val != null) {
        int ival = val.intValue();
        if ((ival < 0) || (ival > 9)) {
            return new UpdateResult("Value for " + ui.getPropName() + " must be >= 0 and <= 9 ");
        }
    }
    if (Util.cmpObjval(val, evVal) != 0) {
        cte.setChanged(evVal, val);
        ev.setPriority(val.intValue());
    }
    return UpdateResult.getOkResult();
}
Also used : BigInteger(java.math.BigInteger) BwEvent(org.bedework.calfacade.BwEvent) PriorityPropType(ietf.params.xml.ns.icalendar_2.PriorityPropType) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)

Example 7 with ChangeTableEntry

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

the class RdatePropUpdater method applyUpdate.

public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    try {
        BwEvent ev = ui.getEvent();
        ChangeTableEntry cte = ui.getCte();
        Set<BwDateTime> evDts = ev.getRdates();
        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 rdate 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 8 with ChangeTableEntry

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

the class AlarmPropUpdater method flagChange.

protected void flagChange(final BwAlarm val, final UpdateInfo ui) {
    ChangeTableEntry cte = ui.getCte();
    if (cte != null) {
        cte.setChanged(null, null);
    }
    ChangeTable ct = ui.getEi().getChangeset(ui.getUserHref());
    cte = ct.getEntry(PropertyInfoIndex.VALARM);
    if (cte != null) {
        cte.setChanged(null, val);
    }
    getAS(ui).add(val);
}
Also used : ChangeTable(org.bedework.calfacade.util.ChangeTable) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry)

Example 9 with ChangeTableEntry

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

the class CompletedPropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    BwEvent ev = ui.getEvent();
    CompletedPropType pr = (CompletedPropType) ui.getProp();
    ChangeTableEntry cte = ui.getCte();
    String val = XcalUtil.getIcalFormatDateTime(pr.getUtcDateTime());
    String evVal = null;
    if (ev.getCompleted() != null) {
        evVal = ev.getCompleted();
    }
    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()) {
        return new UpdateResult("No update specified for " + ui.getPropName());
    } else {
        if (!val.equals(evVal)) {
            return new UpdateResult("Values don't match for update to " + ui.getPropName());
        }
        val = XcalUtil.getIcalFormatDateTime(((CompletedPropType) ui.getUpdprop()).getUtcDateTime());
    }
    if (Util.cmpObjval(val, evVal) != 0) {
        cte.setChanged(evVal, val);
        ev.setCompleted(val);
    }
    return UpdateResult.getOkResult();
}
Also used : CompletedPropType(ietf.params.xml.ns.icalendar_2.CompletedPropType) BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)

Example 10 with ChangeTableEntry

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

the class DtEndDuePropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    /* For start, end and duration we have to finish up at the end after all
     * changes are made.
     */
    try {
        BwEvent ev = ui.getEvent();
        DateDatetimePropertyType dt = (DateDatetimePropertyType) ui.getProp();
        if (dt instanceof DuePropType) {
            if (ev.getEntityType() != IcalDefs.entityTypeTodo) {
                return new UpdateResult("DUE only valid for tasks");
            }
        } else {
            if (ev.getEntityType() == IcalDefs.entityTypeTodo) {
                return new UpdateResult("DUE required for tasks");
            }
        }
        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 (ev.getEndType() != StartEndComponent.endTypeDate) {
                return new UpdateResult("Entity has no end date - cannot remove");
            }
            cte.setDeleted(ev.getDtend());
            ds.end = null;
            return UpdateResult.getOkResult();
        }
        if (ui.isAdd()) {
            if (ev.getEndType() == StartEndComponent.endTypeDate) {
                return new UpdateResult("Entity already has end date - cannot add");
            }
            ds.end = BwDateTime.makeBwDateTime(dt);
            cte.setAdded(ds.end);
            return UpdateResult.getOkResult();
        }
        /* Changing dtend - either value or parameters */
        if (ev.getEndType() != StartEndComponent.endTypeDate) {
            return new UpdateResult("Entity has no end date - cannot change");
        }
        Holder<BwDateTime> resdt = new Holder<BwDateTime>();
        UpdateResult ur = makeDt(ev.getDtend(), resdt, ui);
        if (!ur.getOk()) {
            return ur;
        }
        if (resdt.value != null) {
            cte.setChanged(ev.getDtend(), resdt.value);
            ds.end = resdt.value;
        }
        return UpdateResult.getOkResult();
    } catch (CalFacadeException cfe) {
        throw new WebdavException(cfe);
    }
}
Also used : DuePropType(ietf.params.xml.ns.icalendar_2.DuePropType) BwDateTime(org.bedework.calfacade.BwDateTime) DateDatetimePropertyType(ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType) Holder(javax.xml.ws.Holder) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

ChangeTableEntry (org.bedework.calfacade.util.ChangeTableEntry)32 BwEvent (org.bedework.calfacade.BwEvent)26 UpdateResult (org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)20 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)10 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)10 BwDateTime (org.bedework.calfacade.BwDateTime)7 BwString (org.bedework.calfacade.BwString)7 BwXproperty (org.bedework.calfacade.BwXproperty)7 ChangeTable (org.bedework.calfacade.util.ChangeTable)7 BwAttendee (org.bedework.calfacade.BwAttendee)4 BwCategory (org.bedework.calfacade.BwCategory)4 DateDatetimePropertyType (ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType)3 TextPropertyType (ietf.params.xml.ns.icalendar_2.TextPropertyType)3 Holder (javax.xml.ws.Holder)3 BwContact (org.bedework.calfacade.BwContact)3 BwEventProxy (org.bedework.calfacade.BwEventProxy)3 BigInteger (java.math.BigInteger)2 HashMap (java.util.HashMap)2 TreeSet (java.util.TreeSet)2 BwOrganizer (org.bedework.calfacade.BwOrganizer)2