/** * Creates a new error handler node visitor.<p> * * @param cms the initialized OpenCms user context (required for VFS access) * @param content the XML content to resolve the mappings for */ public CmsXmlContentMappingVisitor(CmsObject cms, CmsXmlContent content) { // store references m_cms = cms; m_content = content; m_handler = content.getHandler(); }
/** * Initializes an XML document based on the provided document, encoding and content definition.<p> * * Checks the links and removes invalid ones in the initialized document.<p> * * @param cms the current users OpenCms content * @param document the base XML document to use for initializing * @param encoding the encoding to use when marshalling the document later * @param definition the content definition to use */ protected void initDocument(CmsObject cms, Document document, String encoding, CmsXmlContentDefinition definition) { initDocument(document, encoding, definition); // check invalid links if (cms != null) { // this will remove all invalid links getHandler().invalidateBrokenLinks(cms, this); } }
/** * Factory method to unmarshal (generate) a XML content instance from a XML document.<p> * * The given encoding is used when marshalling the XML again later.<p> * * <b>Warning:</b><br/> * This method does not support requested historic versions, it always loads the * most recent version. Use <code>{@link #unmarshal(CmsObject, CmsResource, ServletRequest)}</code> * for history support.<p> * * @param cms the cms context, if <code>null</code> no link validation is performed * @param document the XML document to generate the XML content from * @param encoding the encoding to use when marshalling the XML content later * @param resolver the XML entitiy resolver to use * * @return a XML content instance unmarshalled from the String */ public static CmsXmlContent unmarshal(CmsObject cms, Document document, String encoding, EntityResolver resolver) { CmsXmlContent content = new CmsXmlContent(cms, document, encoding, resolver); // call prepare for use content handler and return the result return content.getHandler().prepareForUse(cms, content); }
/** * Create a new instance of an XML content based on the given content definiton, * that will have one language node for the given locale all initialized with default values.<p> * * The given encoding is used when marshalling the XML again later.<p> * * @param cms the current users OpenCms content * @param locale the locale to generate the default content for * @param encoding the encoding to use when marshalling the XML content later * @param contentDefinition the content definiton to create the content for * * @return the created XML content */ public static CmsXmlContent createDocument( CmsObject cms, Locale locale, String encoding, CmsXmlContentDefinition contentDefinition) { // create the XML content CmsXmlContent content = new CmsXmlContent(cms, locale, encoding, contentDefinition); // call prepare for use content handler and return the result return content.getHandler().prepareForUse(cms, content); }
if (m_content.getHandler().getTabs().size() > 0) {
/** * Generates the HTML form for the XML content editor.<p> * * @return the HTML that generates the form for the XML editor */ public String getXmlEditorForm() { // set "editor mode" attribute (required for link replacement in the root site) getCms().getRequestContext().setAttribute(CmsRequestContext.ATTRIBUTE_EDITOR, Boolean.TRUE); // add customized message bundle eventually specified in XSD of XML content addMessages(m_content.getHandler().getMessages(getLocale())); ((CmsMultiMessages)getMessages()).setFallbackHandler(m_content.getHandler().getMessageKeyHandler()); // initialize tab lists for error handling before generating the editor form m_errorTabs = new ArrayList<CmsXmlContentTab>(); m_warningTabs = new ArrayList<CmsXmlContentTab>(); return getXmlEditorForm(m_content.getContentDefinition(), "", true, false).toString(); }
/** * @see org.opencms.file.types.I_CmsResourceType#writeFile(org.opencms.file.CmsObject, CmsSecurityManager, CmsFile) */ @Override public CmsFile writeFile(CmsObject cms, CmsSecurityManager securityManager, CmsFile resource) throws CmsException { // check if the user has write access and if resource is locked // done here so that all the XML operations are not performed if permissions not granted securityManager.checkPermissions( cms.getRequestContext(), resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); // read the XML content, use the encoding set in the property CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(cms, resource, true); // call the content handler for post-processing resource = xmlContent.getHandler().prepareForWrite(cms, xmlContent, resource); // now write the file return super.writeFile(cms, securityManager, resource); }
String previewUri = m_content.getHandler().getPreview(getCms(), m_content, getParamTempfile());
/** * Returns true if the preview is available for the edited xml content.<p> * * This method has to use the resource request parameter and read the file from vfs because the temporary file is * not available in the upper button frame.<p> * * @return true if the preview is enabled, otherwise false */ public boolean isPreviewEnabled() { try { // read the original file because temporary file is not created when opening button frame CmsFile file = getCms().readFile(getParamResource(), CmsResourceFilter.ALL); CmsXmlContent content = CmsXmlContentFactory.unmarshal(getCloneCms(), file); return content.getHandler().getPreview(getCms(), m_content, getParamResource()) != null; } catch (Exception e) { // error reading or unmarshalling, no preview available return false; } }
CmsFile file = m_cms.readFile(res); CmsXmlContent content = CmsXmlContentFactory.unmarshal(m_cms, file); result = content.getHandler().getTitleMapping(m_cms, content, m_cms.getRequestContext().getLocale()); if (result == null) {
result = content.getHandler().getTitleMapping(cms, content, cms.getRequestContext().getLocale()); if (result == null) {
return content.getHandler().prepareForUse(cms, content);
newContent = CmsXmlContentFactory.unmarshal(cms, file); newContent.setAutoCorrectionEnabled(true); resource = newContent.getHandler().prepareForWrite(cms, newContent, file);
CmsContentTypeVisitor visitor = null; CmsEntity originalEntity = null; if (content.getHandler().hasVisibilityHandlers()) { visitor = new CmsContentTypeVisitor(cms, file, contentLocale); visitor.visitTypes(content.getContentDefinition(), getWorkplaceLocale(cms));