use of org.springframework.extensions.config.ConfigException in project acs-community-packaging by Alfresco.
the class PropertySheetElementReader method parse.
/**
* @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
*/
@SuppressWarnings("unchecked")
public ConfigElement parse(Element element) {
PropertySheetConfigElement configElement = null;
if (element != null) {
String name = element.getName();
if (name.equals(ELEMENT_PROPERTY_SHEET) == false) {
throw new ConfigException("PropertySheetElementReader can only parse " + ELEMENT_PROPERTY_SHEET + "elements, " + "the element passed was '" + name + "'");
}
configElement = new PropertySheetConfigElement();
// go through the items to show
Iterator<Element> items = element.elementIterator();
while (items.hasNext()) {
Element item = items.next();
String propName = item.attributeValue(ATTR_NAME);
String label = item.attributeValue(ATTR_DISPLAY_LABEL);
String labelId = item.attributeValue(ATTR_DISPLAY_LABEL_ID);
String readOnly = item.attributeValue(ATTR_READ_ONLY);
String converter = item.attributeValue(ATTR_CONVERTER);
String inEdit = item.attributeValue(ATTR_SHOW_IN_EDIT_MODE);
String inView = item.attributeValue(ATTR_SHOW_IN_VIEW_MODE);
String compGenerator = item.attributeValue(ATTR_COMPONENT_GENERATOR);
if (ELEMENT_SHOW_PROPERTY.equals(item.getName())) {
String ignoreIfMissing = item.attributeValue(ATTR_IGNORE_IF_MISSING);
// add the property to show to the custom config element
configElement.addProperty(propName, label, labelId, readOnly, converter, inView, inEdit, compGenerator, ignoreIfMissing);
} else if (ELEMENT_SHOW_ASSOC.equals(item.getName())) {
configElement.addAssociation(propName, label, labelId, readOnly, converter, inView, inEdit, compGenerator);
} else if (ELEMENT_SHOW_CHILD_ASSOC.equals(item.getName())) {
configElement.addChildAssociation(propName, label, labelId, readOnly, converter, inView, inEdit, compGenerator);
} else if (ELEMENT_SEPARATOR.equals(item.getName())) {
configElement.addSeparator(propName, label, labelId, inView, inEdit, compGenerator);
}
}
}
return configElement;
}
use of org.springframework.extensions.config.ConfigException in project acs-community-packaging by Alfresco.
the class WizardsElementReader method parseStep.
/**
* Parses the given element which represents a step in a wizard
*
* @param step The Element representing the step
* @return A StepConfig object
*/
protected StepConfig parseStep(Element step) {
// get the name of the step and create the config object
String stepName = step.attributeValue(ATTR_NAME);
String stepTitle = step.attributeValue(ATTR_TITLE);
String stepTitleId = step.attributeValue(ATTR_TITLE_ID);
String stepDescription = step.attributeValue(ATTR_DESCRIPTION);
String stepDescriptionId = step.attributeValue(ATTR_DESCRIPTION_ID);
StepConfig stepCfg = new StepConfig(stepName, stepTitle, stepTitleId, stepDescription, stepDescriptionId);
// find and parse the default page
Element defaultPageElem = step.element(ELEMENT_PAGE);
if (defaultPageElem != null) {
String path = defaultPageElem.attributeValue(ATTR_PATH);
String title = defaultPageElem.attributeValue(ATTR_TITLE);
String titleId = defaultPageElem.attributeValue(ATTR_TITLE_ID);
String description = defaultPageElem.attributeValue(ATTR_DESCRIPTION);
String descriptionId = defaultPageElem.attributeValue(ATTR_DESCRIPTION_ID);
String instruction = defaultPageElem.attributeValue(ATTR_INSTRUCTION);
String instructionId = defaultPageElem.attributeValue(ATTR_INSTRUCTION_ID);
// create and set the page config on the step
stepCfg.setDefaultPage(new PageConfig(path, title, titleId, description, descriptionId, instruction, instructionId));
}
// find and parse any conditions that are present
Iterator<Element> conditions = step.elementIterator(ELEMENT_CONDITION);
while (conditions.hasNext()) {
Element conditionElem = conditions.next();
String ifAttr = conditionElem.attributeValue(ATTR_IF);
Element conditionalPageElem = conditionElem.element(ELEMENT_PAGE);
if (conditionalPageElem == null) {
throw new ConfigException("A condition in step '" + stepCfg.getName() + "' does not have a containing <page> element");
}
String path = conditionalPageElem.attributeValue(ATTR_PATH);
String title = conditionalPageElem.attributeValue(ATTR_TITLE);
String titleId = conditionalPageElem.attributeValue(ATTR_TITLE_ID);
String description = conditionalPageElem.attributeValue(ATTR_DESCRIPTION);
String descriptionId = conditionalPageElem.attributeValue(ATTR_DESCRIPTION_ID);
String instruction = conditionalPageElem.attributeValue(ATTR_INSTRUCTION);
String instructionId = conditionalPageElem.attributeValue(ATTR_INSTRUCTION_ID);
// create and add the page to the step
stepCfg.addConditionalPage(new ConditionalPageConfig(path, ifAttr, title, titleId, description, descriptionId, instruction, instructionId));
}
return stepCfg;
}
use of org.springframework.extensions.config.ConfigException 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;
}
use of org.springframework.extensions.config.ConfigException in project acs-community-packaging by Alfresco.
the class DashboardsElementReader method parseDashletDefinition.
/**
* Parse a single Dashlet definition from config.
*
* @param config Element
*
* @return DashletDefinition for the specified config element.
*/
private static DashletDefinition parseDashletDefinition(Element config) {
String id = getMandatoryDashletAttributeValue(config, ATTR_ID);
DashletDefinition def = new DashletDefinition(id);
String allowNarrow = config.attributeValue(ATTR_ALLOWNARROW);
if (allowNarrow != null && allowNarrow.length() != 0) {
def.AllowNarrow = Boolean.parseBoolean(allowNarrow);
}
def.JSPPage = getMandatoryDashletAttributeValue(config, ATTR_JSP);
def.ConfigJSPPage = config.attributeValue(ATTR_CONFIGJSP);
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 'dashlet' 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 'dashlet' configuration element.");
}
def.Description = description;
def.DescriptionId = descriptionId;
return def;
}
use of org.springframework.extensions.config.ConfigException 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;
}
Aggregations