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