Support i18n in directory
[lgpl/argeo-commons.git] / org.argeo.util / src / org / argeo / util / directory / ldap / AbstractLdapDirectory.java
index 54d9776b5fd15106bf6de8b560ef81f863f1d470..28d8d081ccdcfb875e5ce8941086f01cc3be3c00 100644 (file)
@@ -10,6 +10,7 @@ import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Locale;
 import java.util.Optional;
 import java.util.StringJoiner;
 
@@ -255,10 +256,6 @@ public abstract class AbstractLdapDirectory implements Directory, XAResourceProv
                                        } else {
                                                // user doesn't have the right to retrieve role, but we know it exists
                                                // otherwise memberOf would not work
-//                                             Attributes a = new BasicAttributes();
-//                                             a.put(LdapNameUtils.getLastRdn(groupDn).getType(),
-//                                                             LdapNameUtils.getLastRdn(groupDn).getValue());
-//                                             a.put(LdapAttrs.objectClass.name(), LdapObjs.groupOfNames.name());
                                                group = newGroup(groupDn);
                                                allRoles.add(group);
                                        }
@@ -300,6 +297,16 @@ public abstract class AbstractLdapDirectory implements Directory, XAResourceProv
                return getName();
        }
 
+       @Override
+       public String getHierarchyUnitLabel(Locale locale) {
+               String key = LdapNameUtils.getLastRdn(getBaseDn()).getType();
+               Object value = LdapEntry.getLocalized(asLdapEntry().getProperties(), key, locale);
+               if (value == null)
+                       value = getHierarchyUnitName();
+               assert value != null;
+               return value.toString();
+       }
+
        @Override
        public HierarchyUnit getParent() {
                return null;