public void service(SourceBean serviceRequest, SourceBean serviceResponse)
throws Exception {
logger.debug("IN");
RequestContainer reqCont = RequestContainer.getRequestContainer();
SessionContainer sessCont = reqCont.getSessionContainer();
SessionContainer permSess = sessCont.getPermanentContainer();
Locale locale = MessageBuilder.getBrowserLocaleFromSpago();
String language=(String)serviceRequest.getAttribute("language_id");
String country=(String)serviceRequest.getAttribute("country_id");
logger.debug("language selected: "+language);
IEngUserProfile profile = (IEngUserProfile)permSess.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
userProfile=null;
String lang="";
if (profile instanceof UserProfile) {
userProfile = (UserProfile) profile;
}
List<Locale> languages=GeneralUtilities.getSupportedLocales();
if(language==null){
logger.error("language not specified");
}
else{
Iterator<Locale> iter = languages.iterator();
boolean found=false;
while (iter.hasNext() && found==false) {
Locale localeTmp = iter.next();
String lang_supported = localeTmp.getLanguage();
String country_supported= localeTmp.getCountry();
if(language.equalsIgnoreCase(lang_supported) && (country==null || country.equalsIgnoreCase(country_supported))){
locale=new Locale(language,country,"");
permSess.setAttribute("AF_LANGUAGE", locale.getLanguage());
permSess.setAttribute("AF_COUNTRY", locale.getCountry());
if(userProfile!=null){
userProfile.setAttributeValue(SpagoBIConstants.LANGUAGE, language);
userProfile.setAttributeValue(SpagoBIConstants.COUNTRY, country);
logger.debug("modified profile attribute to "+ lang);