Search in sources :

Example 11 with ConfigException

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

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

the class AdvancedSearchElementReader method parse.

/**
 * @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
 */
@SuppressWarnings("unchecked")
public ConfigElement parse(Element element) {
    AdvancedSearchConfigElement configElement = null;
    if (element != null) {
        String name = element.getName();
        if (name.equals(AdvancedSearchConfigElement.CONFIG_ELEMENT_ID) == false) {
            throw new ConfigException("AdvancedSearchElementReader can only parse " + AdvancedSearchConfigElement.CONFIG_ELEMENT_ID + " elements, the element passed was '" + name + "'");
        }
        configElement = new AdvancedSearchConfigElement();
        // get the list of content types
        Element contentTypes = element.element(ELEMENT_CONTENTTYPES);
        if (contentTypes != null) {
            Iterator<Element> typesItr = contentTypes.elementIterator(ELEMENT_TYPE);
            List<String> types = new ArrayList<String>(5);
            while (typesItr.hasNext()) {
                Element contentType = typesItr.next();
                String type = contentType.attributeValue(ATTRIBUTE_NAME);
                if (type != null) {
                    types.add(type);
                }
            }
            configElement.setContentTypes(types);
        }
        // get the list of folder types
        Element folderTypes = element.element(ELEMENT_FOLDERTYPES);
        if (folderTypes != null) {
            Iterator<Element> typesItr = folderTypes.elementIterator(ELEMENT_TYPE);
            List<String> types = new ArrayList<String>(5);
            while (typesItr.hasNext()) {
                Element folderType = typesItr.next();
                String type = folderType.attributeValue(ATTRIBUTE_NAME);
                if (type != null) {
                    types.add(type);
                }
            }
            configElement.setFolderTypes(types);
        }
        // get the list of custom properties to display
        Element customProps = element.element(ELEMENT_CUSTOMPROPS);
        if (customProps != null) {
            Iterator<Element> propsItr = customProps.elementIterator(ELEMENT_METADATA);
            List<CustomProperty> props = new ArrayList<CustomProperty>(5);
            while (propsItr.hasNext()) {
                Element propElement = propsItr.next();
                String type = propElement.attributeValue(ATTRIBUTE_TYPE);
                String aspect = propElement.attributeValue(ATTRIBUTE_ASPECT);
                String prop = propElement.attributeValue(ATTRIBUTE_PROPERTY);
                String labelId = propElement.attributeValue(ATTRIBUTE_DISPLAYLABEL);
                props.add(new AdvancedSearchConfigElement.CustomProperty(type, aspect, prop, labelId));
            }
            configElement.setCustomProperties(props);
        }
    }
    return configElement;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) Element(org.dom4j.Element) CustomProperty(org.alfresco.web.config.AdvancedSearchConfigElement.CustomProperty) ArrayList(java.util.ArrayList) CustomProperty(org.alfresco.web.config.AdvancedSearchConfigElement.CustomProperty) ConfigException(org.springframework.extensions.config.ConfigException)

Example 13 with ConfigException

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

the class CommandServletElementReader method parse.

/**
 * @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
 */
@SuppressWarnings("unchecked")
public ConfigElement parse(Element element) {
    CommandServletConfigElement configElement = new CommandServletConfigElement();
    if (element != null) {
        if (CommandServletConfigElement.CONFIG_ELEMENT_ID.equals(element.getName()) == false) {
            throw new ConfigException("CommandServletElementReader can only parse config elements of type 'command-servlet'");
        }
        Iterator<Element> itr = element.elementIterator(ELEMENT_COMMANDPROCESSOR);
        while (itr.hasNext()) {
            Element procElement = itr.next();
            String name = procElement.attributeValue(ATTRIBUTE_NAME);
            String className = procElement.attributeValue(ATTRIBUTE_CLASS);
            if (name == null || name.length() == 0) {
                throw new ConfigException("'name' attribute is mandatory for command processor config element.");
            }
            if (className == null || className.length() == 0) {
                throw new ConfigException("'class' attribute is mandatory for command processor config element.");
            }
            configElement.addCommandProcessor(name, className);
        }
    }
    return configElement;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) Element(org.dom4j.Element) ConfigException(org.springframework.extensions.config.ConfigException)

Example 14 with ConfigException

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

the class DashboardsElementReader method parseLayoutDefinition.

/**
 * Parse a single Layout definition from config.
 *
 * @param config Element
 *
 * @return LayoutDefinition for the specified config element.
 */
