Search in sources :

Example 16 with ConfigElement

use of org.springframework.extensions.config.ConfigElement 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 17 with ConfigElement

use of org.springframework.extensions.config.ConfigElement 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 18 with ConfigElement

use of org.springframework.extensions.config.ConfigElement 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 19 with ConfigElement

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

the class BrowseBean method getNodeEventListeners.

/**
 * @return the Set of NodeEventListeners registered against this bean
 */
private Set<NodeEventListener> getNodeEventListeners() {
    if ((this.nodeEventListeners == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        Set<NodeEventListener> allNodeEventListeners = new HashSet<NodeEventListener>();
        if (Application.isDynamicConfig(FacesContext.getCurrentInstance()) && (this.nodeEventListeners != null)) {
            // for dynamic config, can add/remove node event listeners dynamically ...
            // however, in case anyone is using public methods (add/removeNodeEventListener)
            // we merge list here with list returned from the config
            allNodeEventListeners.addAll(this.nodeEventListeners);
        }
        FacesContext fc = FacesContext.getCurrentInstance();
        Config listenerConfig = Application.getConfigService(fc).getConfig("Node Event Listeners");
        if (listenerConfig != null) {
            ConfigElement listenerElement = listenerConfig.getConfigElement("node-event-listeners");
            if (listenerElement != null) {
                for (ConfigElement child : listenerElement.getChildren()) {
                    if (child.getName().equals("listener")) {
                        // retrieved the JSF Managed Bean identified in the config
                        String listenerName = child.getValue().trim();
                        Object bean = FacesHelper.getManagedBean(fc, listenerName);
                        if (bean instanceof NodeEventListener) {
                            allNodeEventListeners.add((NodeEventListener) bean);
                        }
                    }
                }
            }
        }
        if (Application.isDynamicConfig(FacesContext.getCurrentInstance())) {
            return allNodeEventListeners;
        } else {
            this.nodeEventListeners = allNodeEventListeners;
        }
    }
    return this.nodeEventListeners;
}
Also used : FacesContext(javax.faces.context.FacesContext) ViewsConfigElement(org.alfresco.web.config.ViewsConfigElement) ConfigElement(org.springframework.extensions.config.ConfigElement) ClientConfigElement(org.alfresco.web.config.ClientConfigElement) Config(org.springframework.extensions.config.Config) HashSet(java.util.HashSet)

Example 20 with ConfigElement

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

the class BaseActionWizard method getImageTransformers.

/**
 * Returns the image transformers that are available
 *
 * @return List of SelectItem objects representing the available image transformers
 */
public List<SelectItem> getImageTransformers() {
    if ((this.imageTransformers == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement transformersCfg = wizardCfg.getConfigElement("image-transformers");
            if (transformersCfg != null) {
                FacesContext context = FacesContext.getCurrentInstance();
                Map<String, String> mimeTypes = this.getMimetypeService().getDisplaysByMimetype();
                this.imageTransformers = new ArrayList<SelectItem>();
                for (ConfigElement child : transformersCfg.getChildren()) {
                    String id = child.getAttribute("name");
                    // try and get the display label from config
                    String label = Utils.getDisplayLabel(context, child);
                    // if there wasn't a client based label get it from the mime type service
                    if (label == null) {
                        label = mimeTypes.get(id);
                    }
                    // if there is still no label use the raw mimetype
                    if (label == null) {
                        label = id;
                    }
                    this.imageTransformers.add(new SelectItem(id, label));
                }
                // make sure the list is sorted by the label
                QuickSort sorter = new QuickSort(this.imageTransformers, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
                sorter.sort();
            } else {
                logger.warn("Could not find 'image-transformers' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
    }
    return this.imageTransformers;
}
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) Config(org.springframework.extensions.config.Config) SelectItem(javax.faces.model.SelectItem)

Aggregations

ConfigElement (org.springframework.extensions.config.ConfigElement)38 Config (org.springframework.extensions.config.Config)21 ConfigService (org.springframework.extensions.config.ConfigService)18 Element (org.dom4j.Element)14 ConfigException (org.springframework.extensions.config.ConfigException)13 SelectItem (javax.faces.model.SelectItem)11 FacesContext (javax.faces.context.FacesContext)10 QuickSort (org.alfresco.web.data.QuickSort)9 QName (org.alfresco.service.namespace.QName)7 ArrayList (java.util.ArrayList)4 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)4 UIListItem (org.alfresco.web.ui.common.component.UIListItem)3 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 UIComponent (javax.faces.component.UIComponent)1