]> git.argeo.org Git - lgpl/argeo-commons.git/blob - ldap/LdapAcrUtils.java
Prepare next development cycle
[lgpl/argeo-commons.git] / ldap / LdapAcrUtils.java
1 package org.argeo.api.acr.ldap;
2
3 import java.util.Locale;
4
5 import javax.xml.namespace.QName;
6
7 import org.argeo.api.acr.Content;
8 import org.argeo.api.acr.ContentName;
9
10 /** Utilities around ACR and LDAP conventions. */
11 public class LdapAcrUtils {
12
13 /** singleton */
14 private LdapAcrUtils() {
15 }
16
17 public static Object getLocalized(Content content, QName key, Locale locale) {
18 if (locale == null)
19 throw new IllegalArgumentException("A locale must be specified");
20 Object value = null;
21 if (locale.getCountry() != null && !locale.getCountry().equals(""))
22 value = content.get(new ContentName(key.getNamespaceURI(),
23 key.getLocalPart() + ";lang-" + locale.getLanguage() + "-" + locale.getCountry()));
24 if (value == null)
25 value = content
26 .get(new ContentName(key.getNamespaceURI(), key.getLocalPart() + ";lang-" + locale.getLanguage()));
27 if (value == null)
28 value = content.get(key);
29 return value;
30 }
31 }