Fix error message
[lgpl/argeo-commons.git] / org.argeo.util / src / org / argeo / util / directory / ldap / AbstractLdapDirectory.java
index 54d9776b5fd15106bf6de8b560ef81f863f1d470..74dd15edec4c658ca9df5af3a3446e7b0cb1cf4e 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;
@@ -386,7 +393,7 @@ public abstract class AbstractLdapDirectory implements Directory, XAResourceProv
                        }
                        return name;
                } catch (InvalidNameException e) {
-                       throw new IllegalStateException("Cannot get role " + path, e);
+                       throw new IllegalStateException("Cannot convert " + path + " to LDAP name", e);
                }
 
        }