Search in sources :

Example 6 with BwView

use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.

the class ProcessCreate method createView.

private boolean createView(final String name) throws Throwable {
    if (debug) {
        debug("About to create view " + name);
    }
    if (name == null) {
        addError("Must supply name");
        return false;
    }
    try {
        open();
        final BwView view = new BwView();
        view.setName(name);
        if (!getSvci().getViewsHandler().add(view, false)) {
            error("view " + name + "already exists.");
        }
        return true;
    } finally {
        close();
    }
}
Also used : BwView(org.bedework.calfacade.svc.BwView)

Example 7 with BwView

use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.

the class ProcessDelete method deleteView.

private boolean deleteView(final String name) throws Throwable {
    if (debug) {
        debug("About to delete view " + name);
    }
    if (name == null) {
        addError("Must supply name");
        return false;
    }
    try {
        open();
        final BwView view = getSvci().getViewsHandler().find(name);
        if (view == null) {
            addError("View " + name + " not found");
            return false;
        }
        return getSvci().getViewsHandler().remove(view);
    } finally {
        close();
    }
}
Also used : BwView(org.bedework.calfacade.svc.BwView)

Example 8 with BwView

use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.

the class ProcessDelete method deleteAll.

private boolean deleteAll(final String type) throws Throwable {
    if (!"views".equals(type)) {
        error("Only allow views for delete all");
        return true;
    }
    try {
        open();
        final Collection<BwView> theViews = getSvci().getViewsHandler().getAll();
        if (Util.isEmpty(theViews)) {
            info("No views for current user");
            return false;
        }
        final List<BwView> views = new ArrayList<>(theViews);
        for (final BwView view : views) {
            if (getSvci().getViewsHandler().remove(view)) {
                info("Removed view " + view.getName());
            } else {
                warn("Unable to remove view " + view.getName());
            }
        }
    } finally {
        close();
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) BwView(org.bedework.calfacade.svc.BwView)

Example 9 with BwView

use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.

the class OwnerRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    error("OwnerRule called");
    BwPrincipal p = doPrincipal();
    if (top() instanceof OwnerUidKey) {
        OwnerUidKey key = (OwnerUidKey) top();
        key.setOwnerHref(p.getPrincipalRef());
        globals.inOwnerKey = false;
        return;
    }
    if (top() instanceof BwAdminGroup) {
        BwAdminGroup ag = (BwAdminGroup) top();
        if (name.equals("owner")) {
            ag.setOwnerHref(p.getPrincipalRef());
        } else if (name.equals("owner-key")) {
            // PRE3.5
            ag.setOwnerHref(p.getPrincipalRef());
        } else {
            ag.setGroupOwnerHref(p.getPrincipalRef());
        }
        globals.inOwnerKey = false;
        return;
    }
    BwOwnedDbentity o = null;
    if (top() == null) {
        error("Null stack top when setting owner.  Match: " + getDigester().getMatch());
        return;
    }
    if (top() instanceof EventInfo) {
        o = ((EventInfo) top()).getEvent();
    } else if (!(top() instanceof BwOwnedDbentity)) {
        if (top() instanceof BwOrganizer) {
        // No owner now
        } else if (top() instanceof BwView) {
        // No owner now
        } else if (top() instanceof SkipThis) {
        } else {
            // We expect organizer in old data
            warn("top() is not BwOwnedDbentity:" + top().getClass().getCanonicalName());
            warn("  match: " + getDigester().getMatch());
        }
        globals.inOwnerKey = false;
        return;
    } else {
        o = (BwOwnedDbentity) top();
    }
    o.setOwnerHref(p.getPrincipalRef());
    globals.inOwnerKey = false;
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) EventInfo(org.bedework.calfacade.svc.EventInfo) BwOwnedDbentity(org.bedework.calfacade.base.BwOwnedDbentity) SkipThis(org.bedework.icalendar.IcalTranslator.SkipThis) BwAdminGroup(org.bedework.calfacade.svc.BwAdminGroup) OwnerUidKey(org.bedework.dumprestore.restore.OwnerUidKey) BwOrganizer(org.bedework.calfacade.BwOrganizer) BwView(org.bedework.calfacade.svc.BwView)

Example 10 with BwView

use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.

the class RestoreImpl method restoreUserPrefs.

@Override
public void restoreUserPrefs(final BwPreferences o) throws Throwable {
    try {
        startTransaction();
        /* If the indexer or some other activity is running this can result in
       * a preferences object being created. See if one exists.
       */
        BwPreferences p = getSvc().getPreferences(o.getOwnerHref());
        if (p != null) {
            warn("Found instance of preferences for " + o.getOwnerHref());
            o.setId(p.getId());
            // noinspection UnusedAssignment
            p = (BwPreferences) getSvc().merge(o);
        } else {
            p = o;
            /* Ensure views are unsaved objects */
            final Collection<BwView> v = p.getViews();
            if (v != null) {
                for (final BwView view : v) {
                    view.markUnsaved();
                }
            }
            p.markUnsaved();
        }
        getCal().saveOrUpdate(o);
    } finally {
        endTransaction();
    }
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) BwView(org.bedework.calfacade.svc.BwView)

Aggregations

BwView (org.bedework.calfacade.svc.BwView)13 BwPreferences (org.bedework.calfacade.svc.BwPreferences)7 BwCalendar (org.bedework.calfacade.BwCalendar)2 BwPrincipal (org.bedework.calfacade.BwPrincipal)2 ArrayList (java.util.ArrayList)1 FilterBase (org.bedework.caldav.util.filter.FilterBase)1 BwOrganizer (org.bedework.calfacade.BwOrganizer)1 BwOwnedDbentity (org.bedework.calfacade.base.BwOwnedDbentity)1 BasicSystemProperties (org.bedework.calfacade.configs.BasicSystemProperties)1 BwAdminGroup (org.bedework.calfacade.svc.BwAdminGroup)1 EventInfo (org.bedework.calfacade.svc.EventInfo)1 OwnerUidKey (org.bedework.dumprestore.restore.OwnerUidKey)1 SkipThis (org.bedework.icalendar.IcalTranslator.SkipThis)1 ToString (org.bedework.util.misc.ToString)1