use of ietf.params.xml.ns.icalendar_2.TextListPropertyType 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();
}
Aggregations