use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.
the class SimpleFilterParser method viewFilter.
private FilterBase viewFilter(final String val) throws ParseFailed {
final BwView view = callGetView(val);
if (view == null) {
throw parseResult.fail("Unknown view: " + val + " source: " + source);
}
FilterBase filter = view.getFilter();
if (filter != null) {
return filter;
}
for (final String vpath : view.getCollectionPaths()) {
final FilterBase vpf = resolveVpath(vpath);
filter = or(filter, vpf);
}
final BwViewFilter vf = new BwViewFilter(null);
vf.setEntity(view);
vf.setFilter(filter);
view.setFilter(filter);
return vf;
}
use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.
the class Users method remove.
@Override
public void remove(final BwPrincipal pr) throws CalFacadeException {
final String userRoot = getSvc().getPrincipalInfo().getCalendarHomePath(pr);
/* views */
final Collection<BwView> views = getSvc().getViewsHandler().getAll(pr);
for (final BwView view : views) {
getSvc().getViewsHandler().remove(view);
}
/* Set default calendar to null so we don't get blocked. */
final BwPreferences prefs = getSvc().getPrefsHandler().get(pr);
if (prefs != null) {
prefs.setDefaultCalendarPath(null);
getSvc().getPrefsHandler().update(prefs);
}
/* collections and user home */
final BwCalendar home = getSvc().getCalendarsHandler().get(userRoot);
if (home != null) {
((Calendars) getCols()).delete(home, true, true, false, true);
}
/* Remove preferences */
getSvc().getPrefsHandler().delete(prefs);
getCal().delete(pr);
}
use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.
the class Views method remove.
/* (non-Javadoc)
* @see org.bedework.calsvci.ViewsI#remove(org.bedework.calfacade.svc.BwView)
*/
@Override
public boolean remove(final BwView val) throws CalFacadeException {
if (val == null) {
return false;
}
BwPreferences prefs = getSvc().getPrefsHandler().get();
checkOwnerOrSuper(prefs);
// setupOwnedEntity(val, getUser());
Collection<BwView> views = prefs.getViews();
if ((views == null) || (!views.contains(val))) {
return false;
}
String name = val.getName();
views.remove(val);
if (name.equals(prefs.getPreferredView())) {
prefs.setPreferredView(null);
}
getSvc().getPrefsHandler().update(prefs);
return true;
}
use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.
the class Views method addCollection.
/* (non-Javadoc)
* @see org.bedework.calsvci.ViewsI#addCollection(java.lang.String, java.lang.String)
*/
@Override
public boolean addCollection(final String name, final String path) throws CalFacadeException {
BwPreferences prefs = getSvc().getPrefsHandler().get();
checkOwnerOrSuper(prefs);
BwView view = find(name);
if (view == null) {
return false;
}
view.addCollectionPath(path);
getSvc().getPrefsHandler().update(prefs);
return true;
}
use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.
the class Views method find.
@Override
public BwView find(String val) throws CalFacadeException {
if (val == null) {
BwPreferences prefs = getSvc().getPrefsHandler().get();
val = prefs.getPreferredView();
if (val == null) {
return null;
}
}
/* val may be a name in which case it's for the current user or it
* may be a fully qualified path referencing another users views.
*/
if (!val.startsWith("/")) {
// This user
Collection<BwView> views = getAll();
for (BwView view : views) {
if (view.getName().equals(val)) {
return view;
}
}
return null;
}
/* Other user - we expect a path of th eform
* /user/<id>/<bedework-resource-name>/views/<view-name>
*/
String[] pathEls = val.split("/");
BasicSystemProperties bsp = getBasicSyspars();
if ((pathEls.length != 5) || !bsp.getBedeworkResourceDirectory().equals(pathEls[2]) || !"views".equals(pathEls[3])) {
return null;
}
StringBuilder sb = new StringBuilder();
if (bsp.getUserCalendarRoot().equals(pathEls[0])) {
sb.append(BwPrincipal.userPrincipalRoot);
} else {
return null;
}
// user id
sb.append(pathEls[1]);
BwPrincipal pr = getPrincipal(sb.toString());
if (pr == null) {
return null;
}
Collection<BwView> views = getAll(pr);
String viewName = pathEls[4];
for (BwView view : views) {
if (view.getName().equals(viewName)) {
return view;
}
}
return null;
}
Aggregations