private static LayoutDefinition parseLayoutDefinition(Element config) {
    String id = getMandatoryLayoutAttributeValue(config, ATTR_ID);
    LayoutDefinition def = new LayoutDefinition(id);
    String columns = getMandatoryLayoutAttributeValue(config, ATTR_COLUMNS);
    def.Columns = Integer.parseInt(columns);
    String columnLength = getMandatoryLayoutAttributeValue(config, ATTR_COLUMNLENGTH);
    def.ColumnLength = Integer.parseInt(columnLength);
    def.Image = getMandatoryLayoutAttributeValue(config, ATTR_IMAGE);
    def.JSPPage = getMandatoryLayoutAttributeValue(config, ATTR_JSP);
    String label = config.attributeValue(ATTR_LABEL);
    String labelId = config.attributeValue(ATTR_LABELID);
    if ((label == null || label.length() == 0) && (labelId == null || labelId.length() == 0)) {
        throw new ConfigException("Either 'label' or 'label-id' attribute must be specified for Dashboard 'layout' configuration element.");
    }
    def.Label = label;
    def.LabelId = labelId;
    String description = config.attributeValue(ATTR_DESCRIPTION);
    String descriptionId = config.attributeValue(ATTR_DESCRIPTIONID);
    if ((description == null || description.length() == 0) && (descriptionId == null || descriptionId.length() == 0)) {
        throw new ConfigException("Either 'description' or 'description-id' attribute must be specified for Dashboard 'layout' configuration element.");
    }
    def.Description = description;
    def.DescriptionId = descriptionId;
    return def;
}
Also used : ConfigException(org.springframework.extensions.config.ConfigException) LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Example 15 with ConfigException

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

the class DashboardsElementReader method parse.

/**
 * @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
 */
@SuppressWarnings("unchecked")
public ConfigElement parse(Element element) {
    DashboardsConfigElement configElement = new DashboardsConfigElement();
    if (element != null) {
        if (DashboardsConfigElement.CONFIG_ELEMENT_ID.equals(element.getName()) == false) {
            throw new ConfigException("DashboardsElementReader can only process elements of type 'dashboards'");
        }
        Element layoutsElement = element.element(ELEMENT_LAYOUTS);
        if (layoutsElement != null) {
            Iterator<Element> layoutsItr = layoutsElement.elementIterator(ELEMENT_LAYOUT);
            while (layoutsItr.hasNext()) {
                LayoutDefinition layoutDef = parseLayoutDefinition(layoutsItr.next());
                configElement.addLayoutDefinition(layoutDef);
            }
        }
        Element dashletsElement = element.element(ELEMENT_DASHLETS);
        if (dashletsElement != null) {
            Iterator<Element> dashletsItr = dashletsElement.elementIterator(ELEMENT_DASHLET);
            while (dashletsItr.hasNext()) {
                DashletDefinition dashletDef = parseDashletDefinition(dashletsItr.next());
                configElement.addDashletDefinition(dashletDef);
            }
        }
        Element defaultDashletsElement = element.element(ELEMENT_DEFAULTDASHLETS);
        if (defaultDashletsElement != null) {
            Iterator<Element> dashletsItr = defaultDashletsElement.elementIterator(ELEMENT_DASHLET);
            while (dashletsItr.hasNext()) {
                String id = getMandatoryDashletAttributeValue(dashletsItr.next(), ATTR_ID);
                configElement.addDefaultDashlet(id);
            }
        }
        Element guestConfigElement = element.element(ELEMENT_GUESTCONFIG);
        if (guestConfigElement != null) {
            boolean allow = Boolean.parseBoolean(guestConfigElement.getTextTrim());
            configElement.setAllowGuestConfig(allow);
        }
    }
    return configElement;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) Element(org.dom4j.Element) ConfigException(org.springframework.extensions.config.ConfigException) DashletDefinition(org.alfresco.web.config.DashboardsConfigElement.DashletDefinition) LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Aggregations

ConfigException (org.springframework.extensions.config.ConfigException)18 Element (org.dom4j.Element)15 ConfigElement (org.springframework.extensions.config.ConfigElement)15 ArrayList (java.util.ArrayList)2 ActionDefinition (org.alfresco.web.config.ActionsConfigElement.ActionDefinition)2 DashletDefinition (org.alfresco.web.config.DashboardsConfigElement.DashletDefinition)2 LayoutDefinition (org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)2 StepConfig (org.alfresco.web.config.WizardsConfigElement.StepConfig)2 EngineConfig (org.alfresco.repo.web.scripts.config.OpenSearchConfigElement.EngineConfig)1 ProxyConfig (org.alfresco.repo.web.scripts.config.OpenSearchConfigElement.ProxyConfig)1 QName (org.alfresco.service.namespace.QName)1 ActionEvaluator (org.alfresco.web.action.ActionEvaluator)1 ActionGroup (org.alfresco.web.config.ActionsConfigElement.ActionGroup)1 CustomProperty (org.alfresco.web.config.AdvancedSearchConfigElement.CustomProperty)1 DialogButtonConfig (org.alfresco.web.config.DialogsConfigElement.DialogButtonConfig)1 ConditionalPageConfig (org.alfresco.web.config.WizardsConfigElement.ConditionalPageConfig)1 PageConfig (org.alfresco.web.config.WizardsConfigElement.PageConfig)1