use of org.bedework.calsvci.ResourcesI in project bw-calendar-engine by Bedework.
the class Calendars method delete.
boolean delete(final BwCalendar val, final boolean emptyIt, final boolean reallyDelete, final boolean sendSchedulingMessage, final boolean unsubscribe) throws CalFacadeException {
if (!emptyIt) {
/* Only allow delete if not in use
*/
if (!getCal().isEmpty(val)) {
throw new CalFacadeException(CalFacadeException.collectionNotEmpty);
}
}
final BwPreferences prefs = getSvc().getPrefsHandler().get(getSvc().getUsersHandler().getPrincipal(val.getOwnerHref()));
if (val.getPath().equals(prefs.getDefaultCalendarPath())) {
throw new CalFacadeException(CalFacadeException.cannotDeleteDefaultCalendar);
}
/* Remove any sharing */
if (val.getCanAlias()) {
getSvc().getSharingHandler().delete(val);
}
if (unsubscribe) {
getSvc().getSharingHandler().unsubscribe(val);
}
getSvc().getSynch().unsubscribe(val, true);
/* Remove from preferences */
((Preferences) getSvc().getPrefsHandler()).updateAdminPrefs(true, val, null, null, null);
/* If it' an alias we just delete it - otherwise we might need to empty it.
*/
if (!val.getInternalAlias() && emptyIt) {
if (val.getCalendarCollection()) {
final Events events = ((Events) getSvc().getEventsHandler());
for (final EventInfo ei : events.getSynchEvents(val.getPath(), null)) {
events.delete(ei, false, sendSchedulingMessage, true);
}
}
/* Remove resources */
final ResourcesI resI = getSvc().getResourcesHandler();
final Collection<BwResource> rs = resI.getAll(val.getPath());
if (!Util.isEmpty(rs)) {
for (final BwResource r : rs) {
resI.delete(Util.buildPath(false, r.getColPath(), "/", r.getName()));
}
}
for (final BwCalendar cal : getChildren(val)) {
if (!delete(cal, true, true, sendSchedulingMessage, true)) {
// Somebody else at it
getSvc().rollbackTransaction();
throw new CalFacadeException(CalFacadeException.collectionNotFound, cal.getPath());
}
}
}
val.getProperties().clear();
/* Attempt to tombstone it
*/
return getSvc().getCal().deleteCalendar(val, reallyDelete);
}
use of org.bedework.calsvci.ResourcesI in project bw-calendar-engine by Bedework.
the class Notifications method removeAll.
@Override
public void removeAll(final String principalHref) throws CalFacadeException {
if (principalHref == null) {
return;
}
final BwCalendar ncol = getCols().getSpecial(principalHref, BwCalendar.calTypeNotifications, true);
if (ncol == null) {
return;
}
/* Remove resources */
final ResourcesI resI = getSvc().getResourcesHandler();
final Collection<BwResource> rs = resI.getAll(ncol.getPath());
if (!Util.isEmpty(rs)) {
for (final BwResource r : rs) {
resI.delete(Util.buildPath(false, r.getColPath(), "/", r.getName()));
}
}
}
Aggregations