Removes a locale group relation between two resources.<p>

@param firstPage the first resource
@param secondPage the second resource
@throws CmsException if something goes wrong
181485
public void detachLocaleGroup(CmsResource firstPage, CmsResource secondPage) throws CmsException {

        CmsRelationFilter typeFilter = CmsRelationFilter.ALL.filterType(CmsRelationType.LOCALE_VARIANT);
        firstPage = getDefaultFileOrSelf(firstPage);
        secondPage = getDefaultFileOrSelf(secondPage);
        if ((firstPage == null) || (secondPage == null)) {
            return;
        }

        List<CmsRelation> relations = m_cms.readRelations(typeFilter.filterStructureId(secondPage.getStructureId()));
        CmsUUID firstId = firstPage.getStructureId();
        CmsUUID secondId = secondPage.getStructureId();
        for (CmsRelation relation : relations) {
            CmsUUID sourceId = relation.getSourceId();
            CmsUUID targetId = relation.getTargetId();
            CmsResource resourceToModify = null;
            if (sourceId.equals(firstId) && targetId.equals(secondId)) {
                resourceToModify = firstPage;
            } else if (sourceId.equals(secondId) && targetId.equals(firstId)) {
                resourceToModify = secondPage;
            }
            if (resourceToModify != null) {
                CmsLockActionRecord record = CmsLockUtil.ensureLock(m_cms, resourceToModify);
                try {
                    m_cms.deleteRelationsFromResource(resourceToModify, typeFilter);
                } finally {
                    if (record.getChange() == LockChange.locked) {
                        m_cms.unlockResource(resourceToModify);
                    }
                }
                break;
            }
        }
    }
736863
public void init(CmsObject cms, Locale locale, List<CmsResource> content) {

        m_cms = cms;
        m_locale = locale;
        m_content = convertResourceList(m_cms, m_locale, content);
    }
444024
private void loadAllRemainingLocalizations() throws CmsException, UnsupportedEncodingException, IOException {

        if (!m_alreadyLoadedAllLocalizations) {
            // is only necessary for property bundles
            if (m_bundleType.equals(BundleType.PROPERTY)) {
                for (Locale l : m_locales) {
                    if (null == m_localizations.get(l)) {
                        CmsResource resource = m_bundleFiles.get(l);
                        if (resource != null) {
                            CmsFile file = m_cms.readFile(resource);
                            m_bundleFiles.put(l, file);
                            SortedProperties props = new SortedProperties();
                            props.load(
                                new InputStreamReader(
                                    new ByteArrayInputStream(file.getContents()),
                                    CmsFileUtil.getEncoding(m_cms, file)));
                            m_localizations.put(l, props);
                        }
                    }
                }
            }
            if (m_bundleType.equals(BundleType.XML)) {
                for (Locale l : m_locales) {
                    if (null == m_localizations.get(l)) {
                        loadLocalizationFromXmlBundle(l);
                    }
                }
            }
            m_alreadyLoadedAllLocalizations = true;
        }

    }
1226837
@Override
	public void removeByG_P(long groupId, boolean primary) {
		for (CommerceCurrency commerceCurrency : findByG_P(groupId, primary,
				QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commerceCurrency);
		}
	}
879992
private void removeOldValues() throws CmsException {

        Locale locale = getLocale();
        I_CmsXmlContentValue value = m_document.getValue(N_DETAIL_PAGE, locale);
        do {
            value = m_document.getValue(N_DETAIL_PAGE, locale);
            if (value != null) {
                m_document.removeValue(value.getPath(), locale, 0);
            }
        } while (value != null);
    }
916253
private void removeAllLocalesExcept(CmsXmlContainerPage page, Locale localeToKeep) throws CmsXmlException {

        List<Locale> locales = page.getLocales();
        for (Locale locale : locales) {
            if (!locale.equals(localeToKeep)) {
                page.removeLocale(locale);
            }
        }
    }
