Search in sources :

Example 1 with PrincipalHref

use of org.bedework.dumprestore.restore.PrincipalHref in project bw-calendar-engine by Bedework.

the class CreatorRule method begin.

@Override
public void begin(final String ns, final String name, final Attributes att) {
    push(new PrincipalHref());
    globals.inOwnerKey = true;
}
Also used : PrincipalHref(org.bedework.dumprestore.restore.PrincipalHref)

Example 2 with PrincipalHref

use of org.bedework.dumprestore.restore.PrincipalHref in project bw-calendar-engine by Bedework.

the class MemberRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    /* Top should be the principal info, underneath is the actual entity -
     */
    PrincipalHref oi = (PrincipalHref) pop();
    try {
        if (oi.prefix == null) {
            error("Unable to handle principal type " + oi.getKind());
        }
        oi.href = Util.buildPath(false, oi.prefix, "/", oi.account);
    } catch (Throwable t) {
        error("Unable to get user principal root", t);
        return;
    }
    BwPrincipal pr = globals.principalsTbl.get(oi);
    if (top() instanceof BwGroup) {
        BwGroup gr = (BwGroup) top();
        if (pr == null) {
            if (gr instanceof BwAdminGroup) {
                ArrayList<PrincipalHref> m = globals.adminGroupMembers.get(gr.getAccount());
                if (m == null) {
                    m = new ArrayList<PrincipalHref>();
                    globals.adminGroupMembers.put(gr.getAccount(), m);
                }
                m.add(oi);
            } else {
                error("Cannot handle group " + gr);
            }
            return;
        }
        gr.addGroupMember(pr);
        return;
    }
    error("Unknown class for member " + top());
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) BwGroup(org.bedework.calfacade.BwGroup) PrincipalHref(org.bedework.dumprestore.restore.PrincipalHref) BwAdminGroup(org.bedework.calfacade.svc.BwAdminGroup)

Example 3 with PrincipalHref

use of org.bedework.dumprestore.restore.PrincipalHref in project bw-calendar-engine by Bedework.

the class PrincipalFieldRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    PrincipalHref oi = (PrincipalHref) top();
    try {
        if (name.equals("user")) {
            oi.setKind(WhoDefs.whoTypeUser);
            oi.prefix = RestoreGlobals.getUserPrincipalRoot();
        } else if (name.equals("group")) {
            oi.setKind(WhoDefs.whoTypeGroup);
            oi.prefix = RestoreGlobals.getGroupPrincipalRoot();
        } else if (name.equals("adminGroup")) {
            oi.setKind(WhoDefs.whoTypeGroup);
            oi.prefix = RestoreGlobals.getBwadmingroupPrincipalRoot();
        } else if (name.equals("account")) {
            oi.setAccount(stringFld());
        } else {
            unknownTag(name);
        }
    } catch (Throwable t) {
        throw new Exception(t);
    }
}
Also used : PrincipalHref(org.bedework.dumprestore.restore.PrincipalHref)

Example 4 with PrincipalHref

use of org.bedework.dumprestore.restore.PrincipalHref in project bw-calendar-engine by Bedework.

the class CreatorRule method doPrincipal.

protected BwPrincipal doPrincipal() throws Exception {
    /* Top should be the owner info, underneath is the actual entity -
     * hide the owner under the entity.
     */
    PrincipalHref oi = (PrincipalHref) pop();
    // XXX could be a group?
    if (oi.getKind() == WhoDefs.whoTypeGroup) {
        throw new Exception("Group creator not implemented");
    }
    try {
        oi.setHref(RestoreGlobals.getUserPrincipalRoot() + oi.getAccount());
    } catch (Throwable t) {
        error("Unable to get user principal root", t);
        return null;
    }
    BwPrincipal p = globals.principalsTbl.getUserOwner(oi);
    if (p == null) {
        error("Missing creator " + oi);
        globals.entityError = true;
        p = BwPrincipal.makeUserPrincipal();
    }
    return p;
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) PrincipalHref(org.bedework.dumprestore.restore.PrincipalHref)

Aggregations

PrincipalHref (org.bedework.dumprestore.restore.PrincipalHref)4 BwPrincipal (org.bedework.calfacade.BwPrincipal)2 BwGroup (org.bedework.calfacade.BwGroup)1 BwAdminGroup (org.bedework.calfacade.svc.BwAdminGroup)1