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

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

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

origin: org.opencms/opencms-core

/**
 * Create a new 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
 */
protected CmsXmlContent(CmsObject cms, Locale locale, String encoding, CmsXmlContentDefinition contentDefinition) {
  // content defition must be set here since it's used during document creation
  m_contentDefinition = contentDefinition;
  // create the XML document according to the content definition
  Document document = m_contentDefinition.createDocument(cms, this, locale);
  // initialize the XML content structure
  initDocument(cms, document, encoding, m_contentDefinition);
}
origin: org.opencms/opencms-core

/**
 * Creates a new XML content based on the provided XML document.<p>
 *
 * The given encoding is used when marshalling the XML again later.<p>
 *
 * @param cms the cms context, if <code>null</code> no link validation is performed
 * @param document the document to create the xml content from
 * @param encoding the encoding of the xml content
 * @param resolver the XML entitiy resolver to use
 */
protected CmsXmlContent(CmsObject cms, Document document, String encoding, EntityResolver resolver) {
  // must set document first to be able to get the content definition
  m_document = document;
  // for the next line to work the document must already be available
  m_contentDefinition = getContentDefinition(resolver);
  // initialize the XML content structure
  initDocument(cms, m_document, encoding, m_contentDefinition);
}
origin: org.opencms/opencms-solr

/**
 * Creates a new XML content based on the provided XML document.<p>
 * 
 * The given encoding is used when marshalling the XML again later.<p>
 * 
 * @param cms the cms context, if <code>null</code> no link validation is performed 
 * @param document the document to create the xml content from
 * @param encoding the encoding of the xml content
 * @param resolver the XML entitiy resolver to use
 */
protected CmsXmlContent(CmsObject cms, Document document, String encoding, EntityResolver resolver) {
  // must set document first to be able to get the content definition
  m_document = document;
  // for the next line to work the document must already be available
  m_contentDefinition = getContentDefinition(resolver);
  // initialize the XML content structure
  initDocument(cms, m_document, encoding, m_contentDefinition);
}
origin: org.opencms/opencms-solr

/**
 * Create a new 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
 */
protected CmsXmlContent(CmsObject cms, Locale locale, String encoding, CmsXmlContentDefinition contentDefinition) {
  // content defition must be set here since it's used during document creation
  m_contentDefinition = contentDefinition;
  // create the XML document according to the content definition
  Document document = m_contentDefinition.createDocument(cms, this, locale);
  // initialize the XML content structure
  initDocument(cms, document, encoding, m_contentDefinition);
}
origin: org.opencms/opencms-core

/**
 * @see java.lang.Object#clone()
 */
@Override
public CmsXmlContent clone() {
  CmsXmlContent clone = new CmsXmlContent();
  clone.m_autoCorrectionEnabled = m_autoCorrectionEnabled;
  clone.m_contentDefinition = m_contentDefinition;
  clone.m_conversion = m_conversion;
  clone.m_document = (Document)(m_document.clone());
  clone.m_encoding = m_encoding;
  clone.m_file = m_file;
  clone.initDocument();
  return clone;
}
origin: org.opencms/opencms-core

/**
 * 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);
  }
}
origin: org.opencms/opencms-solr

/**
 * 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
    getContentDefinition().getContentHandler().invalidateBrokenLinks(cms, this);
  }
}
origin: org.opencms/opencms-solr

/**
 * @see org.opencms.xml.I_CmsXmlDocument#addLocale(org.opencms.file.CmsObject, java.util.Locale)
 */
public void addLocale(CmsObject cms, Locale locale) throws CmsXmlException {
  if (hasLocale(locale)) {
    throw new CmsXmlException(org.opencms.xml.page.Messages.get().container(
      org.opencms.xml.page.Messages.ERR_XML_PAGE_LOCALE_EXISTS_1,
      locale));
  }
  // add element node for Locale
  m_contentDefinition.createLocale(cms, this, m_document.getRootElement(), locale);
  // re-initialize the bookmarks
  initDocument(cms, m_document, m_encoding, m_contentDefinition);
}
origin: org.opencms/opencms-core

/**
 * @see org.opencms.xml.I_CmsXmlDocument#addLocale(org.opencms.file.CmsObject, java.util.Locale)
 */
public void addLocale(CmsObject cms, Locale locale) throws CmsXmlException {
  if (hasLocale(locale)) {
    throw new CmsXmlException(
      org.opencms.xml.page.Messages.get().container(
        org.opencms.xml.page.Messages.ERR_XML_PAGE_LOCALE_EXISTS_1,
        locale));
  }
  // add element node for Locale
  m_contentDefinition.createLocale(cms, this, m_document.getRootElement(), locale);
  // re-initialize the bookmarks
  initDocument(cms, m_document, m_encoding, m_contentDefinition);
}
origin: org.opencms/opencms-solr

