Search in sources :

Example 16 with ConfigService

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

the class AddContentDialog method getInlineEditableMimeTypes.

protected List<String> getInlineEditableMimeTypes() {
    if ((this.inlineEditableMimeTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        this.inlineEditableMimeTypes = new ArrayList<String>(8);
        // get the create mime types list from the config
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Content Wizards");
        if (wizardCfg != null) {
            ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types");
            if (typesCfg != null) {
                for (ConfigElement child : typesCfg.getChildren()) {
                    String currentMimeType = child.getAttribute("name");
                    this.inlineEditableMimeTypes.add(currentMimeType);
                }
            }
        }
    }
    return this.inlineEditableMimeTypes;
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) Config(org.springframework.extensions.config.Config)

Example 17 with ConfigService

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

the class BaseContentWizard method initOtherProperties.

/**
 * Initialises the other properties flags from config
 */
protected void initOtherProperties() {
    // TODO - review implications of these default values for dynamic/MT client
    ConfigService configSvc = Application.getConfigService(FacesContext.getCurrentInstance());
    if (configSvc != null) {
        Config config = configSvc.getConfig("Content Wizards");
        if (config != null) {
            ConfigElement otherPropsCfg = config.getConfigElement("other-properties");
            if (otherPropsCfg != null) {
                // get the attributes
                String userChoiceVisible = otherPropsCfg.getAttribute("user-choice-visible");
                String userChoiceDefault = otherPropsCfg.getAttribute("user-choice-default");
                // set the defaults
                if (userChoiceVisible != null) {
                    this.otherPropertiesChoiceVisible = Boolean.parseBoolean(userChoiceVisible);
                }
                if (userChoiceDefault != null) {
                    this.showOtherProperties = Boolean.parseBoolean(userChoiceDefault);
                }
            }
        }
    }
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) Config(org.springframework.extensions.config.Config)

Example 18 with ConfigService

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

the class BaseContentWizard method getEncoding.

/**
 * @return  Returns the encoding currently selected
 */
public String getEncoding() {
    if (encoding == null) {
        ConfigService configSvc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config config = configSvc.getConfig("Content Wizards");
        if (config != null) {
            ConfigElement defaultEncCfg = config.getConfigElement("default-encoding");
            if (defaultEncCfg != null) {
                String value = defaultEncCfg.getValue();
                if (value != null) {
                    encoding = value.trim();
                }
            }
        }
        if (encoding == null || encoding.length() == 0) {
            // if not configured, set to a sensible default for most character sets
            encoding = "UTF-8";
        }
    }
    return encoding;
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) Config(org.springframework.extensions.config.Config)

Example 19 with ConfigService

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

the class CreateContentWizard method getCreateMimeTypes.

/**
 * @return Returns a list of mime types to allow the user to select from
 */
public List<SelectItem> getCreateMimeTypes() {
    if ((this.createMimeTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        FacesContext context = FacesContext.getCurrentInstance();
        // add the well known object type to start with
        this.createMimeTypes = new ArrayList<SelectItem>(5);
        // add the configured create mime types to the list
        ConfigService svc = Application.getConfigService(context);
        Config wizardCfg = svc.getConfig("Content Wizards");
        if (wizardCfg != null) {
            ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types");
            if (typesCfg != null) {
                for (ConfigElement child : typesCfg.getChildren()) {
                    String currentMimeType = child.getAttribute("name");
                    if (currentMimeType != null) {
                        String label = getSummaryMimeType(currentMimeType);
                        this.createMimeTypes.add(new SelectItem(currentMimeType, label));
                    }
                }
                // make sure the list is sorted by the label
                QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
                sorter.sort();
            } else {
                logger.warn("Could not find 'create-mime-types' configuration element");
            }
        } else {
            logger.warn("Could not find 'Content Wizards' configuration section");
        }
    }
    return this.createMimeTypes;
}
Also used : FacesContext(javax.faces.context.FacesContext) QuickSort(org.alfresco.web.data.QuickSort) ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) SelectItem(javax.faces.model.SelectItem) Config(org.springframework.extensions.config.Config)

Example 20 with ConfigService

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

the class BrowseBean method initFromClientConfig.

// ------------------------------------------------------------------------------
// Private helpers
/**
 * Initialise default values from client configuration
 */
private void initFromClientConfig() {
    // TODO - review implications of these default values on dynamic/MT client: viewsConfig & browseViewMode, as well as page size content/spaces ...
    ConfigService config = Application.getConfigService(FacesContext.getCurrentInstance());
    this.viewsConfig = (ViewsConfigElement) config.getConfig("Views").getConfigElement(ViewsConfigElement.CONFIG_ELEMENT_ID);
    this.browseViewMode = this.viewsConfig.getDefaultView(PAGE_NAME_BROWSE);
    int pageSize = this.viewsConfig.getDefaultPageSize(PAGE_NAME_BROWSE, this.browseViewMode);
    setPageSizeContent(pageSize);
    setPageSizeSpaces(pageSize);
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService)

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