Search in sources :

Example 11 with ConfigElement

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

the class WizardsElementReader method parse.

/**
 * @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
 */
public ConfigElement parse(Element element) {
    WizardsConfigElement configElement = null;
    if (element != null) {
        String elementName = element.getName();
        if (elementName.equals(ELEMENT_WIZARDS) == false) {
            throw new ConfigException("WizardsElementReader can only parse " + ELEMENT_WIZARDS + "elements, the element passed was '" + elementName + "'");
        }
        configElement = new WizardsConfigElement();
        // go through the items to show
        Iterator<Element> items = element.elementIterator(ELEMENT_WIZARD);
        while (items.hasNext()) {
            Element wizard = items.next();
            String name = wizard.attributeValue(ATTR_NAME);
            String bean = wizard.attributeValue(ATTR_MANAGED_BEAN);
            String icon = wizard.attributeValue(ATTR_ICON);
            String title = wizard.attributeValue(ATTR_TITLE);
            String titleId = wizard.attributeValue(ATTR_TITLE_ID);
            String subTitle = wizard.attributeValue(ATTR_SUBTITLE);
            String subTitleId = wizard.attributeValue(ATTR_SUBTITLE_ID);
            String description = wizard.attributeValue(ATTR_DESCRIPTION);
            String descriptionId = wizard.attributeValue(ATTR_DESCRIPTION_ID);
            String errorMsgId = wizard.attributeValue(ATTR_ERROR_MSG_ID);
            // create the wizard config object
            WizardsConfigElement.WizardConfig wizardCfg = new WizardsConfigElement.WizardConfig(name, bean, icon, title, titleId, subTitle, subTitleId, description, descriptionId, errorMsgId);
            Iterator<Element> steps = wizard.elementIterator(ELEMENT_STEP);
            while (steps.hasNext()) {
                StepConfig stepCfg = parseStep(steps.next());
                wizardCfg.addStep(stepCfg);
            }
            configElement.addWizard(wizardCfg);
        }
    }
    return configElement;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) Element(org.dom4j.Element) StepConfig(org.alfresco.web.config.WizardsConfigElement.StepConfig) ConfigException(org.springframework.extensions.config.ConfigException)

Example 12 with ConfigElement

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

the class LanguagesElementReader method parse.

/**
 * @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
 */
@SuppressWarnings("unchecked")
public ConfigElement parse(Element element) {
    LanguagesConfigElement configElement = null;
    if (element != null) {
        String name = element.getName();
        if (name.equals(LanguagesConfigElement.CONFIG_ELEMENT_ID) == false) {
            throw new ConfigException("LanguagesElementReader can only parse " + LanguagesConfigElement.CONFIG_ELEMENT_ID + " elements, the element passed was '" + name + "'");
        }
        configElement = new LanguagesConfigElement();
        Iterator<Element> langsItr = element.elementIterator(ELEMENT_LANGUAGE);
        while (langsItr.hasNext()) {
            Element language = langsItr.next();
            String localeCode = language.attributeValue(ATTRIBUTE_LOCALE);
            String label = language.getTextTrim();
            if (localeCode != null && localeCode.length() != 0 && label != null && label.length() != 0) {
                // store the language code against the display label
                configElement.addLanguage(localeCode, label);
            }
        }
    }
    return configElement;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) Element(org.dom4j.Element) ConfigException(org.springframework.extensions.config.ConfigException)

Example 13 with ConfigElement

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

the class NavigationConfigElement method getChildren.

/**
 * @see ConfigElement#getChildren()
 */
public List<ConfigElement> getChildren() {
    // lazily build the list of generic config elements representing
    // the navigation overrides as the caller may not even call this method
    List<ConfigElement> kids = null;
    if (this.viewIds.size() > 0 || this.outcomes.size() > 0) {
        if (this.kidsPopulated == false) {
            // create generic config elements for the from-view-id items
            for (String fromViewId : this.viewIds.keySet()) {
                GenericConfigElement ce = new GenericConfigElement(NavigationElementReader.ELEMENT_OVERRIDE);
                ce.addAttribute(NavigationElementReader.ATTR_FROM_VIEWID, fromViewId);
                NavigationResult navRes = this.viewIds.get(fromViewId);
                String result = navRes.getResult();
                if (navRes.isOutcome()) {
                    ce.addAttribute(NavigationElementReader.ATTR_TO_OUTCOME, result);
                } else {
                    ce.addAttribute(NavigationElementReader.ATTR_TO_VIEWID, result);
                }
                // add the element
                this.children.add(ce);
            }
            // create generic config elements for the from-outcome items
            for (String fromOutcome : this.outcomes.keySet()) {
                GenericConfigElement ce = new GenericConfigElement(NavigationElementReader.ELEMENT_OVERRIDE);
                ce.addAttribute(NavigationElementReader.ATTR_FROM_OUTCOME, fromOutcome);
                NavigationResult navRes = this.outcomes.get(fromOutcome);
                String result = navRes.getResult();
                if (navRes.isOutcome()) {
                    ce.addAttribute(NavigationElementReader.ATTR_TO_OUTCOME, result);
                } else {
                    ce.addAttribute(NavigationElementReader.ATTR_TO_VIEWID, result);
                }
                // add the element
                this.children.add(ce);
            }
            this.kidsPopulated = true;
        }
        kids = super.getChildren();
    }
    return kids;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) GenericConfigElement(org.springframework.extensions.config.element.GenericConfigElement) GenericConfigElement(org.springframework.extensions.config.element.GenericConfigElement)

Example 14 with ConfigElement

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

the class NavigationElementReader method parse.

/**
 * @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
 */
public ConfigElement parse(Element element) {
    NavigationConfigElement configElement = null;
    if (element != null) {
        String name = element.getName();
        if (ELEMENT_NAVIGATION.equals(name) == false) {
            throw new ConfigException("NavigationElementReader can only parse " + ELEMENT_NAVIGATION + "elements, " + "the element passed was '" + name + "'");
        }
        configElement = new NavigationConfigElement();
        // go through the items to show
        Iterator<Element> items = element.elementIterator();
        while (items.hasNext()) {
            Element item = items.next();
            // only process the override elements
            if (ELEMENT_OVERRIDE.equals(item.getName())) {
                String fromViewId = item.attributeValue(ATTR_FROM_VIEWID);
                String fromOutcome = item.attributeValue(ATTR_FROM_OUTCOME);
                String toViewId = item.attributeValue(ATTR_TO_VIEWID);
                String toOutcome = item.attributeValue(ATTR_TO_OUTCOME);
                configElement.addOverride(fromViewId, fromOutcome, toViewId, toOutcome);
            }
        }
    }
    return configElement;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) Element(org.dom4j.Element) ConfigException(org.springframework.extensions.config.ConfigException)

Example 15 with ConfigElement

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

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