Search in sources :

Example 96 with BwEvent

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

the class DescriptionPropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    final BwEvent ev = ui.getEvent();
    if (ui.isRemove()) {
        ui.getCte().setDeleted(ev.getDescription());
        ev.setDescription(null);
        return UpdateResult.getOkResult();
    }
    if (ui.getUpdprop() == null) {
        // No change - parameters only upated?
        return UpdateResult.getOkResult();
    }
    final String val = ((TextPropertyType) ui.getUpdprop()).getText();
    if (ui.getCte().setChanged(ev.getDescription(), val)) {
        ev.setDescription(val);
    }
    return UpdateResult.getOkResult();
}
Also used : BwEvent(org.bedework.calfacade.BwEvent) TextPropertyType(ietf.params.xml.ns.icalendar_2.TextPropertyType)

Example 97 with BwEvent

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

the class SequencePropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    BwEvent ev = ui.getEvent();
    SequencePropType pr = (SequencePropType) ui.getProp();
    ChangeTableEntry cte = ui.getCte();
    int val = pr.getInteger().intValue();
    int evVal = ev.getSequence();
    if (ui.isRemove()) {
        if (evVal == 0) {
            return new UpdateResult("Entity has no " + ui.getPropName() + " property - cannot remove");
        }
        val = 0;
    } else if (ui.isAdd()) {
        if (evVal != 0) {
            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 != evVal) {
            return new UpdateResult("Values don't match for update to " + ui.getPropName());
        }
        val = ((SequencePropType) ui.getUpdprop()).getInteger().intValue();
    }
    if (val < 0) {
        return new UpdateResult("Value for " + ui.getPropName() + " must be >= 0 ");
    }
    if (val != evVal) {
        cte.setChanged(evVal, val);
        ev.setSequence(val);
    }
    return UpdateResult.getOkResult();
}
Also used : SequencePropType(ietf.params.xml.ns.icalendar_2.SequencePropType) BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)

Example 98 with BwEvent

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

the class StatusPropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    BwEvent ev = ui.getEvent();
    StatusPropType pr = (StatusPropType) ui.getProp();
    ChangeTableEntry cte = ui.getCte();
    String val = pr.getText();
    String evVal = ev.getStatus();
    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 = ((StatusPropType) ui.getUpdprop()).getText();
    }
    if (!Util.equalsString(val, evVal)) {
        cte.setChanged(evVal, val);
        ev.setStatus(val);
    }
    return UpdateResult.getOkResult();
}
Also used : StatusPropType(ietf.params.xml.ns.icalendar_2.StatusPropType) BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)

Example 99 with BwEvent

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

the class SummaryPropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    BwEvent ev = ui.getEvent();
    if (ui.isRemove()) {
        return new UpdateResult("cannot remove: " + ui.getPropName());
    }
    String val = ((TextPropertyType) ui.getUpdprop()).getText();
    if (ui.getCte().setChanged(ev.getSummary(), val)) {
        ev.setSummary(val);
    }
    return UpdateResult.getOkResult();
}
Also used : BwEvent(org.bedework.calfacade.BwEvent) TextPropertyType(ietf.params.xml.ns.icalendar_2.TextPropertyType) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)

Example 100 with BwEvent

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

the class UrlPropUpdater method applyUpdate.

@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    BwEvent ev = ui.getEvent();
    UrlPropType pr = (UrlPropType) ui.getProp();
    ChangeTableEntry cte = ui.getCte();
    String val = pr.getUri();
    String evVal = ev.getLink();
    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 = ((UrlPropType) ui.getUpdprop()).getUri();
    }
    if (!Util.equalsString(val, evVal)) {
        cte.setChanged(evVal, val);
        ev.setLink(val);
    }
    return UpdateResult.getOkResult();
}
Also used : BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult) UrlPropType(ietf.params.xml.ns.icalendar_2.UrlPropType)

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