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

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

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

origin: org.opencms/opencms-solr

  /**
   * Copies the contents from a source locale to a number of destination locales by overwriting them.<p>
   *  
   * @param content the xml content
   * @param sourceLocale the source locale
   * @param destLocales a list of destination locales
   * @throws CmsException if something goes wrong
   */
  protected void transferContents(CmsXmlContent content, Locale sourceLocale, List destLocales) throws CmsException {

    for (Iterator i = destLocales.iterator(); i.hasNext();) {
      Locale to = (Locale)i.next();
      if (content.hasLocale(to)) {
        content.removeLocale(to);
      }
      content.copyLocale(sourceLocale, to);
    }
  }
}
origin: org.opencms/opencms-core

  /**
   * Copies the contents from a source locale to a number of destination locales by overwriting them.<p>
   *
   * @param content the xml content
   * @param sourceLocale the source locale
   * @param destLocales a list of destination locales
   * @throws CmsException if something goes wrong
   */
  protected void transferContents(CmsXmlContent content, Locale sourceLocale, List<Locale> destLocales)
  throws CmsException {

    for (Iterator<Locale> i = destLocales.iterator(); i.hasNext();) {
      Locale to = i.next();
      if (content.hasLocale(to)) {
        content.removeLocale(to);
      }
      content.copyLocale(sourceLocale, to);
    }
  }
}
origin: org.opencms/opencms-core

