Search in sources :

Example 11 with ConfigService

use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.

the class AlfrescoNavigationHandler method getWizardContainer.

/**
 * Retrieves the configured wizard container page
 *
 * @param context FacesContext
 * @return The container page
 */
protected String getWizardContainer(FacesContext context) {
    String container;
    // determine which kind of container we need to return, if the
    // external session flag is set then use the plain container
    Object obj = context.getExternalContext().getSessionMap().get(EXTERNAL_CONTAINER_SESSION);
    if (obj != null && obj instanceof Boolean && ((Boolean) obj).booleanValue()) {
        if ((this.plainWizardContainer == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
            ConfigService configSvc = Application.getConfigService(context);
            Config globalConfig = configSvc.getGlobalConfig();
            if (globalConfig != null) {
                this.plainWizardContainer = globalConfig.getConfigElement("plain-wizard-container").getValue();
            }
        }
        container = this.plainWizardContainer;
    } else {
        if ((this.wizardContainer == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
            ConfigService configSvc = Application.getConfigService(context);
            Config globalConfig = configSvc.getGlobalConfig();
            if (globalConfig != null) {
                this.wizardContainer = globalConfig.getConfigElement("wizard-container").getValue();
            }
        }
        container = this.wizardContainer;
    }
    if (logger.isDebugEnabled())
        logger.debug("Using wizard container: " + container);
    return container;
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) WizardConfig(org.alfresco.web.config.WizardsConfigElement.WizardConfig) DialogConfig(org.alfresco.web.config.DialogsConfigElement.DialogConfig) Config(org.springframework.extensions.config.Config)

Example 12 with ConfigService

use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.

the class AlfrescoNavigationHandler method getWizardConfig.

/**
 * Returns the wizard configuration object for the given wizard name.
 * If there is a node in the dispatch context a lookup is performed using
 * the node otherwise the global config section is used.
 *
 * @param name The name of wizard being launched
 * @param dispatchContext The node being acted upon
 * @return The WizardConfig for the wizard or null if no config could be found
 */
protected WizardConfig getWizardConfig(FacesContext context, String name, Node dispatchContext) {
    WizardConfig wizardConfig = null;
    ConfigService configSvc = Application.getConfigService(context);
    Config config = null;
    if (dispatchContext != null) {
        if (logger.isDebugEnabled())
            logger.debug("Using dispatch context for wizard lookup: " + dispatchContext.getType().toString());
        // use the node to perform the lookup (this will include the global section)
        config = configSvc.getConfig(dispatchContext);
    } else {
        if (logger.isDebugEnabled())
            logger.debug("Looking up wizard in global config");
        // just use the global
        config = configSvc.getGlobalConfig();
    }
    if (config != null) {
        WizardsConfigElement wizardsCfg = (WizardsConfigElement) config.getConfigElement(WizardsConfigElement.CONFIG_ELEMENT_ID);
        if (wizardsCfg != null) {
            wizardConfig = wizardsCfg.getWizard(name);
        }
    }
    return wizardConfig;
}
Also used : WizardsConfigElement(org.alfresco.web.config.WizardsConfigElement) ConfigService(org.springframework.extensions.config.ConfigService) WizardConfig(org.alfresco.web.config.WizardsConfigElement.WizardConfig) DialogConfig(org.alfresco.web.config.DialogsConfigElement.DialogConfig) Config(org.springframework.extensions.config.Config) WizardConfig(org.alfresco.web.config.WizardsConfigElement.WizardConfig)

Example 13 with ConfigService

use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.

the class AlfrescoNavigationHandler method getDialogConfig.

/**
 * Returns the dialog configuration object for the given dialog name.
 * If there is a node in the dispatch context a lookup is performed using
 * the node otherwise the global config section is used.
 *
 * @param name The name of dialog being launched
 * @param dispatchContext The node being acted upon
 * @return The DialogConfig for the dialog or null if no config could be found
 */
protected DialogConfig getDialogConfig(FacesContext context, String name, Node dispatchContext) {
    DialogConfig dialogConfig = null;
    ConfigService configSvc = Application.getConfigService(context);
    Config config = null;
    if (dispatchContext != null) {
        if (logger.isDebugEnabled())
            logger.debug("Using dispatch context for dialog lookup: " + dispatchContext.getType().toString());
        // use the node to perform the lookup (this will include the global section)
        config = configSvc.getConfig(dispatchContext);
    } else {
        if (logger.isDebugEnabled())
            logger.debug("Looking up dialog in global config");
        // just use the global
        config = configSvc.getGlobalConfig();
    }
    if (config != null) {
        DialogsConfigElement dialogsCfg = (DialogsConfigElement) config.getConfigElement(DialogsConfigElement.CONFIG_ELEMENT_ID);
        if (dialogsCfg != null) {
            dialogConfig = dialogsCfg.getDialog(name);
        }
    }
    return dialogConfig;
}
Also used : DialogConfig(org.alfresco.web.config.DialogsConfigElement.DialogConfig) ConfigService(org.springframework.extensions.config.ConfigService) WizardConfig(org.alfresco.web.config.WizardsConfigElement.WizardConfig) DialogConfig(org.alfresco.web.config.DialogsConfigElement.DialogConfig) Config(org.springframework.extensions.config.Config) DialogsConfigElement(org.alfresco.web.config.DialogsConfigElement)

Example 14 with ConfigService

use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.

the class Application method getLoginPage.

/**
 * Retrieves the configured login page for the application
 *
 * @param context The Spring contexr
 * @return The configured login page or null if the configuration is missing
 */
public static String getLoginPage(ApplicationContext context) {
    String loginPage = null;
    ConfigService svc = (ConfigService) context.getBean(BEAN_CONFIG_SERVICE);
    ClientConfigElement clientConfig = (ClientConfigElement) svc.getGlobalConfig().getConfigElement(ClientConfigElement.CONFIG_ELEMENT_ID);
    if (clientConfig != null) {
        loginPage = clientConfig.getLoginPage();
    }
    return loginPage;
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) ClientConfigElement(org.alfresco.web.config.ClientConfigElement)

Example 15 with ConfigService

use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.

the class Application method getLanguage.

/**
 * Return the configured language Locale for the application context
 *
 * @param ctx
 *           the application context
 * @return Current language Locale set or the VM default if none set - never null
 */
public static Locale getLanguage(ApplicationContext ctx) {
    // get from web-client config - the first item in the configured list of languages
    Config config = ((ConfigService) ctx.getBean(Application.BEAN_CONFIG_SERVICE)).getConfig("Languages");
    LanguagesConfigElement langConfig = (LanguagesConfigElement) config.getConfigElement(LanguagesConfigElement.CONFIG_ELEMENT_ID);
    List<String> languages = langConfig.getLanguages();
    if (languages != null && languages.size() != 0) {
        return I18NUtil.parseLocale(languages.get(0));
    } else {
        // failing that, use the server default locale
        return Locale.getDefault();
    }
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) LanguagesConfigElement(org.alfresco.web.config.LanguagesConfigElement) Config(org.springframework.extensions.config.Config)

Aggregations

ConfigService (org.springframework.extensions.config.ConfigService)35 Config (org.springframework.extensions.config.Config)28 ConfigElement (org.springframework.extensions.config.ConfigElement)18 SelectItem (javax.faces.model.SelectItem)10 QuickSort (org.alfresco.web.data.QuickSort)9 FacesContext (javax.faces.context.FacesContext)7 DialogConfig (org.alfresco.web.config.DialogsConfigElement.DialogConfig)5 WizardConfig (org.alfresco.web.config.WizardsConfigElement.WizardConfig)5 ClientConfigElement (org.alfresco.web.config.ClientConfigElement)4 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)3 QName (org.alfresco.service.namespace.QName)3 IOException (java.io.IOException)2 Map (java.util.Map)2 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 PropertySheetConfigElement (org.alfresco.web.config.PropertySheetConfigElement)2 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 UIComponent (javax.faces.component.UIComponent)1 ResponseWriter (javax.faces.context.ResponseWriter)1 PropertyNotFoundException (javax.faces.el.PropertyNotFoundException)1