/**
 * Removes an existing XML content value of the given element name and locale at the given index position
 * from this XML content document.<p> 
 * 
 * @param name the name of the XML content value element
 * @param locale the locale where to remove the value 
 * @param index the index where to remove the value (relative to all other values of this type)
 */
public void removeValue(String name, Locale locale, int index) {
  // first get the value from the selected locale and index
  I_CmsXmlContentValue value = getValue(name, locale, index);
  // check for the min / max occurs constrains
  List<I_CmsXmlContentValue> values = getValues(name, locale);
  if (values.size() <= value.getMinOccurs()) {
    // must not allow removing an element if min occurs would be violated
    throw new CmsRuntimeException(Messages.get().container(
      Messages.ERR_XMLCONTENT_ELEM_MINOCCURS_2,
      name,
      new Integer(value.getMinOccurs())));
  }
  // detach the value node from the XML document
  value.getElement().detach();
  // re-initialize this XML content 
  initDocument(m_document, m_encoding, m_contentDefinition);
}
origin: org.opencms/opencms-core

document.initDocument();
origin: org.opencms/opencms-solr

document.initDocument();
origin: org.opencms/opencms-core

/**
 * Removes an existing XML content value of the given element name and locale at the given index position
 * from this XML content document.<p>
 *
 * @param name the name of the XML content value element
 * @param locale the locale where to remove the value
 * @param index the index where to remove the value (relative to all other values of this type)
 */
public void removeValue(String name, Locale locale, int index) {
  // first get the value from the selected locale and index
  I_CmsXmlContentValue value = getValue(name, locale, index);
  if (!value.isChoiceOption()) {
    // check for the min / max occurs constrains
    List<I_CmsXmlContentValue> values = getValues(name, locale);
    if (values.size() <= value.getMinOccurs()) {
      // must not allow removing an element if min occurs would be violated
      throw new CmsRuntimeException(
        Messages.get().container(
          Messages.ERR_XMLCONTENT_ELEM_MINOCCURS_2,
          name,
          new Integer(value.getMinOccurs())));
    }
  }
  // detach the value node from the XML document
  value.getElement().detach();
  // re-initialize this XML content
  initDocument(m_document, m_encoding, m_contentDefinition);
}
origin: org.opencms/opencms-core

initDocument(m_document, m_encoding, getContentDefinition());
origin: org.opencms/opencms-solr

initDocument(m_document, m_encoding, getContentDefinition());
origin: org.opencms/opencms-solr

initDocument(m_document, m_encoding, m_contentDefinition);
origin: org.opencms/org.opencms.workplace.tools.modules

/**
 * Adds the given messages to the vfs message bundle.<p>
 *
 * @param messages the messages
 * @param vfsBundleFile the bundle file
 *
 * @throws CmsException if something goes wrong writing the file
 */
private void addMessagesToVfsBundle(Map<String, String> messages, CmsFile vfsBundleFile) throws CmsException {
  lockTemporary(vfsBundleFile);
  CmsObject cms = getCms();
  CmsXmlContent content = CmsXmlContentFactory.unmarshal(cms, vfsBundleFile);
  Locale locale = CmsLocaleManager.getDefaultLocale();
  if (!content.hasLocale(locale)) {
    content.addLocale(cms, locale);
  }
  Element root = content.getLocaleNode(locale);
  for (Entry<String, String> entry : messages.entrySet()) {
    Element message = root.addElement(CmsVfsBundleLoaderXml.N_MESSAGE);
    Element key = message.addElement(CmsVfsBundleLoaderXml.N_KEY);
    key.setText(entry.getKey());
    Element value = message.addElement(CmsVfsBundleLoaderXml.N_VALUE);
    value.setText(entry.getValue());
  }
  content.initDocument();
  vfsBundleFile.setContents(content.marshal());
  cms.writeFile(vfsBundleFile);
}
origin: org.opencms/opencms-core

initDocument(m_document, m_encoding, m_contentDefinition);
origin: org.opencms/opencms-core

initDocument(cms, document, model.getEncoding(), m_contentDefinition);
origin: org.opencms/opencms-solr

initDocument(cms, document, model.getEncoding(), m_contentDefinition);
org.opencms.xml.contentCmsXmlContentinitDocument

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,
  • correctXmlStructure,
  • getEncoding,
  • getLocaleNode,
  • removeLocale,
  • setAutoCorrectionEnabled,
  • toString,
  • visitAllValuesWith

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • requestLocationUpdates (LocationManager)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Path (java.nio.file)
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Best plugins for Eclipse
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