if (!content.hasLocale(locale)) {
    List<Locale> locales = getDefaultLocales(cms, resource);
    for (Locale defaultLocale : locales) {
      if (content.hasLocale(defaultLocale)) {
        locale = defaultLocale;
        foundLocale = true;
      locales = getAvailableLocales(cms, resource);
      for (Locale availableLocale : locales) {
        if (content.hasLocale(availableLocale)) {
          locale = availableLocale;
          foundLocale = true;
origin: org.opencms/opencms-core

/**
 * Gets the locale to use for parsing the dynamic function.<p>
 *
 * @param cms the current CMS context
 * @param xmlContent the xml content from which the dynamic function should be read
 *
 * @return the locale from which the dynamic function should be read
 */
protected Locale getLocaleToUse(CmsObject cms, CmsXmlContent xmlContent) {
  Locale contextLocale = cms.getRequestContext().getLocale();
  if (xmlContent.hasLocale(contextLocale)) {
    return contextLocale;
  }
  Locale defaultLocale = CmsLocaleManager.getDefaultLocale();
  if (xmlContent.hasLocale(defaultLocale)) {
    return defaultLocale;
  }
  if (!xmlContent.getLocales().isEmpty()) {
    return xmlContent.getLocales().get(0);
  } else {
    return defaultLocale;
  }
}
origin: org.opencms/opencms-core

throws CmsXmlException {
  if (!content.hasLocale(locale)) {
    content.addLocale(m_cms, locale);
origin: org.opencms/opencms-core

/**
 * Initialize the key set for an xml bundle.
 */
private void initKeySetForXmlBundle() {
  // consider only available locales
  for (Locale l : m_locales) {
    if (m_xmlBundle.hasLocale(l)) {
      Set<Object> keys = new HashSet<Object>();
      for (I_CmsXmlContentValue msg : m_xmlBundle.getValueSequence("Message", l).getValues()) {
        String msgpath = msg.getPath();
        keys.add(m_xmlBundle.getStringValue(m_cms, msgpath + "/Key", l));
      }
      m_keyset.updateKeySet(null, keys);
    }
  }
}
origin: org.opencms/opencms-solr

/**
 * Initializes the element language for the first call of the editor.<p>
 */
protected void initElementLanguage() {
  // get the default locale for the resource
  List locales = OpenCms.getLocaleManager().getDefaultLocales(getCms(), getParamResource());
  Locale locale = (Locale)locales.get(0);
  if (m_content != null) {
    // to copy anything we need at least one locale
    if ((locales.size() > 1) && (m_content.getLocales().size() > 0) && !m_content.hasLocale(locale)) {
      // required locale not available, check if an existing default locale should be copied as "template"
      try {
        // a list of possible default locales has been set as property, try to find a match                    
        m_content.copyLocale(locales, locale);
        writeContent();
      } catch (CmsException e) {
        // no match was found for the required locale
      }
    }
    if (!m_content.hasLocale(locale)) {
      // value may have changed because of the copy operation
      locale = m_content.getLocales().get(0);
    }
  }
  setParamElementlanguage(locale.toString());
}
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-core

SortedProperties props = m_localizations.get(l);
if (null != props) {
  if (m_xmlBundle.hasLocale(l)) {
    m_xmlBundle.removeLocale(l);
origin: org.opencms/opencms-core

if (!hasLocale(source)) {
  throw new CmsXmlException(
    Messages.get().container(org.opencms.xml.Messages.ERR_LOCALE_NOT_AVAILABLE_1, source));
if (hasLocale(destination)) {
  throw new CmsXmlException(
    Messages.get().container(org.opencms.xml.Messages.ERR_LOCALE_ALREADY_EXISTS_1, destination));
origin: org.opencms/opencms-core

/**
 * Removes an existing inheritance container entry with a given name from the configuration file.<p>
 *
 * This does nothing if no such entry actually exists.<p>
 *
 * @param cms the current CMS context
 * @param content the XML content
 * @param locale the locale from which to remove the entry
 * @param name the name of the entry
 *
 */
protected void removeExistingEntry(CmsObject cms, CmsXmlContent content, Locale locale, String name) {
  if (!content.hasLocale(locale)) {
    return;
  }
  String entriesXpath = N_CONFIGURATION;
  List<I_CmsXmlContentValue> values = content.getValues(entriesXpath, locale);
  int valueIndex = 0;
  for (I_CmsXmlContentValue value : values) {
    String valueXpath = value.getPath();
    I_CmsXmlContentValue nameValue = content.getValue(CmsXmlUtils.concatXpath(valueXpath, N_NAME), locale);
    String currentName = nameValue.getStringValue(cms);
    if (currentName.equals(name)) {
      content.removeValue(valueXpath, locale, valueIndex);
      break;
    }
    valueIndex += 1;
  }
}
origin: org.opencms/opencms-core

if (!m_content.hasLocale(locale)) {
  try {
if (!m_content.hasLocale(locale)) {
origin: org.opencms/opencms-core

/**
 * Returns the content values.<p>
 *
 * @return the content values
 *
 * @throws CmsException if reading the content fails
 */
public Map<String, String> getValues() throws CmsException {
  CmsFile file = m_cms.readFile(m_editResource);
  CmsXmlContent content = unmarshalXmlContent(file);
  Locale locale = m_cms.getRequestContext().getLocale();
  if (!content.hasLocale(locale)) {
    content.addLocale(m_cms, locale);
  }
  return getContentValues(content, locale);
}
origin: org.opencms/opencms-core

if (!content.hasLocale(locale)) {
  content.addLocale(cms, locale);
origin: org.opencms/opencms-core

String entityId = entity.getId();
Locale contentLocale = CmsLocaleManager.getLocale(CmsContentDefinition.getLocaleFromId(entityId));
if (content.hasLocale(contentLocale)) {
  content.removeLocale(contentLocale);
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

/**
 * @see org.opencms.ade.contenteditor.shared.rpc.I_CmsContentService#copyLocale(java.util.Collection, org.opencms.acacia.shared.CmsEntity)
 */
public void copyLocale(Collection<String> locales, CmsEntity sourceLocale) throws CmsRpcException {
  try {
    CmsUUID structureId = CmsContentDefinition.entityIdToUuid(sourceLocale.getId());
    CmsResource resource = getCmsObject().readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
    CmsFile file = getCmsObject().readFile(resource);
    CmsXmlContent content = getSessionCache().getCacheXmlContent(structureId);
    synchronizeLocaleIndependentForEntity(file, content, Collections.<String> emptyList(), sourceLocale);
    Locale sourceContentLocale = CmsLocaleManager.getLocale(
      CmsContentDefinition.getLocaleFromId(sourceLocale.getId()));
    for (String loc : locales) {
      Locale targetLocale = CmsLocaleManager.getLocale(loc);
      if (content.hasLocale(targetLocale)) {
        content.removeLocale(targetLocale);
      }
      content.copyLocale(sourceContentLocale, targetLocale);
    }
  } catch (Throwable t) {
    error(t);
  }
}
origin: org.opencms/opencms-core

if (!hasLocale(locale)) {
origin: org.opencms/opencms-solr

if (!hasLocale(locale)) {
org.opencms.xml.contentCmsXmlContenthasLocale

Popular methods of CmsXmlContent

  • getValue
  • getStringValue
  • getValues
  • 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.
  • correctXmlStructure
  • copyLocale,
  • correctXmlStructure,
  • getEncoding,
  • getLocaleNode,
  • initDocument,
  • removeLocale,
  • setAutoCorrectionEnabled,
  • toString,
  • visitAllValuesWith

Popular in Java

  • Updating database using SQL prepared statement
  • getSharedPreferences (Context)
  • onCreateOptionsMenu (Activity)
  • runOnUiThread (Activity)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Permission (java.security)
    Legacy security code; do not use.
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • 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