Search in sources :

Example 1 with ChangedPropertyType

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);
    }
}
Also used : ResourceChangeType(org.bedework.caldav.util.notifications.ResourceChangeType) ChangedPropertyType(org.bedework.caldav.util.notifications.ChangedPropertyType) DeletedType(org.bedework.caldav.util.notifications.DeletedType) DeletedDetailsType(org.bedework.caldav.util.notifications.DeletedDetailsType) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 2 with ChangedPropertyType

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;
}
Also used : ChangedPropertyType(org.bedework.caldav.util.notifications.ChangedPropertyType) BwXproperty(org.bedework.calfacade.BwXproperty) RecurrenceType(org.bedework.caldav.util.notifications.RecurrenceType) CalendarChangesType(org.bedework.caldav.util.notifications.CalendarChangesType) ChangesType(org.bedework.caldav.util.notifications.ChangesType) CalendarChangesType(org.bedework.caldav.util.notifications.CalendarChangesType)

Aggregations

ChangedPropertyType (org.bedework.caldav.util.notifications.ChangedPropertyType)2 CalendarChangesType (org.bedework.caldav.util.notifications.CalendarChangesType)1 ChangesType (org.bedework.caldav.util.notifications.ChangesType)1 DeletedDetailsType (org.bedework.caldav.util.notifications.DeletedDetailsType)1 DeletedType (org.bedework.caldav.util.notifications.DeletedType)1 RecurrenceType (org.bedework.caldav.util.notifications.RecurrenceType)1 ResourceChangeType (org.bedework.caldav.util.notifications.ResourceChangeType)1 BwXproperty (org.bedework.calfacade.BwXproperty)1 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1