use of org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult in project bw-calendar-engine by Bedework.
the class TriggerPropUpdater method applyUpdate.
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
BwAlarm alarm = ui.getSubComponent().getAlarm();
TriggerPropType pr = (TriggerPropType) ui.getProp();
if (ui.isRemove()) {
return new UpdateResult("Cannot remove " + ui.getPropName());
}
if (ui.isAdd()) {
return new UpdateResult("Cannot add " + ui.getPropName());
}
if (!ui.isChange()) {
return new UpdateResult("No update specified for " + ui.getPropName());
}
/* Ensure the old value matches */
if (pr.getDateTime() != null) {
if (!alarm.getTriggerDateTime()) {
return new UpdateResult("Values don't match for update to " + ui.getPropName());
}
} else {
if (alarm.getTriggerDateTime()) {
return new UpdateResult("Values don't match for update to " + ui.getPropName());
}
}
pr = (TriggerPropType) ui.getUpdprop();
if (pr.getDateTime() != null) {
alarm.setTrigger(XcalUtil.getIcalFormatDateTime(pr.getDateTime()));
alarm.setTriggerDateTime(true);
} else {
alarm.setTrigger(pr.getDuration());
RelatedParamType r = (RelatedParamType) XcalUtil.findParam(pr, XcalTags.related);
alarm.setTriggerStart((r == null) || (r.getText().toUpperCase().equals("START")));
}
flagChange(alarm, ui);
return UpdateResult.getOkResult();
}
use of org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult 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();
}
use of org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult in project bw-calendar-engine by Bedework.
the class XbwCategoryPropUpdater method applyUpdate.
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
try {
final ChangeTableEntry cte = ui.getCte();
final BwEvent ev = ui.getEvent();
final List<BwXproperty> xcats = ev.getXproperties(BwXproperty.xBedeworkCategories);
final Set<BwCategory> cats = ev.getCategories();
final String lang = UpdaterUtil.getLang(ui.getProp());
final String xval = getValue(ui.getProp());
final BwString cstr = new BwString(lang, xval);
if (ui.isRemove()) {
if (Util.isEmpty(xcats)) {
// Nothing to remove
return UpdateResult.getOkResult();
}
for (final BwXproperty xp : xcats) {
if (!xp.getValue().equals(xval)) {
continue;
}
// Found
ev.removeXproperty(xp);
cte.addRemovedValue(xp);
/* Do we have a corresponding category */
for (final BwCategory c : cats) {
if (c.getWord().equals(cstr)) {
ev.removeCategory(c);
cte.addRemovedValue(c);
break;
}
}
return UpdateResult.getOkResult();
}
return UpdateResult.getOkResult();
}
if (ui.isAdd()) {
for (final BwXproperty xp : xcats) {
if (xp.getValue().equals(xval)) {
return new UpdateResult("Entity already has " + ui.getPropName() + " property with that value - cannot add");
}
}
/* Add the xprop or a category */
if (!checkCategory(ui, ev, cats, lang, xval)) {
final BwXproperty xp = makeXprop(lang, xval);
ev.addXproperty(xp);
cte.addValue(xp);
}
return UpdateResult.getOkResult();
}
if (ui.isChange()) {
for (final BwXproperty xp : xcats) {
if (xp.getValue().equals(xval)) {
// Found
ev.removeXproperty(xp);
cte.addRemovedValue(xp);
final String nlang = UpdaterUtil.getLang(ui.getUpdprop());
final String nxval = getValue(ui.getUpdprop());
if (!checkCategory(ui, ev, cats, nlang, nxval)) {
final BwXproperty nxp = makeXprop(nlang, nxval);
ev.addXproperty(nxp);
cte.addValue(nxp);
}
return UpdateResult.getOkResult();
}
}
}
return UpdateResult.getOkResult();
} catch (final CalFacadeException cfe) {
throw new WebdavException(cfe);
}
}
use of org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult in project bw-calendar-engine by Bedework.
the class DurationPropUpdater method applyUpdate.
@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
if (ui.getSubComponent() != null) {
return alarmDurationPropUpdater.applyUpdate(ui);
}
BwEvent ev = ui.getEvent();
DurationPropType dur = (DurationPropType) 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 (ev.getEndType() != StartEndComponent.endTypeDuration) {
return new UpdateResult("Entity has no duration - cannot remove");
}
cte.setDeleted(ev.getDuration());
ds.duration = null;
return UpdateResult.getOkResult();
}
if (ui.isAdd()) {
if (ev.getEndType() == StartEndComponent.endTypeDuration) {
return new UpdateResult("Entity already has duration - cannot add");
}
ds.duration = dur.getDuration();
cte.setAdded(ds.duration);
return UpdateResult.getOkResult();
}
/* Changing duration */
if (ev.getEndType() != StartEndComponent.endTypeDuration) {
return new UpdateResult("Entity has no duration - cannot change");
}
dur = (DurationPropType) ui.getUpdprop();
if (!dur.getDuration().equals(ev.getDuration())) {
cte.setChanged(ev.getDuration(), dur.getDuration());
}
ds.duration = dur.getDuration();
return UpdateResult.getOkResult();
}
use of org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult in project bw-calendar-engine by Bedework.
the class GeoPropUpdater method applyUpdate.
@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
BwEvent ev = ui.getEvent();
GeoPropType pr = (GeoPropType) ui.getProp();
ChangeTableEntry cte = ui.getCte();
BwGeo val = new BwGeo(new BigDecimal(String.valueOf(pr.getLatitude())), new BigDecimal(String.valueOf(pr.getLongitude())));
BwGeo evVal = ev.getGeo();
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());
}
pr = (GeoPropType) ui.getUpdprop();
val = new BwGeo(new BigDecimal(String.valueOf(pr.getLatitude())), new BigDecimal(String.valueOf(pr.getLongitude())));
}
if (Util.cmpObjval(val, evVal) != 0) {
cte.setChanged(evVal, val);
ev.setGeo(val);
}
return UpdateResult.getOkResult();
}
Aggregations