use of org.bedework.caldav.util.notifications.ChangedPropertyType in project bw-calendar-engine by Bedework.
the class NotificationsInfo method getDeleted.
/**
* Call for a deleted event
*
* @param currentAuth
* @param ev
* @return resource deleted notification.
* @throws CalFacadeException
*/
public static ResourceChangeType getDeleted(final String currentAuth, final BwEvent ev) throws CalFacadeException {
try {
ResourceChangeType rc = new ResourceChangeType();
DeletedType del = new DeletedType();
del.setHref(getHref(ev));
del.setChangedBy(getChangedBy(currentAuth));
DeletedDetailsType dd = new DeletedDetailsType();
dd.setDeletedComponent(getType(ev));
dd.setDeletedSummary(ev.getSummary());
if (ev.isRecurringEntity()) {
// TODO: Set these correctly.
// dd.setDeletedNextInstance(val);
// dd.setDeletedNextInstanceTzid(val);
// dd.setDeletedHadMoreInstances(val);
}
if (ev.getDtstart() != null) {
ChangedPropertyType start = new ChangedPropertyType();
start.setName(PropertyInfoIndex.DTSTART.name());
start.setDataFrom(String.valueOf(ev.getDtstart()));
dd.getDeletedProps().add(start);
}
if (ev.getDtend() != null) {
ChangedPropertyType end = new ChangedPropertyType();
end.setName(PropertyInfoIndex.DTEND.name());
end.setDataFrom(String.valueOf(ev.getDtend()));
dd.getDeletedProps().add(end);
}
if (ev.getDuration() != null && !ev.getDuration().isEmpty()) {
ChangedPropertyType dur = new ChangedPropertyType();
dur.setName(PropertyInfoIndex.DURATION.name());
dur.setDataFrom(ev.getDuration());
dd.getDeletedProps().add(dur);
}
if (ev.getLocation() != null) {
ChangedPropertyType loc = new ChangedPropertyType();
loc.setName(PropertyInfoIndex.LOCATION.name());
loc.setDataFrom(ev.getLocation().getAddress().getValue());
dd.getDeletedProps().add(loc);
}
if (ev.getDescription() != null) {
ChangedPropertyType desc = new ChangedPropertyType();
desc.setName(PropertyInfoIndex.DESCRIPTION.name());
desc.setDataFrom(ev.getDescription());
dd.getDeletedProps().add(desc);
}
del.setDeletedDetails(dd);
rc.setDeleted(del);
return rc;
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
use of org.bedework.caldav.util.notifications.ChangedPropertyType in project bw-calendar-engine by Bedework.
the class NotificationsInfo method instanceChanges.
private static CalendarChangesType instanceChanges(final String currentAuth, final BwEvent ev) throws Throwable {
CalendarChangesType cc = new CalendarChangesType();
RecurrenceType r = new RecurrenceType();
r.setRecurrenceid(ev.getRecurrenceId());
ChangesType c = new ChangesType();
for (ChangeTableEntry cte : ev.getChangeset(currentAuth).getEntries()) {
if (!cte.getChanged()) {
continue;
}
if (cte.getIndex() == PropertyInfoIndex.XPROP) {
/* Reflected a a set of removes and adds. */
if (!Util.isEmpty(cte.getRemovedValues())) {
for (BwXproperty xp : ((Collection<BwXproperty>) cte.getRemovedValues())) {
ChangedPropertyType cp = new ChangedPropertyType();
cp.setName(xp.getName());
cp.setDataFrom(String.valueOf(xp));
c.getChangedProperty().add(cp);
}
}
if (!Util.isEmpty(cte.getAddedValues())) {
for (BwXproperty xp : ((Collection<BwXproperty>) cte.getAddedValues())) {
ChangedPropertyType cp = new ChangedPropertyType();
cp.setName(xp.getName());
cp.setDataTo(String.valueOf(xp));
c.getChangedProperty().add(cp);
}
}
} else {
ChangedPropertyType cp = new ChangedPropertyType();
cp.setName(cte.getIndex().name());
cp.setDataFrom(getDataFrom(cte));
cp.setDataTo(getDataTo(cte));
c.getChangedProperty().add(cp);
}
}
r.getChanges().add(c);
cc.getRecurrence().add(r);
return cc;
}
Aggregations