Search in sources :

Example 21 with ConfigElement

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

the class BaseActionWizard method getAddableAspects.

/**
 * Returns a list of aspects that can be added
 *
 * @return List of SelectItem objects representing the aspects that can be added
 */
public List<SelectItem> getAddableAspects() {
    if ((this.addableAspects == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        // get the list of common aspects
        this.addableAspects = new ArrayList<SelectItem>();
        this.addableAspects.addAll(getCommonAspects());
        // get those aspects configured to appear only in the remove aspect action
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects-add");
            if (aspectsCfg != null) {
                List<SelectItem> aspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
                this.addableAspects.addAll(aspects);
            } else {
                logger.warn("Could not find 'aspects-add' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
        // make sure the list is sorted by the label
        QuickSort sorter = new QuickSort(this.addableAspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
    }
    return this.addableAspects;
}
Also used : 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 22 with ConfigElement

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

the class BaseActionWizard method getCommonAspects.

/**
 * Returns the aspects that are available in all scenarios i.e. add, remove and test
 *
 * @return List of SelectItem objects representing the available aspects
 */
protected List<SelectItem> getCommonAspects() {
    if ((this.commonAspects == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects");
            if (aspectsCfg != null) {
                this.commonAspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
            } else {
                logger.warn("Could not find 'aspects' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
    }
    return this.commonAspects;
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) Config(org.springframework.extensions.config.Config)

Example 23 with ConfigElement

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

the class BaseActionWizard method getObjectTypes.

/**
 * @return Returns a list of object types to allow the user to select from
 */
public List<SelectItem> getObjectTypes() {
    if ((this.objectTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        FacesContext context = FacesContext.getCurrentInstance();
        // add the well known object type to start with
        this.objectTypes = new ArrayList<SelectItem>(5);
        // add any configured content or folder sub-types to the list
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement typesCfg = wizardCfg.getConfigElement("specialise-types");
            if (typesCfg != null) {
                for (ConfigElement child : typesCfg.getChildren()) {
                    QName idQName = Repository.resolveToQName(child.getAttribute("name"));
                    TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
                    // the content or folder type itself
                    if (typeDef != null && typeDef.getName().equals(ContentModel.TYPE_CONTENT) == false && typeDef.getName().equals(ContentModel.TYPE_FOLDER) == false && (this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_CONTENT) || this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_FOLDER))) {
                        // try and get the display label from config
                        String label = Utils.getDisplayLabel(context, child);
                        // if there wasn't a client based label try and get it from the dictionary
                        if (label == null) {
                            label = typeDef.getTitle(this.getDictionaryService());
                        }
                        // finally, just use the localname
                        if (label == null) {
                            label = idQName.getLocalName();
                        }
                        this.objectTypes.add(new SelectItem(idQName.toString(), label));
                    }
                }
                // make sure the list is sorted by the label
                QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
                sorter.sort();
                // add the select an action item at the start of the list
                this.objectTypes.add(0, new SelectItem("null", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_type")));
            } else {
                logger.warn("Could not find 'specialise-types' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
    }
    return this.objectTypes;
}
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) QName(org.alfresco.service.namespace.QName) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition)

Example 24 with ConfigElement

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

the class BaseActionWizard method getRemovableAspects.

/**
 * Returns a list of aspects that can be removed
 *
 * @return List of SelectItem objects representing the aspects that can be removed
 */
public List<SelectItem> getRemovableAspects() {
    if ((this.removableAspects == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        // get the list of common aspects
        this.removableAspects = new ArrayList<SelectItem>();
        this.removableAspects.addAll(getCommonAspects());
        // get those aspects configured to appear only in the remove aspect action
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects-remove");
            if (aspectsCfg != null) {
                List<SelectItem> aspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
                this.removableAspects.addAll(aspects);
            } else {
                logger.warn("Could not find 'aspects-remove' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
        // make sure the list is sorted by the label
        QuickSort sorter = new QuickSort(this.removableAspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
    }
    return this.removableAspects;
}
Also used : 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 25 with ConfigElement

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

the class BaseActionWizard method getTransformers.

/**
 * Returns the transformers that are available
 *
 * @return List of SelectItem objects representing the available transformers
 */
public List<SelectItem> getTransformers() {
    if ((this.transformers == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement transformersCfg = wizardCfg.getConfigElement("transformers");
            if (transformersCfg != null) {
                FacesContext context = FacesContext.getCurrentInstance();
                Map<String, String> mimeTypes = this.getMimetypeService().getDisplaysByMimetype();
                this.transformers = 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.transformers.add(new SelectItem(id, label));
                }
                // make sure the list is sorted by the label
                QuickSort sorter = new QuickSort(this.transformers, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
                sorter.sort();
            } else {
                logger.warn("Could not find 'transformers' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
    }
    return this.transformers;
}
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