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());
}
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);
}
}
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);
}
}
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();
}
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);
}
}
Aggregations