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;
}
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());
}
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);
}
}
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;
}
Aggregations