Changes to the given site. Will update session and workplace settings.<p>

@param siteRoot the site to change to
425480
public void changeSite(String siteRoot) {

        if (!getCmsObject().getRequestContext().getSiteRoot().equals(siteRoot)) {
            getCmsObject().getRequestContext().setSiteRoot(siteRoot);
            getWorkplaceSettings().setSite(siteRoot);
            OpenCms.getSessionManager().updateSessionInfo(getCmsObject(), getHttpSession());
        }
    }
1054658
private void checkPermissionsForMassEdit(CmsObject cms, String siteRoot) throws CmsException {

        String originalSiteRoot = cms.getRequestContext().getSiteRoot();
        try {
            cms.getRequestContext().setSiteRoot(siteRoot);
            checkPermissionsForMassEdit(cms);
        } finally {
            cms.getRequestContext().setSiteRoot(originalSiteRoot);
        }
    }
566124
public static boolean useSingleLocaleDetailContainers(String siteRoot) {

        boolean result = false;
        if ((siteRoot != null)
            && (OpenCms.getLocaleManager().getLocaleHandler() instanceof CmsSingleTreeLocaleHandler)) {
            CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot);
            result = (site != null) && CmsSite.LocalizationMode.singleTree.equals(site.getLocalizationMode());
        }
        return result;
    }
