public void onStartRequest(Application app, WebuiRequestContext context) throws Exception {
if (context instanceof PortalRequestContext == false)
throw new IllegalArgumentException("Expected PortalRequestContext, but got: " + context);
PortalRequestContext reqCtx = (PortalRequestContext) context;
ExoContainer container = app.getApplicationServiceContainer();
LocaleConfigService localeConfigService = (LocaleConfigService) container
.getComponentInstanceOfType(LocaleConfigService.class);
LocalePolicy localePolicy = (LocalePolicy) container.getComponentInstanceOfType(LocalePolicy.class);
LocaleContextInfo localeCtx = new LocaleContextInfo();
Set<Locale> supportedLocales = new HashSet<Locale>();
for (LocaleConfig lc : localeConfigService.getLocalConfigs()) {
supportedLocales.add(lc.getLocale());
}
localeCtx.setSupportedLocales(supportedLocales);
HttpServletRequest request = HttpServletRequest.class.cast(context.getRequest());
localeCtx.setBrowserLocales(Collections.list(request.getLocales()));
localeCtx.setCookieLocales(getCookieLocales(request));
localeCtx.setSessionLocale(getSessionLocale(request));
localeCtx.setUserProfileLocale(getUserProfileLocale(reqCtx));
localeCtx.setRemoteUser(reqCtx.getRemoteUser());
DataStorage dataStorage = (DataStorage) container.getComponentInstanceOfType(DataStorage.class);
PortalConfig pConfig = null;
try {
pConfig = dataStorage.getPortalConfig(SiteType.PORTAL.getName(), reqCtx.getPortalOwner());
if (pConfig == null)
log.warn("No UserPortalConfig available! Portal locale set to 'en'");