/** * 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); }
/** * 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); }
/** * @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; }
/** * @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)); } }
/** * Adds an error message to the internal list of errors, * also raised the "has errors" flag.<p> * * @param value the value that contains the error * @param message the error message to add */ public void addError(I_CmsXmlContentValue value, String message) { m_hasErrors = true; Locale locale = value.getLocale(); Map<String, String> localeErrors = getLocalIssueMap(m_errors, locale); localeErrors.put(value.getPath(), message); if (LOG.isDebugEnabled()) { LOG.debug( Messages.get().getBundle().key(Messages.LOG_XMLCONTENT_VALIDATION_ERR_2, value.getPath(), message)); } }
/** * Adds an error message to the internal list of errors, * also raised the "has errors" flag.<p> * * @param value the value that contains the error * @param message the error message to add */ public void addError(I_CmsXmlContentValue value, String message) { m_hasErrors = true; Locale locale = value.getLocale(); Map<String, String> localeErrors = getLocalIssueMap(m_errors, locale); localeErrors.put(value.getPath(), message); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_XMLCONTENT_VALIDATION_ERR_2, value.getPath(), message)); } }
/** * @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); } }
/** * Checks whether a given resource is a folder and throws an exception otherwise.<p> * * @param resource the resource to check * @throws CmsException if something goes wrong */ protected static void checkIsFolder(CmsResource resource) throws CmsException { if (!isFolder(resource)) { throw new CmsIllegalArgumentException( Messages.get().container( org.opencms.file.Messages.ERR_REWRITE_LINKS_ROOT_NOT_FOLDER_1, resource.getRootPath())); } }
/** * @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())); } // get original value (for simple types only) if (value.isSimpleType()) { String original = value.getStringValue(m_cms); // resolve the value String resolved = m_resolver.resolveMacros(original); if (!resolved.equals(original)) { // something has been changed, set new value value.setStringValue(m_cms, resolved); } } } }
/** * @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())); } // get original value (for simple types only) if (value.isSimpleType()) { String original = value.getStringValue(m_cms); // resolve the value String resolved = m_resolver.resolveMacros(original); if (!resolved.equals(original)) { // something has been changed, set new value value.setStringValue(m_cms, resolved); } } } }
/** * @see org.opencms.xml.content.I_CmsXmlContentHandler#resolveMapping(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, org.opencms.xml.types.I_CmsXmlContentValue) */ public void resolveMapping(CmsObject cms, CmsXmlContent content, I_CmsXmlContentValue value) throws CmsException { if (content.getFile() == null) { throw new CmsXmlException(Messages.get().container(Messages.ERR_XMLCONTENT_RESOLVE_FILE_NOT_FOUND_0)); } // get the mappings for the element name boolean valueIsSimple = value.isSimpleType(); String valuePath = value.getPath(); int valueIndex = value.getIndex(); Locale valueLocale = value.getLocale(); CmsObject rootCms1 = createRootCms(cms); String originalStringValue = null; if (valueIsSimple) { originalStringValue = value.getStringValue(rootCms1); } resolveMapping(cms, content, valuePath, valueIsSimple, valueIndex, valueLocale, originalStringValue); }