965380
protected List<CmsResourceStatusRelationBean> getSiblings(CmsObject cms, String locale, CmsResource resource)
    throws CmsException {

        List<CmsResourceStatusRelationBean> result = new ArrayList<CmsResourceStatusRelationBean>();
        for (CmsResource sibling : cms.readSiblings(resource, CmsResourceFilter.ALL)) {
            if (sibling.getStructureId().equals(resource.getStructureId())) {
                continue;
            }
            try {
                CmsPermissionInfo permissionInfo = OpenCms.getADEManager().getPermissionInfo(
                    cms,
                    sibling,
                    resource.getRootPath());
                if (permissionInfo.hasViewPermission()) {
                    CmsResourceStatusRelationBean relationBean = createRelationBean(
                        cms,
                        locale,
                        sibling,
                        permissionInfo);
                    result.add(relationBean);
                }
            } catch (CmsException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
        return result;
    }
1056579
private void deleteResource(CmsResource resource) throws CmsException {

        String path = null;
        CmsObject cms = getCmsObject();
        try {
            path = cms.getSitePath(resource);
            cms.lockResource(path);
            cms.deleteResource(path, CmsResource.DELETE_PRESERVE_SIBLINGS);
            // check if any detail container page resources exist to this resource
            List<CmsResource> detailContainers = CmsDetailOnlyContainerUtil.getDetailOnlyResources(cms, resource);
            for (CmsResource detailContainer : detailContainers) {
                deleteResource(detailContainer);
            }
        } finally {
            try {
                if (path != null) {
                    getCmsObject().unlockResource(path);
                }
            } catch (Exception e) {
                // should really never happen
                LOG.debug(e.getLocalizedMessage(), e);
            }
        }
    }
193996
public void initialize(CmsUUID id, Locale initialComparisonLocale) throws CmsException {

        removeAllComponents();
        CmsObject cms = A_CmsUI.getCmsObject();
        CmsResource res = cms.readResource(id);
        m_currentRoot = res;
        CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(res.getRootPath());

        Locale rootLocale = OpenCms.getLocaleManager().getDefaultLocale(cms, res);
        m_rootLocale = rootLocale;
        Locale mainLocale = site.getMainTranslationLocale(null);
        List<Locale> secondaryLocales = site.getSecondaryTranslationLocales();

        List<Locale> possibleLocaleSelections = getMainLocaleSelectOptions(cms, res, mainLocale, secondaryLocales);
        m_rootLocaleSelector = new ComboBox();
        m_rootLocaleSelector.addStyleName("o-sitemap-localeselect");
        m_rootLocaleSelector.setNullSelectionAllowed(false);
        for (Locale selectableLocale : possibleLocaleSelections) {
            m_rootLocaleSelector.addItem(selectableLocale);
            m_rootLocaleSelector.setItemIcon(selectableLocale, FontOpenCms.SPACE);
            m_rootLocaleSelector.setItemCaption(
                selectableLocale,
                selectableLocale.getDisplayName(A_CmsUI.get().getLocale()));
        }
        m_rootLocaleSelector.setItemIcon(mainLocale, MAIN_LOCALE_ICON);
        m_rootLocaleSelector.setValue(m_rootLocale);
        m_rootLocaleSelector.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @SuppressWarnings("synthetic-access")
            public void valueChange(ValueChangeEvent event) {

                if (!m_handlingLocaleChange) {
                    m_handlingLocaleChange = true;
                    try {
                        Locale newLocale = (Locale)(event.getProperty().getValue());
                        switchToLocale(newLocale);
                    } catch (Exception e) {
                        LOG.error(e.getLocalizedMessage(), e);
                        CmsErrorDialog.showErrorDialog(e);
                    } finally {
                        m_handlingLocaleChange = false;
                    }
                }
            }
        });

        m_comparisonLocaleSelector = new ComboBox();
        m_comparisonLocaleSelector.addStyleName("o-sitemap-localeselect");
        m_comparisonLocaleSelector.setNullSelectionAllowed(false);

        List<Locale> comparisonLocales = getComparisonLocales();
        Locale selectedComparisonLocale = null;
        for (Locale comparisonLocale : comparisonLocales) {
            m_comparisonLocaleSelector.addItem(comparisonLocale);
            m_comparisonLocaleSelector.setItemIcon(comparisonLocale, FontOpenCms.SPACE);
            m_comparisonLocaleSelector.setItemCaption(
                comparisonLocale,
                comparisonLocale.getDisplayName(A_CmsUI.get().getLocale()));
            if ((selectedComparisonLocale == null) && !comparisonLocale.equals(m_rootLocale)) {
                selectedComparisonLocale = comparisonLocale;
            }
            if ((initialComparisonLocale != null)
                && comparisonLocale.equals(initialComparisonLocale)
                && !comparisonLocale.equals(m_rootLocale)) {
                // if an initial comparison locale is given, it should have priority over the first comparison locale
                selectedComparisonLocale = comparisonLocale;
            }

        }
        m_comparisonLocale = selectedComparisonLocale;
        m_comparisonLocaleSelector.setValue(selectedComparisonLocale);
        m_comparisonLocaleSelector.setItemIcon(mainLocale, MAIN_LOCALE_ICON);

        m_comparisonLocaleSelector.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @SuppressWarnings("synthetic-access")
            public void valueChange(ValueChangeEvent event) {

                if (!m_handlingLocaleChange) {
                    m_handlingLocaleChange = true;
                    try {
                        Locale locale = (Locale)(event.getProperty().getValue());
                        if (m_rootLocale.equals(locale)) {
                            Locale oldComparisonLocale = m_comparisonLocale;
                            if (getLocaleGroup().getResourcesByLocale().keySet().contains(oldComparisonLocale)) {
                                m_comparisonLocale = locale;
                                switchToLocale(oldComparisonLocale);
                                updateLocaleWidgets();
                            } else {
                                Notification.show(
                                    CmsVaadinUtils.getMessageText(
                                        Messages.GUI_LOCALECOMPARE_CANNOT_SWITCH_COMPARISON_LOCALE_0));
                                m_comparisonLocaleSelector.setValue(oldComparisonLocale);
                            }
                        } else {
                            m_comparisonLocale = locale;
                            updateLocaleWidgets();
                            initTree(m_currentRoot);
                        }

                    } catch (Exception e) {
                        LOG.error(e.getLocalizedMessage(), e);
                        CmsErrorDialog.showErrorDialog(e);
                    } finally {
                        m_handlingLocaleChange = false;
                    }
                }
            }
        });

        CssLayout localeSelectors = new CssLayout();
        localeSelectors.addStyleName(OpenCmsTheme.SITEMAP_LOCALE_BAR);

        m_rootLocaleSelector.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_MAIN_LOCALE_0));
        m_comparisonLocaleSelector.setCaption(
            CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_COMPARISON_LOCALE_0));

        localeSelectors.setWidth("100%");
        localeSelectors.addComponent(m_rootLocaleSelector);
        localeSelectors.addComponent(m_comparisonLocaleSelector);
        // localeSelectors.setComponentAlignment(wrapper2, Alignment.MIDDLE_RIGHT);

        setSpacing(true);
        addComponent(localeSelectors);
        addComponent(m_treeContainer);
        m_treeContainer.setWidth("100%");
        initTree(res);
    }
