Search in sources :

Example 16 with BwResource

use of org.bedework.calfacade.BwResource in project bw-calendar-engine by Bedework.

the class ResourcesImpl method delete.

@Override
public void delete(final String path) throws CalFacadeException {
    final CollectionAndName cn = getCollectionAndName(path);
    final BwResource r = getCal().getResource(cn.name, cn.coll, PrivilegeDefs.privUnbind);
    if (r == null) {
        throw new CalFacadeException(CalFacadeException.unknownResource, path);
    }
    try {
        getContent(r);
    } catch (final CalFacadeException cfe) {
        if (!cfe.getMessage().equals(CalFacadeException.missingResourceContent)) {
            getSvc().rollbackTransaction();
            throw cfe;
        }
    // Otherwise we just swallow it
    }
    /* Remove any previous tombstoned version */
    final BwResource tr = getCal().getResource(cn.name + BwResource.tombstonedSuffix, cn.coll, PrivilegeDefs.privUnbind);
    if (tr != null) {
        getCal().delete(tr);
    }
    final BwResourceContent rc = r.getContent();
    r.setContent(null);
    r.tombstone();
    r.updateLastmod(getCurrentTimestamp());
    getCal().saveOrUpdate(r);
    if (rc != null) {
        getCal().delete(rc);
    }
    touchCalendar(cn.coll);
}
Also used : BwResource(org.bedework.calfacade.BwResource) BwResourceContent(org.bedework.calfacade.BwResourceContent) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

BwResource (org.bedework.calfacade.BwResource)16 BwCalendar (org.bedework.calfacade.BwCalendar)10 BwResourceContent (org.bedework.calfacade.BwResourceContent)7 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)7 ArrayList (java.util.ArrayList)3 NotificationType (org.bedework.caldav.util.notifications.NotificationType)2 EventInfo (org.bedework.calfacade.svc.EventInfo)2 ResourcesI (org.bedework.calsvci.ResourcesI)2 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)2 WebdavForbidden (org.bedework.webdav.servlet.shared.WebdavForbidden)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 TreeSet (java.util.TreeSet)1 CurrentAccess (org.bedework.access.Acl.CurrentAccess)1 HibSession (org.bedework.calcorei.HibSession)1 CalDAVResource (org.bedework.caldav.server.CalDAVResource)1 NotificationInfo (org.bedework.caldav.util.notifications.NotificationType.NotificationInfo)1 BwEvent (org.bedework.calfacade.BwEvent)1 BwString (org.bedework.calfacade.BwString)1