604936
protected void onSiteChange(String site) {

        try {
            m_treeData.removeAllItems();
            CmsObject rootCms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
            rootCms.getRequestContext().setSiteRoot("");
            CmsResource siteRootResource = rootCms.readResource(site);

            m_treeData.initRoot(rootCms, siteRootResource);
            m_fileTree.expandItem(siteRootResource.getStructureId());
            m_siteRoot = site;
            updateRoot(rootCms, siteRootResource);
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
98150
public void addNormalSites(boolean includeRoot, String startFolder) {

        CmsSiteManagerImpl siteManager = OpenCms.getSiteManager();
        List<CmsSite> sites = siteManager.getAvailableSites(m_cms, true, false, m_cms.getRequestContext().getOuFqn());
        try {
            CmsObject rootCms = OpenCms.initCmsObject(m_cms);
            rootCms.getRequestContext().setSiteRoot("/");
            if (sites.isEmpty()) {
                String siteRoot = m_cms.getRequestContext().getSiteRoot();
                if (!rootCms.existsResource(siteRoot, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
                    if (startFolder != null) {
                        siteRoot = CmsStringUtil.joinPaths(siteRoot, startFolder);
                    }
                    if ((startFolder == null)
                        || !rootCms.existsResource(siteRoot, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
                        siteRoot = null;
                    }
                }
                if (siteRoot != null) {
                    Type type = Type.site;
                    String message = siteRoot;
                    addOption(type, siteRoot, message);
                }
            }
            for (CmsSite site : sites) {
                // Do not add the shared site - it will be among sites if you are on the shared site at the moment.
                if (site.isSharedSite()) {
                    continue;
                }
                String siteRoot = site.getSiteRoot();
                if (!rootCms.existsResource(siteRoot, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
                    if (startFolder != null) {
                        siteRoot = CmsStringUtil.joinPaths(siteRoot, startFolder);
                    }
                    if ((startFolder == null)
                        || !rootCms.existsResource(siteRoot, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
                        siteRoot = null;
                    }
                }
                if (siteRoot != null) {
                    Type type = Type.site;
                    String message = null;
                    String title = site.getTitle();
                    if (!CmsStringUtil.isEmptyOrWhitespaceOnly(title)) {
                        message = title;
                    } else {
                        message = siteRoot;
                    }
                    if (siteRoot.equals("")) {
                        type = Type.root;
                        Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(m_cms);
                        message = Messages.get().getBundle(locale).key(Messages.GUI_ROOT_SITE_0);
                        if (!includeRoot) {
                            continue;
                        }
                    }
                    addOption(type, siteRoot, message);
                }
            }
        } catch (CmsException e) {
            LOG.error(e);
        }
    }
1091201
protected function applySiteConditions()
    {
        if ($this->site !== null) {
            $this->andWhere(Db::parseParam('siteId', $this->parseSiteValue($this->site)));
        } else {
            $this->andWhere(Db::parseParam('siteId', Craft::$app->getSites()->currentSite->id));
        }
    }
155511
public function setSite($site)
    {
        if ($site === null) {
            $this->siteId = null;
            $this->site = null;

            return;
        }
        $this->siteId = $site->getSiteId();

        $this->site = $site;
    }
280364
CmsObject getCmsObjectWithSite(String siteRoot) {

        if (siteRoot == null) {
            siteRoot = "/";
        }
        try {
            CmsObject res = OpenCms.initCmsObject(m_cms);
            res.getRequestContext().setSiteRoot(siteRoot);
            return res;
        } catch (CmsException e) {
            LOG.error("Unable to initialize CmsObject", e);
            return m_cms;
        }
    }
12558
protected void update(CmsRequestContext context) {

        m_timeUpdated = System.currentTimeMillis();
        m_siteRoot = context.getSiteRoot();
        setProject(context.getCurrentProject().getUuid());
        m_ouFqn = context.getOuFqn();
    }
333734
private void setFieldsForSite(boolean enableAll) {

        try {
            if (!CmsStringUtil.isEmptyOrWhitespaceOnly(m_site.getSiteRoot())) {
                CmsProperty prop = m_clonedCms.readPropertyObject(
                    m_site.getSiteRoot(),
                    CmsPropertyDefinition.PROPERTY_TEMPLATE,
                    false);
                if (!prop.isNullProperty()) {
                    if (!m_templates.contains(prop.getValue())) {
                        m_simpleFieldTemplate.addItem(prop.getValue());
                    }
                    m_simpleFieldTemplate.select(prop.getValue());
                } else {
                    if (!m_templates.isEmpty()) {
                        m_simpleFieldTemplate.setValue(m_templates.get(0).getRootPath());
                    }
                }
                m_simpleFieldTemplate.setEnabled(enableAll);
            }
        } catch (CmsException e) {
            LOG.error("Unable to read template property.", e);
        }

        m_simpleFieldSiteRoot.setVisible(true);
        m_simpleFieldSiteRoot.setValue(m_site.getSiteRoot());
        m_simpleFieldSiteRoot.setCmsObject(m_clonedCms);
        m_simpleFieldSiteRoot.addValidator(new SiteRootValidator());
        m_simpleFieldSiteRoot.setEnabled(enableAll);
        m_simpleFieldSiteRoot.addValueChangeListener(new ValueChangeListener() {

            /**vaadin serial id. */
            private static final long serialVersionUID = 4680456758446195524L;

            public void valueChange(ValueChangeEvent event) {

                setTemplateField();
                checkOnOfflineSiteRoot();
            }

        });
        m_simpleFieldParentFolderName.setVisible(false);
        m_simpleFieldFolderName.setVisible(false);

        displayResourceInfoDirectly(
            Collections.singletonList(
                new CmsResourceInfo(
                    m_site.getTitle(),
                    m_site.getSiteRoot(),
                    m_manager.getFavIcon(m_site.getSiteRoot()))));

        m_tab.removeTab(m_tab.getTab(4));
        m_simpleFieldTitle.removeTextChangeListener(null);
        m_simpleFieldTitle.setEnabled(enableAll);
        m_simpleFieldParentFolderName.setEnabled(false);
        m_simpleFieldParentFolderName.setValue(
            m_site.getSiteRoot().substring(
                0,
                m_site.getSiteRoot().length()
                    - m_site.getSiteRoot().split("/")[m_site.getSiteRoot().split("/").length - 1].length()));

        m_simpleFieldFolderName.removeAllValidators(); //can not be changed
        m_fieldCreateOU.setVisible(false);

        m_alreadyUsedURL.remove(m_site.getSiteMatcher().forDifferentScheme("https")); //Remove current url to avoid validation problem
        m_alreadyUsedURL.remove(m_site.getSiteMatcher().forDifferentScheme("http"));

        setFieldTitle(m_site.getTitle());
        setFieldFolder(getFolderNameFromSiteRoot(m_site.getSiteRoot()));
        m_simpleFieldFolderName.setEnabled(false);
        m_simpleFieldTitle.setEnabled(enableAll);

        setFieldServer(m_site.getUrl());
        m_simpleFieldServer.setEnabled(enableAll);
        if (m_site.hasSecureServer()) {
            m_fieldSecureServer.setValue(m_site.getSecureUrl());
        }
        if (m_site.getErrorPage() != null) {
            m_fieldErrorPage.setValue(m_site.getErrorPage());
        }
        m_fieldWebServer.setValue(new Boolean(m_site.isWebserver()));
        m_fieldWebServer.setEnabled(enableAll);
        m_fieldExclusiveURL.setValue(new Boolean(m_site.isExclusiveUrl()));
        m_fieldExclusiveURL.setEnabled(enableAll);
        m_fieldExclusiveError.setValue(new Boolean(m_site.isExclusiveError()));
        m_fieldExclusiveError.setEnabled(enableAll);

        Map<String, String> siteParameters = m_site.getParameters();
        for (Entry<String, String> parameter : siteParameters.entrySet()) {
            addParameter(getParameterString(parameter));
        }

        List<CmsSiteMatcher> siteAliases = m_site.getAliases();

        for (CmsSiteMatcher siteMatcher : siteAliases) {
            if (enableAll) {
                m_aliasGroup.addRow(createAliasComponent(siteMatcher.getUrl(), siteMatcher.isRedirect()));
            } else {
                Component c = createAliasComponent(siteMatcher.getUrl(), siteMatcher.isRedirect());
                c.setEnabled(false);
                m_aliases.addComponent(c);
            }
        }

        setTemplateField();

        setUpComboBoxPosition();

        if (!m_fieldSecureServer.isEmpty()) {
            m_fieldExclusiveURL.setEnabled(true && enableAll);
            m_fieldExclusiveError.setEnabled(true && enableAll);
        }
        setFaviconIfExist();
        checkOnOfflineSiteRoot();
        m_fieldUploadFavIcon.setVisible(false);
        m_simpleFieldEncryption.setContainerDataSource(getSSLModeContainer("caption", true, m_site.getSSLMode()));
        m_simpleFieldEncryption.select(m_site.getSSLMode());
        m_simpleFieldEncryption.setEnabled(enableAll);

        m_fieldErrorPage.setEnabled(enableAll);
        m_addParameter.setVisible(enableAll);
        m_fieldPosition.setEnabled(enableAll);
    }
389686
void submit() {

        String siteRoot = (String)m_siteComboBox.getValue();
        if (!m_context.getCms().getRequestContext().getSiteRoot().equals(siteRoot)) {
            A_CmsUI.get().changeSite(siteRoot);
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(siteRoot) || OpenCms.getSiteManager().isSharedFolder(siteRoot)) {
                // switch to explorer view when selecting shared or root site

                Page.getCurrent().open(CmsCoreService.getFileExplorerLink(A_CmsUI.getCmsObject(), siteRoot), "_top");
                return;
            }
        } else {
            siteRoot = null;
        }
        m_context.finish(null, siteRoot);
    }
619557
public void updateSite(String siteRoot) {

        try {
            CmsObject cloneCms = OpenCms.initCmsObject(m_cms);
            if (siteRoot == null) {
                siteRoot = "/system";
            }
            cloneCms.getRequestContext().setSiteRoot(siteRoot);
            m_cms = cloneCms;
        } catch (CmsException e1) {
            LOG.error(e1.getLocalizedMessage(), e1);
        }
        updateValidation();
    }
1344708
public void setSiteRoot(String siteRoot) {

        // site roots must never end with a "/"
        if (siteRoot.endsWith("/")) {
            m_siteRoot = siteRoot.substring(0, siteRoot.length() - 1);
        } else {
            m_siteRoot = siteRoot;
        }
    }
642952
private function applyTitles(Siteroot $siteroot, array $data)
    {
        if (!array_key_exists('titles', $data)) {
            // noting to save
            return $this;
        }

        $siteroot->setTitles($data['titles']);

        return $this;
    }
685721
private void updateDefaultActions(String targetRootPath) {

        if (m_actionCombo != null) {
            m_defaultActions.clear();
            String resPath = m_context.getResources().get(0).getRootPath();
            String parentFolder = CmsResource.getParentFolder(resPath);
            if ((DialogMode.copy_and_move == m_dialogMode) && !parentFolder.equals(targetRootPath)) {
                m_defaultActions.clear();
                m_defaultActions.add(Action.move);
            } else if (m_context.getResources().size() == 1) {
                if (m_context.getResources().get(0).isFile()) {
                    m_defaultActions.add(Action.copy_all);
                } else {
                    m_defaultActions.add(Action.copy_sibling_mixed);
                    if (m_hasContainerPageDefaultFile) {
                        m_defaultActions.clear();
                        m_defaultActions.add(Action.container_page_automatic);
                        m_defaultActions.add(Action.container_page_copy);
                        m_defaultActions.add(Action.container_page_reuse);
                    }
                    CmsResource folder = m_context.getResources().get(0);
                    if (CmsResourceTypeFolderSubSitemap.isSubSitemap(folder)) {
                        m_defaultActions.clear();
                        m_defaultActions.add(Action.sub_sitemap);
                    }
                }
            } else {
                m_defaultActions.add(Action.copy_sibling_mixed);
            }
            if (!m_defaultActions.isEmpty()) {
                m_actionCombo.setValue(m_defaultActions.get(0));
            }
            m_actionCombo.markAsDirty();
        }
    }
176722
public void saveRewriteAliases(CmsObject cms, String siteRoot, List<CmsRewriteAlias> newAliases)
    throws CmsException {

        checkPermissionsForMassEdit(cms, siteRoot);
        m_securityManager.saveRewriteAliases(cms.getRequestContext(), siteRoot, newAliases);
    }
1074616
public void loadVfsEntryBean(
        final String siteRoot,
        final String filter,

        final AsyncCallback<CmsVfsEntryBean> asyncCallback) {

        CmsRpcAction<CmsVfsEntryBean> action = new CmsRpcAction<CmsVfsEntryBean>() {

            @Override
            public void execute() {

                start(200, false);
                getGalleryService().loadVfsEntryBean(siteRoot, filter, this);
            }

            @Override
            public void onResponse(CmsVfsEntryBean result) {

                stop(false);
                asyncCallback.onSuccess(result);
            }

        };
        action.execute();
    }