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);
}
Aggregations