Search in sources :

Example 21 with ConfigService

use of org.springframework.extensions.config.ConfigService 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)

Example 22 with ConfigService

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

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

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

use of org.springframework.extensions.config.ConfigService 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)

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