Search in sources :

Example 1 with OwnerUidKey

use of org.bedework.dumprestore.restore.OwnerUidKey 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)

Aggregations

BwOrganizer (org.bedework.calfacade.BwOrganizer)1 BwPrincipal (org.bedework.calfacade.BwPrincipal)1 BwOwnedDbentity (org.bedework.calfacade.base.BwOwnedDbentity)1 BwAdminGroup (org.bedework.calfacade.svc.BwAdminGroup)1 BwView (org.bedework.calfacade.svc.BwView)1 EventInfo (org.bedework.calfacade.svc.EventInfo)1 OwnerUidKey (org.bedework.dumprestore.restore.OwnerUidKey)1 SkipThis (org.bedework.icalendar.IcalTranslator.SkipThis)1