final Set<String> activeLanguages = site.getActiveLanguages();
if (languageSettings != null && languageSettings.size() > 0) {
final TreeSet<String> orderedLangs = new TreeSet<String>();
orderedLangs.addAll(languageSettings);
for (String langCode : orderedLangs) {
GWTJahiaLanguage item = new GWTJahiaLanguage();
item.setLanguage(langCode);
item.setDisplayName(getDisplayName(langCode));
item.setImage(getLangIcon(Jahia.getContextPath(), langCode));
item.setCurrent(langCode.equalsIgnoreCase(currentLocale.toString()));
item.setActive(activeLanguages.contains(langCode));
item.setMandatory(mandatoryLanguages.contains(langCode));
items.add(item);
}
}
} else {
JCRSiteNode siteByKey = (JCRSiteNode) ServicesRegistry.getInstance().getJahiaSitesService().getSiteByKey(
JahiaSitesBaseService.SYSTEM_SITE_KEY).getNode();
final Set<String>languages = siteByKey.getLanguages();
final Set<String> activeLanguages = siteByKey.getActiveLanguages();
final Set<String> mandatoryLanguages = site.getMandatoryLanguages();
final TreeSet<String> orderedLangs = new TreeSet<String>();
orderedLangs.addAll(languages);
for (String langCode : orderedLangs) {
GWTJahiaLanguage item = new GWTJahiaLanguage();
item.setLanguage(langCode);
item.setDisplayName(getDisplayName(langCode));
item.setImage(getLangIcon(Jahia.getContextPath(), langCode));
item.setCurrent(langCode.equalsIgnoreCase(currentLocale.toString()));
item.setActive(activeLanguages.contains(langCode));
item.setMandatory(mandatoryLanguages.contains(langCode));
items.add(item);
}
}
} catch (Exception e) {
logger.error("Error while creating change site link", e);