/** * 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); } } }
/** * 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); } } }
/** * 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()); }
m_content.copyLocale(locales, newLocale); addNew = false; } catch (CmsXmlException e) {
m_content.copyLocale(locales, locale);
m_content.copyLocale(locales, newLocale); addNew = false; } catch (CmsXmlException e) {
content.copyLocale(mainLocale, locale); } else { content.addLocale(cms, locale);
/** * @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); } }
report.addWarning(container); } else { content.copyLocale(sourceLocale, targetLocale); if (m_delete) { content.removeLocale(sourceLocale);