X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.util%2Fsrc%2Forg%2Fargeo%2Fosgi%2Fuseradmin%2FLdifHierarchyUnit.java;h=a847e49ae7f3d66afd13644889dc859961abc248;hb=4672ec9d1071dffc7c591f623898d32a31637d04;hp=271f236115d330911e34974252e6ebbd9dc2028e;hpb=99bca5f6b71c24837c23cf2a9bb944e09dca3dea;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.util/src/org/argeo/osgi/useradmin/LdifHierarchyUnit.java b/org.argeo.util/src/org/argeo/osgi/useradmin/LdifHierarchyUnit.java index 271f23611..a847e49ae 100644 --- a/org.argeo.util/src/org/argeo/osgi/useradmin/LdifHierarchyUnit.java +++ b/org.argeo.util/src/org/argeo/osgi/useradmin/LdifHierarchyUnit.java @@ -1,12 +1,11 @@ package org.argeo.osgi.useradmin; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Objects; import javax.naming.directory.Attributes; import javax.naming.ldap.LdapName; +import javax.naming.ldap.Rdn; import org.osgi.framework.InvalidSyntaxException; import org.osgi.service.useradmin.Role; @@ -16,35 +15,47 @@ class LdifHierarchyUnit implements HierarchyUnit { private final AbstractUserDirectory directory; private final LdapName dn; - private final int type; + private final boolean functional; private final Attributes attributes; - HierarchyUnit parent; - List children = new ArrayList<>(); +// HierarchyUnit parent; +// List children = new ArrayList<>(); - LdifHierarchyUnit(AbstractUserDirectory directory, LdapName dn, int type, Attributes attributes) { + LdifHierarchyUnit(AbstractUserDirectory directory, LdapName dn, Attributes attributes) { Objects.requireNonNull(directory); Objects.requireNonNull(dn); this.directory = directory; this.dn = dn; - this.type = type; this.attributes = attributes; + + Rdn rdn = LdapNameUtils.getLastRdn(dn); + functional = !(directory.getUserBaseRdn().equals(rdn) || directory.getGroupBaseRdn().equals(rdn) + || directory.getSystemRoleBaseRdn().equals(rdn)); } @Override public HierarchyUnit getParent() { - return parent; + return directory.doGetHierarchyUnit(LdapNameUtils.getParent(dn)); } @Override - public Iterable getDirectHierachyUnits() { - return children; + public Iterable getDirectHierachyUnits(boolean functionalOnly) { +// List res = new ArrayList<>(); +// if (functionalOnly) +// for (HierarchyUnit hu : children) { +// if (hu.isFunctional()) +// res.add(hu); +// } +// else +// res.addAll(children); +// return Collections.unmodifiableList(res); + return directory.doGetDirectHierarchyUnits(dn, functionalOnly); } @Override - public int getHierarchyUnitType() { - return type; + public boolean isFunctional() { + return functional; } @Override @@ -59,7 +70,7 @@ class LdifHierarchyUnit implements HierarchyUnit { } @Override - public String getBasePath() { + public String getContext() { return dn.toString(); }