use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.
the class CalintfImpl method deleteFilterDef.
@Override
public void deleteFilterDef(final String name, final BwPrincipal owner) throws CalFacadeException {
final BwFilterDef fd = filterDefs.fetch(name, owner);
if (fd == null) {
throw new CalFacadeException(CalFacadeException.unknownFilter, name);
}
entityDao.delete(fd);
}
use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.
the class CoreCalendars method checkNewCalendarName.
private void checkNewCalendarName(final String name, final boolean special, final BwCalendar parent) throws CalFacadeException {
// XXX This should be accessible to all implementations.
if (!special) {
final BasicSystemProperties sys = getSyspars();
if (name.equals(sys.getUserInbox())) {
throw new CalFacadeException(CalFacadeException.illegalCalendarCreation);
}
if (name.equals(sys.getUserOutbox())) {
throw new CalFacadeException(CalFacadeException.illegalCalendarCreation);
}
if (name.equals(sys.getDefaultNotificationsName())) {
throw new CalFacadeException(CalFacadeException.illegalCalendarCreation);
}
}
/* Ensure the name is not-null and contains no invalid characters
*/
if ((name == null) || name.contains("/")) {
throw new CalFacadeException(CalFacadeException.illegalCalendarCreation);
}
/* Ensure the new path is unique */
String path;
if (parent == null) {
path = "";
} else {
path = parent.getPath();
}
path = Util.buildPath(colPathEndsWithSlash, path, "/", name);
final BwCalendar col = dao.getCollection(path);
if (col != null) {
if (!col.getTombstoned()) {
throw new CalFacadeException(CalFacadeException.duplicateCalendar);
}
dao.deleteCalendar(unwrap(col));
}
}
use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.
the class CoreCalendars method deleteCalendar.
@Override
public boolean deleteCalendar(BwCalendar val, final boolean reallyDelete) throws CalFacadeException {
colCache.flush();
ac.checkAccess(val, privUnbind, false);
final String parentPath = val.getColPath();
if (parentPath == null) {
throw new CalFacadeException(CalFacadeException.cannotDeleteCalendarRoot);
}
/* Ensure the parent exists and we have writeContent on the parent.
*/
final BwCalendar parent = getCalendar(parentPath, privWriteContent, false);
if (parent == null) {
throw new CalFacadeException(CalFacadeException.collectionNotFound);
}
val = getCalendar(val.getPath(), privUnbind, false);
if (val == null) {
throw new CalFacadeException(CalFacadeException.collectionNotFound);
}
if (!isEmpty(val)) {
throw new CalFacadeException(CalFacadeException.collectionNotEmpty);
}
/* See if this is a no-op after all. We do this now to ensure the caller
* really does have access
*/
if (!reallyDelete && val.getTombstoned()) {
// Nothing to do
return true;
}
final BwCalendar unwrapped = unwrap(val);
final String path = val.getPath();
/* Ensure it's not in any (auth)user preferences */
dao.removeCalendarFromAuthPrefs(unwrapped);
/* Ensure no tombstoned events or childen */
dao.removeTombstoned(fixPath(path));
if (reallyDelete) {
dao.deleteCalendar(unwrapped);
} else {
tombstoneEntity(unwrapped);
unwrapped.tombstone();
dao.updateCollection(unwrapped);
touchCalendar(unwrapped);
}
colCache.remove(path);
touchCalendar(parent);
notify(SysEvent.SysCode.COLLECTION_DELETED, val);
getIndexer(val).unindexEntity(path);
return true;
}
use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.
the class DtStartPropUpdater method applyUpdate.
@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
try {
BwEvent ev = ui.getEvent();
boolean scheduleReply = ev.getScheduleMethod() == ScheduleMethods.methodTypeReply;
// No dates valid for reply
DtstartPropType dt = (DtstartPropType) ui.getProp();
DatesState ds = (DatesState) ui.getState(DatesState.stateName);
if (ds == null) {
ds = new DatesState(ev);
ui.saveState(DatesState.stateName, ds);
}
ChangeTableEntry cte = ui.getCte();
if (ui.isRemove()) {
if (!scheduleReply && (ev.getEntityType() != IcalDefs.entityTypeTodo)) {
return new UpdateResult("Entity requires start date");
}
cte.setDeleted(ev.getDtstart());
ds.start = null;
return UpdateResult.getOkResult();
}
if (ui.isAdd()) {
if (!ev.getNoStart()) {
return new UpdateResult("Entity already has start date - cannot add");
}
ds.start = BwDateTime.makeBwDateTime(dt);
cte.setAdded(ds.start);
return UpdateResult.getOkResult();
}
/* Changing dtstart - either value or parameters */
if (ev.getNoStart()) {
return new UpdateResult("Entity has no start date - cannot change");
}
Holder<BwDateTime> resdt = new Holder<BwDateTime>();
UpdateResult ur = makeDt(ev.getDtstart(), resdt, ui);
if (!ur.getOk()) {
return ur;
}
if (resdt.value != null) {
cte.setChanged(ev.getDtstart(), resdt.value);
ds.start = resdt.value;
}
return UpdateResult.getOkResult();
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
}
}
use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.
the class LocationPropUpdater method applyUpdate.
@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
try {
final BwEvent ev = ui.getEvent();
final ChangeTableEntry cte = ui.getCte();
BwString val = new BwString(UpdaterUtil.getLang(ui.getProp()), ((TextPropertyType) ui.getProp()).getText());
final BwLocation evLoc = ev.getLocation();
BwString evVal = null;
if (evLoc != null) {
evVal = evLoc.getAddress();
}
if (ui.isRemove()) {
if (evVal == null) {
return new UpdateResult("Entity has no " + ui.getPropName() + " property - cannot remove");
}
val = null;
} else if (ui.isAdd()) {
if (evVal != null) {
return new UpdateResult("Entity already has " + ui.getPropName() + " property - cannot add");
}
} else if (!ui.isChange()) {
final ParameterUpdater.UpdateInfo langUpd = UpdaterUtil.findLangUpdate(ui.getParamUpdates());
if (langUpd == null) {
return new UpdateResult("No update specified for " + ui.getPropName());
}
String lang = val.getLang();
if (langUpd.isRemove()) {
lang = null;
} else if (langUpd.isAdd()) {
lang = ((TextParameterType) langUpd.getParam()).getText();
} else if (langUpd.getUpdparam() != null) {
lang = ((TextParameterType) langUpd.getUpdparam()).getText();
}
if (!Util.equalsString(lang, val.getLang())) {
val = new BwString(lang, val.getValue());
}
} else {
if (!val.equals(evVal)) {
return new UpdateResult("Values don't match for update to " + ui.getPropName());
}
val = new BwString(UpdaterUtil.getLang(ui.getUpdprop()), ((TextPropertyType) ui.getUpdprop()).getText());
}
if (val == null) {
cte.setDeleted(ev.getLocation());
ev.setLocation(null);
} else if (Util.cmpObjval(val, evVal) != 0) {
BwLocation loc = ui.getIcalCallback().findLocation(val);
if (loc == null) {
loc = BwLocation.makeLocation();
loc.setAddress(val);
ui.getIcalCallback().addLocation(loc);
}
if (cte.setChanged(evLoc, loc)) {
ev.setLocation(loc);
}
}
return UpdateResult.getOkResult();
} catch (final CalFacadeException cfe) {
throw new WebdavException(cfe);
}
}
Aggregations