866457
public void removeUserFromGroup(String username, String groupname) throws CmsException {

        m_securityManager.removeUserFromGroup(m_context, username, groupname, false);
    }
381179
private void removeInValidElements(CmsXmlPage page, Locale locale) {

        if (page == null) {
            return;
        }

        if (ALL.equals(getParamTemplate())) {
            return;
        }

        // get all elements of this page
        List pageElements = page.getNames(locale);
        if (pageElements != null) {
            Iterator i = pageElements.iterator();
            while (i.hasNext()) {
                String currElement = (String)i.next();
                // remove current element only is invalid and has no content
                if (!isValidElement(currElement) && isEmptyElement(page, currElement, locale)) {
                    page.removeValue(currElement, locale);
                    try {
                        writePageAndReport(page, false);
                        m_report.println(
                            Messages.get().container(Messages.RPT_REMOVE_INVALID_EMPTY_ELEM_1, currElement),
                            I_CmsReport.FORMAT_NOTE);
                    } catch (CmsException e) {
                        // ignore
                    }
                }
            }
        }
    }
248494
void deleteCurrentLocale() {

        // there has to remain at least one content locale
        if (m_contentLocales.size() > 1) {
            String deletedLocale = m_locale;
            m_contentLocales.remove(deletedLocale);
            m_registeredEntities.remove(m_entityId);
            m_changedEntityIds.remove(m_entityId);
            m_deletedEntities.add(m_entityId);
            getValidationHandler().getValidationContext().removeEntityId(m_entityId);
            unregistereEntity(m_entityId);
            enableSave();
            String nextLocale = null;
            if (m_registeredEntities.isEmpty()) {
                nextLocale = m_contentLocales.iterator().next();
            } else {
                nextLocale = CmsContentDefinition.getLocaleFromId(m_registeredEntities.iterator().next());
            }
            switchLocale(nextLocale);
        }
    }
