Example usage for org.springframework.web.context.support WebApplicationContextUtils getRequiredWebApplicationContext

List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getRequiredWebApplicationContext

Introduction

In this page you can find the example usage for org.springframework.web.context.support WebApplicationContextUtils getRequiredWebApplicationContext.

Prototype

public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc)
        throws IllegalStateException 

Source Link

Document

Find the root WebApplicationContext for this web app, typically loaded via org.springframework.web.context.ContextLoaderListener .

Usage

From source file:org.alfresco.web.app.Application.java

/**
 * @return Returns the Content templates folder name
 *//*  w ww .  j  a  v  a  2  s  .c om*/
public static String getContentTemplatesFolderName(ServletContext context) {
    return getContentTemplatesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context));
}

From source file:org.alfresco.web.app.Application.java

/**
  * @return Returns the Invite Email Templates folder name
  *//*from   w w w.  j  av a  2  s  .c  o m*/
public static String getInviteEmailTemplatesFolderName(ServletContext context) {
    return getInviteEmailTemplatesFolderName(
            WebApplicationContextUtils.getRequiredWebApplicationContext(context));
}

From source file:org.alfresco.web.app.Application.java

/**
 * @return Returns the Notify Email Templates folder name
 *//*from  w  w  w  .j a  v a  2  s .co  m*/
public static String getNotifyEmailTemplatesFolderName(ServletContext context) {
    return getNotifyEmailTemplatesFolderName(
            WebApplicationContextUtils.getRequiredWebApplicationContext(context));
}

From source file:org.alfresco.web.app.Application.java

/**
* @return Returns the Email templates folder name
*//*from  w w  w .j a v a2s. c  om*/
public static String getEmailTemplatesFolderName(ServletContext context) {
    return getEmailTemplatesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context));
}

From source file:org.alfresco.web.app.Application.java

/**
 * @return Returns the RSS templates folder name
 *///from   w  ww .j av  a  2  s  .c o m
public static String getRSSTemplatesFolderName(ServletContext context) {
    return getRSSTemplatesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context));
}

From source file:org.alfresco.web.app.Application.java

/**
 * @return Return the Saved Searches folder name
 *//*  w  ww.  java  2 s.  c o  m*/
public static String getSavedSearchesFolderName(ServletContext context) {
    return getSavedSearchesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context));
}

From source file:org.alfresco.web.app.Application.java

/**
 * @return Return the JavaScript scripts folder name
 *//*from   w w  w . ja va2 s.  c  o  m*/
public static String getScriptsFolderName(ServletContext context) {
    return getScriptsFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context));
}

From source file:org.alfresco.web.app.Application.java

/**
 * @return Return the Guest Home folder name
 *///ww  w .  jav  a 2  s . c om
public static String getGuestHomeFolderName(ServletContext context) {
    return getGuestHomeFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context));
}

From source file:org.alfresco.web.app.Application.java

/**
 * Return the language Locale for the current user Session.
 * //www.  j  ava 2 s. com
 * @param session
 *           HttpSession for the current user
 * @param useInterfaceLanguage
 *           If the session language hasn't been established yet, should we base it on user preferences?
 * @return Current language Locale set or the VM default if none set - never null
 */
public static Locale getLanguage(HttpSession session, boolean useInterfaceLanguage) {
    Boolean useSessionLocale = (Boolean) session.getAttribute(USE_SESSION_LOCALE);
    if (useSessionLocale == null) {
        useSessionLocale = useInterfaceLanguage;
        session.setAttribute(USE_SESSION_LOCALE, useSessionLocale);
    }
    Locale locale = (Locale) session.getAttribute(LOCALE);
    if (locale == null || (!locale.equals(I18NUtil.getLocale()) && !useInterfaceLanguage)) {
        if (useSessionLocale && useInterfaceLanguage) {
            // first check saved user preferences
            String strLocale = null;
            if (getCurrentUser(session) != null) {
                strLocale = (String) PreferencesService.getPreferences(session)
                        .getValue(UserPreferencesBean.PREF_INTERFACELANGUAGE);
                if (strLocale != null) {
                    locale = I18NUtil.parseLocale(strLocale);
                } else {
                    // failing that, use the server default locale
                    locale = Locale.getDefault();
                }
            } else {
                // else get from web-client config - the first item in the configured list of languages
                locale = getLanguage(WebApplicationContextUtils
                        .getRequiredWebApplicationContext(session.getServletContext()));

            }

            // This is an interface session - the same locale will be used for the rest of the session
            session.setAttribute(LOCALE, locale);
        } else {
            // Get the request default, already decoded from the request headers
            locale = I18NUtil.getLocale();
        }
    }
    return locale;
}

From source file:org.alfresco.web.app.Application.java

/**
 * Helper to get the ConfigService instance
 * /*from   w  ww.  j  av  a 2  s.c  om*/
 * @param context        ServletContext
 * 
 * @return ConfigService
 */
public static ConfigService getConfigService(ServletContext context) {
    return (ConfigService) WebApplicationContextUtils.getRequiredWebApplicationContext(context)
            .getBean(Application.BEAN_CONFIG_SERVICE);
}