Search in sources :

Example 31 with UpdateResult

use of org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult in project bw-calendar-engine by Bedework.

the class PercentCompletePropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    BwEvent ev = ui.getEvent();
    PercentCompletePropType pr = (PercentCompletePropType) ui.getProp();
    ChangeTableEntry cte = ui.getCte();
    BigInteger val = pr.getInteger();
    BigInteger evVal = null;
    if (ev.getPercentComplete() != null) {
        evVal = BigInteger.valueOf(ev.getPercentComplete());
    }
    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 = ((PercentCompletePropType) ui.getUpdprop()).getInteger();
    }
    if (Util.cmpObjval(val, evVal) != 0) {
        cte.setChanged(evVal, val);
        ev.setPercentComplete(val.intValue());
    }
    return UpdateResult.getOkResult();
}
Also used : PercentCompletePropType(ietf.params.xml.ns.icalendar_2.PercentCompletePropType) BigInteger(java.math.BigInteger) BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)

Aggregations

UpdateResult (org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)31 BwEvent (org.bedework.calfacade.BwEvent)23 ChangeTableEntry (org.bedework.calfacade.util.ChangeTableEntry)20 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)11 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)11 BwString (org.bedework.calfacade.BwString)6 TextPropertyType (ietf.params.xml.ns.icalendar_2.TextPropertyType)4 BwAlarm (org.bedework.calfacade.BwAlarm)4 BwDateTime (org.bedework.calfacade.BwDateTime)4 BwXproperty (org.bedework.calfacade.BwXproperty)4 BaseComponentType (ietf.params.xml.ns.icalendar_2.BaseComponentType)2 BasePropertyType (ietf.params.xml.ns.icalendar_2.BasePropertyType)2 DateDatetimePropertyType (ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType)2 DurationPropType (ietf.params.xml.ns.icalendar_2.DurationPropType)2 BigInteger (java.math.BigInteger)2 QName (javax.xml.namespace.QName)2 Holder (javax.xml.ws.Holder)2 ParameterUpdater (org.bedework.caldav.bwserver.ParameterUpdater)2 BwContact (org.bedework.calfacade.BwContact)2 BwLocation (org.bedework.calfacade.BwLocation)2