1316631
public void writeContainerPage(CmsObject cms, CmsContainerPageBean cntPage) throws CmsException {

        // keep unused containers
        CmsContainerPageBean savePage = cleanupContainersContainers(cms, cntPage);
        savePage = removeEmptyContainers(cntPage);
        // Replace existing locales with master locale
        for (Locale locale : getLocales()) {
            removeLocale(locale);
        }
        Locale masterLocale = CmsLocaleManager.MASTER_LOCALE;
        addLocale(cms, masterLocale);

        // add the nodes to the raw XML structure
        Element parent = getLocaleNode(masterLocale);
        saveContainerPage(cms, parent, savePage);
        initDocument(m_document, m_encoding, m_contentDefinition);
    }
1128059
public boolean isModelGroupPage() {

        CmsResource page = getPageResource();
        return (page != null) && CmsContainerpageService.isEditingModelGroups(m_cms, page);

    }
152830
public void removeModelPage(CmsResource sitemapConfig, CmsUUID structureId) throws CmsException {

        CmsFile sitemapConfigFile = m_cms.readFile(sitemapConfig);
        CmsXmlContent content = CmsXmlContentFactory.unmarshal(m_cms, sitemapConfigFile);
        CmsConfigurationReader reader = new CmsConfigurationReader(m_cms);
        reader.parseConfiguration(m_adeConfig.getBasePath(), content);
        List<CmsModelPageConfig> modelPageConfigs = reader.getModelPageConfigs();

        int i = 0;
        for (CmsModelPageConfig config : modelPageConfigs) {
            if (config.getResource().getStructureId().equals(structureId)) {
                break;
            }
            i += 1;
        }
        if (i < modelPageConfigs.size()) {
            content.removeValue(CmsConfigurationReader.N_MODEL_PAGE, Locale.ENGLISH, i);
        }
        writeSitemapConfig(content, sitemapConfigFile);
    }
704888
private CmsContainerPageBean getPage(CmsResource pageResource) throws CmsException {

        CmsContainerPageBean result = null;
        if ((pageResource != null) && CmsResourceTypeXmlContainerPage.isContainerPage(pageResource)) {
            CmsXmlContainerPage xmlContainerPage = CmsXmlContainerPageFactory.unmarshal(m_cms, pageResource, m_request);
            result = xmlContainerPage.getContainerPage(m_cms);
            CmsModelGroupHelper modelHelper = new CmsModelGroupHelper(
                m_cms,
                OpenCms.getADEManager().lookupConfiguration(m_cms, pageResource.getRootPath()),
                CmsJspTagEditable.isEditableRequest(m_request) && (m_request instanceof HttpServletRequest)
                ? CmsADESessionCache.getCache((HttpServletRequest)m_request, m_cms)
                : null,
                CmsContainerpageService.isEditingModelGroups(m_cms, pageResource));
            result = modelHelper.readModelGroups(xmlContainerPage.getContainerPage(m_cms));
        }
        return result;
    }
248415
private void lockLocalization(Locale l) throws CmsException {

        if (null == m_lockedBundleFiles.get(l)) {
            LockedFile lf = LockedFile.lockResource(m_cms, m_bundleFiles.get(l));
            m_lockedBundleFiles.put(l, lf);
        }

    }