Search in sources :

Example 1 with DeletedDetailsType

use of org.bedework.caldav.util.notifications.DeletedDetailsType 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)

Aggregations

ChangedPropertyType (org.bedework.caldav.util.notifications.ChangedPropertyType)1 DeletedDetailsType (org.bedework.caldav.util.notifications.DeletedDetailsType)1 DeletedType (org.bedework.caldav.util.notifications.DeletedType)1 ResourceChangeType (org.bedework.caldav.util.notifications.ResourceChangeType)1 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1