// INSPIRE: Use language parameter if available, otherwise use default (using context.getLanguage())
if (inspireEnabled) {
String isoLangParamValue = request.getAttributeValue("language");
final LanguageRepository languageRepository = context.getBean(LanguageRepository.class);
List<Language> languageList = languageRepository.findAllByInspireFlag(true);
List<String> langCodes = Lists.transform(languageList, new Function<Language, String>() {
@Nullable
@Override
public String apply(@Nonnull Language input) {
return input.getId();
}
});
if (isoLangParamValue != null) {
// Retrieve GN language id from Iso language id
if (langCodes.contains(isoLangParamValue)) {
currentLanguage = isoLangParamValue;
}
}
Language defaultLanguage = languageRepository.findOneByDefaultLanguage();
if (StringUtils.isEmpty(currentLanguage)) {
currentLanguage = defaultLanguage.getId();
}