/** * Creates a new XML content definition.<p> * * @param outerName the outer element name to use for the content definition * @param innerName the inner element name to use for the content definition * @param schemaLocation the location from which the XML schema was read (system id) */ public CmsXmlContentDefinition(String outerName, String innerName, String schemaLocation) { // TODO: this constructor can be removed or made 'protected', schemas should be only created from files m_outerName = outerName; m_innerName = innerName; setInnerName(innerName); m_typeSequence = new ArrayList<I_CmsXmlSchemaType>(); m_types = new HashMap<String, I_CmsXmlSchemaType>(); m_includes = new HashSet<CmsXmlContentDefinition>(); m_schemaLocation = schemaLocation; m_contentHandler = new CmsDefaultXmlContentHandler(); }
addCheckRule(contentDefinition, elementName, invalidate, type);
m_useAcacia = safeParseBoolean(root.attributeValue(ATTR_USE_ACACIA), true); Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(root, APPINFO_LAYOUT); while (i.hasNext()) { String displayCompact = element.attributeValue(APPINFO_ATTR_DISPLAY); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(displayCompact) && (elementName != null)) { addDisplayType(contentDefinition, elementName, DisplayType.valueOf(displayCompact)); addWidget(contentDefinition, elementName, widgetClassOrAlias); if (configuration != null) { addConfiguration(contentDefinition, elementName, configuration);
validateAppinfoElement(appInfoElement); init(); String nodeName = element.getName(); if (nodeName.equals(APPINFO_MAPPINGS)) { initMappings(element, contentDefinition); } else if (nodeName.equals(APPINFO_LAYOUTS)) { initLayouts(element, contentDefinition); } else if (nodeName.equals(APPINFO_VALIDATIONRULES)) { initValidationRules(element, contentDefinition); } else if (nodeName.equals(APPINFO_RELATIONS)) { initRelations(element, contentDefinition); } else if (nodeName.equals(APPINFO_DEFAULTS)) { initDefaultValues(element, contentDefinition); } else if (nodeName.equals(APPINFO_MODELFOLDER)) { initModelFolder(element, contentDefinition); } else if (nodeName.equals(APPINFO_PREVIEW)) { initPreview(element, contentDefinition); } else if (nodeName.equals(APPINFO_RESOURCEBUNDLE)) { initResourceBundle(element, contentDefinition); } else if (nodeName.equals(APPINFO_SEARCHSETTINGS)) { initSearchSettings(element, contentDefinition); } else if (nodeName.equals(APPINFO_TABS)) { initTabs(element, contentDefinition); addDefaultCheckRules(contentDefinition, null, null);
validateAppinfoElement(appInfoElement); init(); String nodeName = element.getName(); if (nodeName.equals(APPINFO_MAPPINGS)) { initMappings(element, contentDefinition); } else if (nodeName.equals(APPINFO_LAYOUTS)) { initLayouts(element, contentDefinition); } else if (nodeName.equals(APPINFO_VALIDATIONRULES)) { initValidationRules(element, contentDefinition); } else if (nodeName.equals(APPINFO_RELATIONS)) { initRelations(element, contentDefinition); } else if (nodeName.equals(APPINFO_DEFAULTS)) { initDefaultValues(element, contentDefinition); } else if (nodeName.equals(APPINFO_MODELFOLDER)) { initModelFolder(element, contentDefinition); } else if (nodeName.equals(APPINFO_PREVIEW)) { initPreview(element, contentDefinition); } else if (nodeName.equals(APPINFO_RESOURCEBUNDLE)) { initResourceBundle(element, contentDefinition, true); } else if (nodeName.equals(APPINFO_RESOURCEBUNDLES)) { initResourceBundle(element, contentDefinition, false); } else if (nodeName.equals(APPINFO_SEARCHSETTINGS)) { initSearchSettings(element, contentDefinition); } else if (nodeName.equals(APPINFO_TABS)) { initTabs(element, contentDefinition); } else if (nodeName.equals(APPINFO_FORMATTERS)) { initFormatters(element, contentDefinition);
if ((elementName != null) && (widgetClassOrAlias != null)) { addWidget(contentDefinition, elementName, widgetClassOrAlias); if (configuration != null) { addConfiguration(contentDefinition, elementName, configuration);
boolean include = (CmsStringUtil.isEmpty(searchContent)) || (Boolean.valueOf(searchContent).booleanValue()); if (elementName != null) { addSearchSetting(contentDefinition, elementName, Boolean.valueOf(include)); while (ite.hasNext()) { Element mappingElement = ite.next(); field.addMapping(createSearchFieldMapping(contentDefinition, mappingElement, locale)); field.addMapping(map); Set<I_CmsXmlContentHandler.MappingType> mappingTypes = parseSearchMappingTypes(solrElement); for (I_CmsXmlContentHandler.MappingType type : mappingTypes) { addSearchField(contentDefinition, field, type);
&& !m_relations.containsKey(elementPath)) { addCheckRule(rootContentDefinition, elementPath, null, null); String element = itElems.next(); String path = (schemaType != null) ? CmsXmlUtils.concatXpath(elementPath, element) : element; addDefaultCheckRules(rootContentDefinition, nestedContentDefinition.getSchemaType(element), path);
/** * @see org.opencms.xml.content.I_CmsXmlContentHandler#getComplexWidget(org.opencms.xml.types.I_CmsXmlSchemaType) */ public I_CmsComplexWidget getComplexWidget(I_CmsXmlSchemaType value) { I_CmsComplexWidget result = m_complexWidgets.get(value.getName()); if (result == null) { if (value instanceof CmsXmlNestedContentDefinition) { I_CmsXmlContentHandler contentHandler = ((CmsXmlNestedContentDefinition)value).getNestedContentDefinition().getContentHandler(); if (contentHandler.getDefaultComplexWidget() != null) { return contentHandler.getDefaultComplexWidget().configure( contentHandler.getDefaultComplexWidgetConfiguration()); } } return null; } else { String configuration = getConfiguration(value); result = result.configure(configuration); return result; } }
/** * Initializes the default values for this content handler.<p> * * Using the default values from the appinfo node, it's possible to have more * sophisticated logic for generating the defaults then just using the XML schema "default" * attribute.<p> * * @param root the "defaults" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the default values belong to * @throws CmsXmlException if something goes wrong */ protected void initDefaultValues(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException { Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(root, APPINFO_DEFAULT); while (i.hasNext()) { // iterate all "default" elements in the "defaults" node Element element = i.next(); String elementName = element.attributeValue(APPINFO_ATTR_ELEMENT); String defaultValue = element.attributeValue(APPINFO_ATTR_VALUE); String resolveMacrosValue = element.attributeValue(APPINFO_ATTR_RESOLVE_MACROS); if ((elementName != null) && (defaultValue != null)) { // add a default value mapping for the element addDefault(contentDefinition, elementName, defaultValue, resolveMacrosValue); } } }
/** * Initializes the element mappings for this content handler.<p> * * Element mappings allow storing values from the XML content in other locations. * For example, if you have an element called "Title", it's likely a good idea to * store the value of this element also in the "Title" property of a XML content resource.<p> * * @param root the "mappings" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the mappings belong to * @throws CmsXmlException if something goes wrong */ protected void initMappings(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException { Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(root, APPINFO_MAPPING); while (i.hasNext()) { // iterate all "mapping" elements in the "mappings" node Element element = i.next(); // this is a mapping node String elementName = element.attributeValue(APPINFO_ATTR_ELEMENT); String maptoName = element.attributeValue(APPINFO_ATTR_MAPTO); if ((elementName != null) && (maptoName != null)) { // add the element mapping addMapping(contentDefinition, elementName, maptoName); } } }
if ((elementName != null) && (regex != null)) { addValidationRule( contentDefinition, elementName,
/** * Initializes the search exclusions values for this content handler.<p> * * For the full text search, the value of all elements in one locale of the XML content are combined * to one big text, which is referred to as the "content" in the context of the full text search. * With this option, it is possible to hide certain elements from this "content" that does not make sense * to include in the full text search.<p> * * @param root the "searchsettings" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the default values belong to * * @throws CmsXmlException if something goes wrong */ protected void initSearchSettings(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException { Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(root, APPINFO_SEARCHSETTING); while (i.hasNext()) { // iterate all "searchsetting" elements in the "searchsettings" node Element element = i.next(); String elementName = element.attributeValue(APPINFO_ATTR_ELEMENT); String searchContent = element.attributeValue(APPINFO_ATTR_SEARCHCONTENT); boolean include = CmsStringUtil.isEmpty(searchContent) || Boolean.valueOf(searchContent).booleanValue(); if (elementName != null) { // add search exclusion for the element // this may also be "false" in case a default of "true" is to be overwritten addSearchSetting(contentDefinition, elementName, Boolean.valueOf(include)); } } }
&& !m_relations.containsKey(elementPath)) { addCheckRule(rootContentDefinition, elementPath, null, null); I_CmsXmlSchemaType nestedSchema = nestedContentDefinition.getSchemaType(element); if ((schemaType == null) || !nestedSchema.equals(schemaType)) { addDefaultCheckRules(rootContentDefinition, nestedSchema, path);
/** * @see org.opencms.xml.content.I_CmsXmlContentHandler#getWidget(org.opencms.xml.types.I_CmsXmlContentValue) */ public I_CmsWidget getWidget(I_CmsXmlContentValue value) { // try the specific widget settings first I_CmsWidget result = m_elementWidgets.get(value.getName()); if (result == null) { // use default widget mappings result = OpenCms.getXmlContentTypeManager().getWidgetDefault(value.getTypeName()); } else { result = result.newInstance(); } // set the configuration value for this widget String configuration = getConfiguration(value); if (configuration == null) { // no individual configuration defined, try to get global default configuration configuration = OpenCms.getXmlContentTypeManager().getWidgetDefaultConfiguration(result); } result.setConfiguration(configuration); return result; }
/** * Initializes the default values for this content handler.<p> * * Using the default values from the appinfo node, it's possible to have more * sophisticated logic for generating the defaults then just using the XML schema "default" * attribute.<p> * * @param root the "defaults" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the default values belong to * @throws CmsXmlException if something goes wrong */ protected void initDefaultValues(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException { Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(root, APPINFO_DEFAULT); while (i.hasNext()) { // iterate all "default" elements in the "defaults" node Element element = i.next(); String elementName = element.attributeValue(APPINFO_ATTR_ELEMENT); String defaultValue = element.attributeValue(APPINFO_ATTR_VALUE); if ((elementName != null) && (defaultValue != null)) { // add a default value mapping for the element addDefault(contentDefinition, elementName, defaultValue); } } }
/** * Initializes the element mappings for this content handler.<p> * * Element mappings allow storing values from the XML content in other locations. * For example, if you have an element called "Title", it's likely a good idea to * store the value of this element also in the "Title" property of a XML content resource.<p> * * @param root the "mappings" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the mappings belong to * @throws CmsXmlException if something goes wrong */ protected void initMappings(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException { Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(root, APPINFO_MAPPING); while (i.hasNext()) { // iterate all "mapping" elements in the "mappings" node Element element = i.next(); // this is a mapping node String elementName = element.attributeValue(APPINFO_ATTR_ELEMENT); String maptoName = element.attributeValue(APPINFO_ATTR_MAPTO); String useDefault = element.attributeValue(APPINFO_ATTR_USE_DEFAULT); if ((elementName != null) && (maptoName != null)) { // add the element mapping addMapping(contentDefinition, elementName, maptoName, useDefault); } } }
if ((elementName != null) && (regex != null)) { addValidationRule( contentDefinition, elementName,
/** * @see org.opencms.xml.content.I_CmsXmlContentHandler#getWidget(org.opencms.xml.types.I_CmsXmlSchemaType) */ public I_CmsWidget getWidget(I_CmsXmlSchemaType value) { // try the specific widget settings first I_CmsWidget result = m_elementWidgets.get(value.getName()); if (result == null) { // use default widget mappings result = OpenCms.getXmlContentTypeManager().getWidgetDefault(value.getTypeName()); } else { result = result.newInstance(); } if (result != null) { // set the configuration value for this widget String configuration = getConfiguration(value); if (configuration == null) { // no individual configuration defined, try to get global default configuration configuration = OpenCms.getXmlContentTypeManager().getWidgetDefaultConfiguration(result); } result.setConfiguration(configuration); } return result; }
/** * Creates a new XML content definition.<p> * * @param outerName the outer element name to use for the content definition * @param innerName the inner element name to use for the content definition * @param schemaLocation the location from which the XML schema was read (system id) */ public CmsXmlContentDefinition(String outerName, String innerName, String schemaLocation) { m_outerName = outerName; m_innerName = innerName; setInnerName(innerName); m_typeSequence = new ArrayList<I_CmsXmlSchemaType>(); m_types = new HashMap<String, I_CmsXmlSchemaType>(); m_includes = new HashSet<CmsXmlContentDefinition>(); m_schemaLocation = schemaLocation; m_contentHandler = new CmsDefaultXmlContentHandler(); m_sequenceType = SequenceType.SEQUENCE; m_elementTypes = new ConcurrentHashMap<String, I_CmsXmlSchemaType>(); }