/** * Returns the XML root element node for the given locale.<p> * * @param locale the locale to get the root element for * * @return the XML root element node for the given locale * * @throws CmsRuntimeException if no language element is found in the document */ public Element getLocaleNode(Locale locale) throws CmsRuntimeException { String localeStr = locale.toString(); Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(m_document.getRootElement()); while (i.hasNext()) { Element element = i.next(); if (localeStr.equals(element.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_VALUE_LANGUAGE))) { // language element found, return it return element; } } // language element was not found throw new CmsRuntimeException(Messages.get().container(Messages.ERR_XMLCONTENT_MISSING_LOCALE_1, locale)); }
/** * Returns the XML root element node for the given locale.<p> * * @param locale the locale to get the root element for * * @return the XML root element node for the given locale * * @throws CmsRuntimeException if no language element is found in the document */ protected Element getLocaleNode(Locale locale) throws CmsRuntimeException { String localeStr = locale.toString(); Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(m_document.getRootElement()); while (i.hasNext()) { Element element = i.next(); if (localeStr.equals(element.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_VALUE_LANGUAGE))) { // language element found, return it return element; } } // language element was not found throw new CmsRuntimeException(Messages.get().container(Messages.ERR_XMLCONTENT_MISSING_LOCALE_1, locale)); }
/** * Initializes the preview location for this content handler.<p> * * @param root the "preview" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the validation rules belong to * @throws CmsXmlException if something goes wrong */ protected void initPreview(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException { String preview = root.attributeValue(APPINFO_ATTR_URI); if (preview == null) { throw new CmsXmlException(Messages.get().container( Messages.ERR_XMLCONTENT_MISSING_PREVIEW_URI_2, root.getName(), contentDefinition.getSchemaLocation())); } m_previewLocation = preview; }
/** * Initializes the preview location for this content handler.<p> * * @param root the "preview" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the validation rules belong to * @throws CmsXmlException if something goes wrong */ protected void initPreview(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException { String preview = root.attributeValue(APPINFO_ATTR_URI); if (preview == null) { throw new CmsXmlException( Messages.get().container( Messages.ERR_XMLCONTENT_MISSING_PREVIEW_URI_2, root.getName(), contentDefinition.getSchemaLocation())); } m_previewLocation = preview; }
/** * Initializes the folder containing the model file(s) for this content handler.<p> * * @param root the "modelfolder" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the model folder belongs to * @throws CmsXmlException if something goes wrong */ protected void initModelFolder(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException { String master = root.attributeValue(APPINFO_ATTR_URI); if (master == null) { throw new CmsXmlException( Messages.get().container( Messages.ERR_XMLCONTENT_MISSING_MODELFOLDER_URI_2, root.getName(), contentDefinition.getSchemaLocation())); } m_modelFolder = master; }
/** * Initializes the folder containing the model file(s) for this content handler.<p> * * @param root the "modelfolder" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the model folder belongs to * @throws CmsXmlException if something goes wrong */ protected void initModelFolder(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException { String master = root.attributeValue(APPINFO_ATTR_URI); if (master == null) { throw new CmsXmlException(Messages.get().container( Messages.ERR_XMLCONTENT_MISSING_MODELFOLDER_URI_2, root.getName(), contentDefinition.getSchemaLocation())); } m_modelFolder = master; }
/** * @see org.opencms.xml.content.I_CmsXmlContentValueVisitor#visit(org.opencms.xml.types.I_CmsXmlContentValue) */ public void visit(I_CmsXmlContentValue value) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_XMLCONTENT_VISIT_1, value.getPath())); } try { m_handler.resolveMapping(m_cms, m_content, value); } catch (CmsException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_XMLCONTENT_RESOLVE_MAPPING_1, value.getPath()), e); } } }
/** * @see org.opencms.xml.content.I_CmsXmlContentValueVisitor#visit(org.opencms.xml.types.I_CmsXmlContentValue) */ public void visit(I_CmsXmlContentValue value) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_XMLCONTENT_VISIT_1, value.getPath())); } try { m_handler.resolveMapping(m_cms, m_content, value); } catch (CmsException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_XMLCONTENT_RESOLVE_MAPPING_1, value.getPath()), e); } } }
/** * Initializes the resource bundle to use for localized messages in this content handler.<p> * * @param root the "resourcebundle" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the validation rules belong to * * @throws CmsXmlException if something goes wrong */ protected void initResourceBundle(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException { String name = root.attributeValue(APPINFO_ATTR_NAME); if (name == null) { throw new CmsXmlException(Messages.get().container( Messages.ERR_XMLCONTENT_MISSING_RESOURCE_BUNDLE_NAME_2, root.getName(), contentDefinition.getSchemaLocation())); } m_messageBundleName = name; }
/** * Adds a search setting for an element.<p> * * @param contentDefinition the XML content definition this XML content handler belongs to * @param elementName the element name to map * @param value the search setting value to store * * @throws CmsXmlException in case an unknown element name is used */ protected void addSearchSetting(CmsXmlContentDefinition contentDefinition, String elementName, Boolean value) throws CmsXmlException { if (contentDefinition.getSchemaType(elementName) == null) { throw new CmsXmlException( Messages.get().container(Messages.ERR_XMLCONTENT_INVALID_ELEM_SEARCHSETTINGS_1, elementName)); } // store the search exclusion as defined m_searchSettings.put(elementName, value); }
throw new CmsXmlException(Messages.get().container( Messages.ERR_XMLCONTENT_INVALID_ELEM_VALIDATION_1, elementName));
Messages.get().container(Messages.ERR_XMLCONTENT_INVALID_ELEM_VALIDATION_1, elementName));
/** * Adds the given element to the compact view set.<p> * * @param contentDefinition the XML content definition this XML content handler belongs to * @param elementName the element name * @param displayType the display type to use for the element widget * * @throws CmsXmlException in case an unknown element name is used */ protected void addDisplayType( CmsXmlContentDefinition contentDefinition, String elementName, DisplayType displayType) throws CmsXmlException { if (contentDefinition.getSchemaType(elementName) == null) { throw new CmsXmlException( Messages.get().container(Messages.ERR_XMLCONTENT_CONFIG_ELEM_UNKNOWN_1, elementName)); } m_displayTypes.put(elementName, displayType); }
/** * Adds a configuration value for an element widget.<p> * * @param contentDefinition the XML content definition this XML content handler belongs to * @param elementName the element name to map * @param configurationValue the configuration value to use * * @throws CmsXmlException in case an unknown element name is used */ protected void addConfiguration( CmsXmlContentDefinition contentDefinition, String elementName, String configurationValue) throws CmsXmlException { if (contentDefinition.getSchemaType(elementName) == null) { throw new CmsXmlException(Messages.get().container( Messages.ERR_XMLCONTENT_CONFIG_ELEM_UNKNOWN_1, elementName)); } m_configurationValues.put(elementName, configurationValue); }
/** * Adds a configuration value for an element widget.<p> * * @param contentDefinition the XML content definition this XML content handler belongs to * @param elementName the element name to map * @param configurationValue the configuration value to use * * @throws CmsXmlException in case an unknown element name is used */ protected void addConfiguration( CmsXmlContentDefinition contentDefinition, String elementName, String configurationValue) throws CmsXmlException { if (contentDefinition.getSchemaType(elementName) == null) { throw new CmsXmlException( Messages.get().container(Messages.ERR_XMLCONTENT_CONFIG_ELEM_UNKNOWN_1, elementName)); } m_configurationValues.put(elementName, configurationValue); }
/** * @see org.opencms.xml.content.I_CmsXmlContentHandler#getMessages(java.util.Locale) */ public CmsMessages getMessages(Locale locale) { CmsMessages result = null; if ((m_messageBundleNames == null) || m_messageBundleNames.isEmpty()) { return new CmsMessages(Messages.get().getBundleName(), locale); } else { // a message bundle was initialized CmsMultiMessages multiMessages = new CmsMultiMessages(locale); for (String messageBundleName : m_messageBundleNames) { multiMessages.addMessages(new CmsMessages(messageBundleName, locale)); } if (!m_messageBundleNames.contains(Messages.get().getBundleName())) { multiMessages.addMessages(new CmsMessages(Messages.get().getBundleName(), locale)); } result = multiMessages; } return result; }
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_XMLCONTENT_MISSING_SCHEMA_0)); return CmsXmlContentDefinition.unmarshal(schemaLocation, resolver); } catch (SAXException e) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_XML_SCHEMA_PARSE_0), e); } catch (IOException e) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_XML_SCHEMA_IO_0), e); } catch (CmsXmlException e) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_XMLCONTENT_UNMARSHAL_0), e);
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_XMLCONTENT_MISSING_SCHEMA_0)); return CmsXmlContentDefinition.unmarshal(schemaLocation, resolver); } catch (SAXException e) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_XML_SCHEMA_PARSE_1, schemaLocation), e); } catch (IOException e) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_XML_SCHEMA_IO_1, schemaLocation), e); } catch (CmsXmlException e) { throw new CmsRuntimeException( Messages.get().container(Messages.ERR_XMLCONTENT_UNMARSHAL_1, schemaLocation), e);
/** * @see org.opencms.xml.content.I_CmsXmlContentValueVisitor#visit(org.opencms.xml.types.I_CmsXmlContentValue) */ public void visit(I_CmsXmlContentValue value) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_XMLCONTENT_VISIT_1, value.getPath())); } m_errorHandler = value.getContentDefinition().getContentHandler().resolveValidation( m_cms, value, m_errorHandler); } }
/** * Adds an warning message to the internal list of errors, * also raised the "has warning" flag.<p> * * @param value the value that contians the warning * @param message the warning message to add */ public void addWarning(I_CmsXmlContentValue value, String message) { m_hasWarnings = true; Locale locale = value.getLocale(); Map<String, String> localeWarnings = getLocalIssueMap(m_warnings, locale); localeWarnings.put(value.getPath(), message); if (LOG.isDebugEnabled()) { LOG.debug( Messages.get().getBundle().key(Messages.LOG_XMLCONTENT_VALIDATION_WARN_2, value.getPath(), message)); } }