Package org.exoplatform.services.resources

Examples of org.exoplatform.services.resources.LocaleContextInfo


        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'");
        } catch (Exception ignored) {
            if (log.isDebugEnabled())
                log.debug("IGNORED: Failed to load UserPortalConfig: ", ignored);
        }

        String portalLocaleName = "en";
        if (pConfig != null)
            portalLocaleName = pConfig.getLocale();

        Locale portalLocale = LocaleContextInfo.getLocale(portalLocaleName);
        localeCtx.setPortalLocale(portalLocale);

        localeCtx.setRequestLocale(reqCtx.getRequestLocale());

        Locale locale = localePolicy.determineLocale(localeCtx);
        boolean supported = supportedLocales.contains(locale);

        if (!supported && !"".equals(locale.getCountry())) {
View Full Code Here


            LocaleConfigService localeConfigService = (LocaleConfigService) container
                    .getComponentInstanceOfType(LocaleConfigService.class);
            LocalePolicy localePolicy = (LocalePolicy) container.getComponentInstanceOfType(LocalePolicy.class);

            LocaleContextInfo localeCtx = new LocaleContextInfo();

            Set<Locale> supportedLocales = new HashSet();
            for (LocaleConfig lc : localeConfigService.getLocalConfigs()) {
                supportedLocales.add(lc.getLocale());
            }
            localeCtx.setSupportedLocales(supportedLocales);

            localeCtx.setBrowserLocales(Collections.list(request.getLocales()));
            localeCtx.setCookieLocales(LocalizationLifecycle.getCookieLocales(req));
            localeCtx.setSessionLocale(LocalizationLifecycle.getSessionLocale(req));
            localeCtx.setUserProfileLocale(getUserProfileLocale(container, req.getRemoteUser()));
            localeCtx.setRemoteUser(req.getRemoteUser());

            localeCtx.setPortalLocale(checkPortalLocaleSupported(portalLocale, supportedLocales));
            Locale locale = localePolicy.determineLocale(localeCtx);
            boolean supported = supportedLocales.contains(locale);

            if (!supported && !"".equals(locale.getCountry())) {
                locale = new Locale(locale.getLanguage());
View Full Code Here

            LocaleConfigService localeConfigService = (LocaleConfigService) container
                    .getComponentInstanceOfType(LocaleConfigService.class);
            LocalePolicy localePolicy = (LocalePolicy) container.getComponentInstanceOfType(LocalePolicy.class);

            LocaleContextInfo localeCtx = new LocaleContextInfo();

            Set<Locale> supportedLocales = new HashSet();
            for (LocaleConfig lc : localeConfigService.getLocalConfigs()) {
                supportedLocales.add(lc.getLocale());
            }
            localeCtx.setSupportedLocales(supportedLocales);

            localeCtx.setBrowserLocales(Collections.list(request.getLocales()));
            localeCtx.setCookieLocales(LocalizationLifecycle.getCookieLocales(req));
            localeCtx.setSessionLocale(LocalizationLifecycle.getSessionLocale(req));
            localeCtx.setUserProfileLocale(getUserProfileLocale(container, req.getRemoteUser()));
            localeCtx.setRemoteUser(req.getRemoteUser());

            localeCtx.setPortalLocale(checkPortalLocaleSupported(portalLocale, supportedLocales));
            Locale locale = localePolicy.determineLocale(localeCtx);
            boolean supported = supportedLocales.contains(locale);

            if (!supported && !"".equals(locale.getCountry())) {
                locale = new Locale(locale.getLanguage());
View Full Code Here

        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'");
        } catch (Exception ignored) {
            if (log.isDebugEnabled())
                log.debug("IGNORED: Failed to load UserPortalConfig: ", ignored);
        }

        String portalLocaleName = "en";
        if (pConfig != null)
            portalLocaleName = pConfig.getLocale();

        Locale portalLocale = LocaleContextInfo.getLocale(portalLocaleName);
        localeCtx.setPortalLocale(portalLocale);

        localeCtx.setRequestLocale(reqCtx.getRequestLocale());

        Locale locale = localePolicy.determineLocale(localeCtx);
        boolean supported = supportedLocales.contains(locale);

        if (!supported && !"".equals(locale.getCountry())) {
View Full Code Here

TOP

Related Classes of org.exoplatform.services.resources.LocaleContextInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.