Tabnine Logo
CmsXmlContent.correctXmlStructure
Code IndexAdd Tabnine to your IDE (free)

How to use
correctXmlStructure
method
in
org.opencms.xml.content.CmsXmlContent

Best Java code snippets using org.opencms.xml.content.CmsXmlContent.correctXmlStructure (Showing top 18 results out of 315)

origin: org.opencms/opencms-core

/**
 * Unmarshal the XML content with auto-correction.
 * @param file the file that contains the XML
 * @return the XML read from the file
 * @throws CmsXmlException thrown if the XML can't be read.
 */
private CmsXmlContent unmarshalXmlContent(CmsFile file) throws CmsXmlException {
  CmsXmlContent content = CmsXmlContentFactory.unmarshal(m_cms, file);
  content.setAutoCorrectionEnabled(true);
  content.correctXmlStructure(m_cms);
  return content;
}
origin: org.opencms/opencms-core

/**
 * Corrects the XML structure of the edited content according to the XSD.<p>
 *
 * @throws CmsException if the correction fails
 */
private void correctXmlStructure() throws CmsException {
  m_content.setAutoCorrectionEnabled(true);
  m_content.correctXmlStructure(getCms());
  // write the corrected temporary file
  writeContent();
}
origin: org.opencms/opencms-solr

/**
 * Corrects the XML structure of the edited content according to the XSD.<p>
 * 
 * @throws CmsException if the correction fails
 */
private void correctXmlStructure() throws CmsException {
  m_content.setAutoCorrectionEnabled(true);
  m_content.correctXmlStructure(getCms());
  // write the corrected temporary file
  writeContent();
}
origin: org.opencms/opencms-core

/**
 * Check if automatic content correction is required. Returns <code>true</code> if the content was changed.<p>
 *
 * @param cms the cms context
 * @param content the content to check
 *
 * @return <code>true</code> if the content was changed
 * @throws CmsXmlException if the automatic content correction failed
 */
private boolean checkAutoCorrection(CmsObject cms, CmsXmlContent content) throws CmsXmlException {
  boolean performedAutoCorrection = false;
  try {
    content.validateXmlStructure(new CmsXmlEntityResolver(cms));
  } catch (CmsXmlException eXml) {
    // validation failed
    content.setAutoCorrectionEnabled(true);
    content.correctXmlStructure(cms);
    performedAutoCorrection = true;
  }
  return performedAutoCorrection;
}
origin: org.opencms/org.opencms.workplace.tools.modules

CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCms(), file);
xmlContent.setAutoCorrectionEnabled(true);
file = xmlContent.correctXmlStructure(getCms());
origin: org.opencms/opencms-solr

file = content.correctXmlStructure(cms);
content.setFile(file);
origin: org.opencms/opencms-core

/**
 * Writes the new detail page information to the configuration file.<p>
 *
 * @param infos the new detail page information
 * @param newId the id to use for new pages
 *
 * @throws CmsException if something goes wrong
 */
public void updateAndSave(List<CmsDetailPageInfo> infos, CmsUUID newId) throws CmsException {
  //lock(m_cms, m_resource);
  getDocument();
  removeOldValues();
  writeDetailPageInfos(infos, newId);
  m_document.setAutoCorrectionEnabled(true);
  m_document.correctXmlStructure(m_cms);
  byte[] content = m_document.marshal();
  m_file.setContents(content);
  m_cms.writeFile(m_file);
  //m_cms.unlockResource(m_cms.getSitePath(m_resource));
}
origin: org.opencms/org.opencms.workplace.tools.modules

  /**
   * Reads a file into a string, applies a transformation to the string, and writes the string back to the file.<p>
   *
   * @param resource the resource to transform
   * @param transformation the transformation to apply
   * @throws CmsException if something goes wrong
   * @throws UnsupportedEncodingException in case the encoding is not supported
   */
  private void transformResource(CmsResource resource, Function<String, String> transformation)
  throws CmsException, UnsupportedEncodingException {

    CmsFile file = getCms().readFile(resource);
    if (CmsResourceTypeXmlContent.isXmlContent(file)) {
      CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCms(), file);
      xmlContent.setAutoCorrectionEnabled(true);
      file = xmlContent.correctXmlStructure(getCms());
    }
    String encoding = CmsLocaleManager.getResourceEncoding(getCms(), file);
    String content = new String(file.getContents(), encoding);
    content = transformation.apply(content);
    file.setContents(content.getBytes(encoding));
    lockResource(getCms(), file);
    getCms().writeFile(file);

  }
}
origin: org.opencms/org.opencms.workplace.tools.modules

CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCms(), file);
xmlContent.setAutoCorrectionEnabled(true);
file = xmlContent.correctXmlStructure(getCms());
origin: org.opencms/opencms-core

file = content.correctXmlStructure(cms);
content.setFile(file);
origin: org.opencms/org.opencms.workplace.tools.modules

CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCms(), file);
xmlContent.setAutoCorrectionEnabled(true);
file = xmlContent.correctXmlStructure(getCms());
origin: org.opencms/opencms-core

/**
 * Writes a sitemap configuration back to the VFS.<p>
 *
 * @param content the content to write
 * @param sitemapConfigFile the file to which the sitemap config should be written
 *
 * @throws CmsXmlException if an XML processing error occurs
 * @throws CmsException if something goes wrong
 */
private void writeSitemapConfig(CmsXmlContent content, CmsFile sitemapConfigFile)
throws CmsXmlException, CmsException {
  content.correctXmlStructure(m_cms);
  byte[] contentBytes = content.marshal();
  sitemapConfigFile.setContents(contentBytes);
  try {
    CmsLock lock = m_cms.getLock(sitemapConfigFile);
    if (lock.isUnlocked() || !lock.isOwnedBy(m_cms.getRequestContext().getCurrentUser())) {
      m_cms.lockResourceTemporary(sitemapConfigFile);
    }
    m_cms.writeFile(sitemapConfigFile);
  } finally {
    m_cms.unlockResource(sitemapConfigFile);
  }
}
origin: org.opencms/opencms-solr

file = content.correctXmlStructure(cms);
content.setFile(file);
origin: org.opencms/org.opencms.workplace.tools.modules

/**
 * Replaces the referenced formatters within the new XSD files with the new formatter paths.<p>
 *
 * @param targetModule the target module
 *
 * @throws CmsException if something goes wrong
 * @throws UnsupportedEncodingException if the file content could not be read with the determined encoding
 */
private void replaceFormatterPaths(CmsModule targetModule) throws CmsException, UnsupportedEncodingException {
  CmsResource formatterSourceFolder = getCms().readResource(
    "/system/modules/" + m_cloneInfo.getFormatterSourceModule() + "/");
  CmsResource formatterTargetFolder = getCms().readResource(
    "/system/modules/" + m_cloneInfo.getFormatterTargetModule() + "/");
  for (I_CmsResourceType type : targetModule.getResourceTypes()) {
    String schemaPath = type.getConfiguration().get("schema");
    CmsResource res = getCms().readResource(schemaPath);
    CmsFile file = getCms().readFile(res);
    if (CmsResourceTypeXmlContent.isXmlContent(file)) {
      CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCms(), file);
      xmlContent.setAutoCorrectionEnabled(true);
      file = xmlContent.correctXmlStructure(getCms());
    }
    String encoding = CmsLocaleManager.getResourceEncoding(getCms(), file);
    String content = new String(file.getContents(), encoding);
    content = content.replaceAll(formatterSourceFolder.getRootPath(), formatterTargetFolder.getRootPath());
    file.setContents(content.getBytes(encoding));
    getCms().writeFile(file);
  }
}
origin: org.opencms/opencms-core

content.correctXmlStructure(m_cms);
file.setContents(content.marshal());
m_cms.writeFile(file);
origin: org.opencms/opencms-core

file = content.correctXmlStructure(cms);
content.setFile(file);
origin: org.opencms/opencms-core

xmlContent.correctXmlStructure(getCms());
file.setContents(xmlContent.marshal());
origin: org.opencms/opencms-solr

xmlContent.correctXmlStructure(getCms());
file.setContents(xmlContent.marshal());
org.opencms.xml.contentCmsXmlContentcorrectXmlStructure

Popular methods of CmsXmlContent

  • getValue
  • getStringValue
  • getValues
  • hasLocale
  • getFile
  • getLocales
  • marshal
  • addValue
    Adds a new XML schema type with the default value to the given parent node.
  • getIndexCount
  • hasValue
  • addLocale
  • copyLocale
    Copies the content of the given source locale to the given destination locale in this XML document.
  • addLocale,
  • copyLocale,
  • getEncoding,
  • getLocaleNode,
  • initDocument,
  • removeLocale,
  • setAutoCorrectionEnabled,
  • toString,
  • visitAllValuesWith

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (ScheduledExecutorService)
  • addToBackStack (FragmentTransaction)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Collectors (java.util.stream)
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now