Search in sources :

Example 11 with BwResourceContent

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

the class ResourcesImpl method update.

@Override
public void update(final BwResource val, final boolean updateContent) throws CalFacadeException {
    checkAccess(val, PrivilegeDefs.privWrite, false);
    try {
        val.updateLastmod(getCurrentTimestamp());
        getCal().saveOrUpdate(val);
        if (updateContent && (val.getContent() != null)) {
            final BwResourceContent rc = val.getContent();
            rc.setColPath(val.getColPath());
            rc.setName(val.getName());
            getCal().saveOrUpdate(rc);
        }
        touchCalendar(getCols().get(val.getColPath()));
    } catch (final CalFacadeException cfe) {
        getSvc().rollbackTransaction();
        throw cfe;
    }
}
Also used : BwResourceContent(org.bedework.calfacade.BwResourceContent) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 12 with BwResourceContent

use of org.bedework.calfacade.BwResourceContent 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

BwResourceContent (org.bedework.calfacade.BwResourceContent)12 BwResource (org.bedework.calfacade.BwResource)7 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)7 BwCalendar (org.bedework.calfacade.BwCalendar)4 InputStream (java.io.InputStream)2 Blob (java.sql.Blob)2 NotificationType (org.bedework.caldav.util.notifications.NotificationType)2 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 HibSession (org.bedework.calcorei.HibSession)1 CalFacadeForbidden (org.bedework.calfacade.exc.CalFacadeForbidden)1 WebdavForbidden (org.bedework.webdav.servlet.shared.WebdavForbidden)1