Shows the header for the currently selected sitemap root.<p>

@throws CmsException if something goes wrong
160979
private void showHeader() throws CmsException {

        CmsSitemapUI ui = (CmsSitemapUI)A_CmsUI.get();
        String title = null;
        String description = null;
        String path = null;
        String locale = m_rootLocale.toString();
        CmsObject cms = A_CmsUI.getCmsObject();
        CmsResource targetRes = getRoot();
        if (targetRes.isFolder()) {
            targetRes = cms.readDefaultFile(targetRes, CmsResourceFilter.IGNORE_EXPIRATION);
            if (targetRes == null) {
                targetRes = getRoot();
            }
        }
        CmsResourceUtil resUtil = new CmsResourceUtil(cms, getRoot());
        title = resUtil.getTitle();
        description = resUtil.getGalleryDescription(A_CmsUI.get().getLocale());
        path = OpenCms.getLinkManager().getServerLink(
            cms,
            cms.getRequestContext().removeSiteRoot(targetRes.getRootPath()));
        String iconClasses = CmsIconUtil.getIconClasses(
            CmsIconUtil.getDisplayType(cms, getRoot()),
            getRoot().getName(),
            false);
        ui.getSitemapExtension().showInfoHeader(title, description, path, locale, iconClasses);
    }
169971
private void initXmlBundle() throws CmsException {

        CmsFile file = m_cms.readFile(m_resource);
        m_bundleFiles.put(null, m_resource);
        m_xmlBundle = CmsXmlContentFactory.unmarshal(m_cms, file);
        initKeySetForXmlBundle();

    }
204266
private void initFolderTree(boolean showInvisible) throws CmsException {

        CmsObject cms = A_CmsUI.getCmsObject();
        m_treeContainer.removeAllItems();
        try {
            CmsResource siteRoot = cms.readResource("/", FOLDERS);
            addTreeItem(cms, siteRoot, null, false, m_treeContainer);
        } catch (CmsException e) {
            if (showInvisible) {
                CmsResource siteRoot = cms.readResource("/", CmsResourceFilter.IGNORE_EXPIRATION);
                addTreeItem(cms, siteRoot, null, true, m_treeContainer);
            } else {
                throw e;
            }
        }

    }
934058
public String renderSitemap() throws CmsException {

        StringBuffer buffer = new StringBuffer();
        List<CmsXmlSitemapUrlBean> urlBeans = generateSitemapBeans();
        buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        buffer.append(getUrlSetOpenTag() + "\n");
        for (CmsXmlSitemapUrlBean bean : urlBeans) {
            buffer.append(getXmlForEntry(bean));
            buffer.append("\n");
        }
        buffer.append("</urlset>");
        return buffer.toString();
    }
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;
        }
    }
189437
private void loadChildren() throws CmsException {

        for (CmsResource resource : new ArrayList<CmsResource>(m_knownResources)) {
            if (resource.isFolder()) {
                if (!m_mustLoadChildren.contains(resource)) {
                    continue;
                }
                List<CmsResource> children = getChildren(resource);
                for (CmsResource child : children) {
                    m_knownResources.add(child);
                    m_childMap.put(resource, child);
                }
            }
        }
    }
1118751
public Map<String, CmsClientTemplateBean> getTemplates() throws CmsException {

        Map<String, CmsClientTemplateBean> result = new HashMap<String, CmsClientTemplateBean>();
        CmsObject cms = getCmsObject();

        // find current site templates
        int templateId = OpenCms.getResourceManager().getResourceType(
            CmsResourceTypeJsp.getContainerPageTemplateTypeName()).getTypeId();
        List<CmsResource> templates = cms.readResources(
            "/",
            CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(templateId),
            true);
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(cms.getRequestContext().getSiteRoot())) {
            // if not in the root site, also add template under /system/
            templates.addAll(
                cms.readResources(
                    CmsWorkplace.VFS_PATH_SYSTEM,
                    CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(templateId),
                    true));
        }
        // convert resources to template beans
        for (CmsResource template : templates) {
            CmsClientTemplateBean templateBean = getTemplateBean(cms, template);
            result.put(templateBean.getSitePath(), templateBean);
        }
        return result;
    }
651235
public void onClickOk(CmsResource selected) {

        try {
            CmsResource target = selected;
            CmsResource source = m_context.getResources().get(0);
            CmsLocaleGroupService service = A_CmsUI.getCmsObject().getLocaleGroupService();
            service.attachLocaleGroupIndirect(source, target);
            m_context.finish(Arrays.asList(source.getStructureId()));
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
            m_context.error(e);
        }
    }
1265244
protected void initTree(CmsResource rootRes) throws CmsException {

        m_currentRoot = rootRes;
        m_treeContainer.removeAllComponents();
        showHeader();
        CmsSitemapTreeController controller = new CmsSitemapTreeController(
            A_CmsUI.getCmsObject(),
            rootRes,
            this,
            m_treeContainer);

        // no need to escape a structure id
        JavaScript.eval(CmsGwtConstants.VAR_LOCALE_ROOT + "='" + rootRes.getStructureId() + "'");

        CmsSitemapUI ui = (CmsSitemapUI)(A_CmsUI.get());
        ui.getSitemapExtension().setSitemapTreeController(controller);
        CmsSitemapTreeNode root1 = controller.createRootNode();
        controller.initEventHandlers(root1);
        m_treeContainer.addComponent(root1);
        controller.onClickOpen(root1);
    }
223618
public String displayDialog() throws IOException, CmsException {

        if ((OpenCms.getSiteManager().getSites().size() > 1)
            && !OpenCms.getSiteManager().isWorkplaceRequest(getRequest())) {

            // this is a multi site-configuration, but not a request to the configured Workplace site
            // do not send any redirects to the workplace site for security reasons
            getResponse().sendError(HttpServletResponse.SC_NOT_FOUND);
            return null;
        }

        CmsObject cms = getCmsObject();
        if (shouldUseNewLogin() && (cms.getRequestContext().getCurrentUser().isGuestUser())) {
            if (getRequest().getParameter(PARAM_ACTION_LOGOUT) != null) {
                getResponse().sendRedirect(OpenCms.getLinkManager().substituteLink(cms, "/system/login"));
                return "";
            } else {
                return CmsLoginUI.displayVaadinLoginDialog(getRequest(), getResponse());
            }
        }

        m_message = null;
        if (cms.getRequestContext().getCurrentUser().isGuestUser()) {
            // user is not currently logged in
            m_action = ACTION_DISPLAY;
            m_username = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_USERNAME);
            if (m_username != null) {
                // remove white spaces, can only lead to confusion on user name
                m_username = m_username.trim();
            }
            m_password = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_PASSWORD);
            m_actionLogin = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_ACTION_LOGIN);
            m_oufqn = getRequest().getParameter(PARAM_OUFQN);
            if (m_oufqn == null) {
                m_oufqn = getPreDefOuFqn();
            }
            if (OpenCms.getLoginManager().isEnableSecurity()) {
                // security option is enabled, try to get PC type from request parameter
                m_pcType = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_PCTYPE);
            } else {
                // if security option is disabled, just set PC type to "private" to get common login dialog
                m_pcType = PCTYPE_PRIVATE;
            }

            // try to get some info from a cookie
            getCookieData();

            // set PC type to "public" as default if not already set by cookie, request or if security option is disabled
            if (m_pcType == null) {
                m_pcType = PCTYPE_PUBLIC;
            }
        } else {
            // user is already logged in
            m_oufqn = cms.getRequestContext().getOuFqn();
            m_action = ACTION_LOGIN;
            m_actionLogout = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_ACTION_LOGOUT);
        }

        if (m_oufqn == null) {
            m_oufqn = CmsOrganizationalUnit.SEPARATOR;
        }

        String actionGetOus = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_ACTION_GETOULIST);
        if (Boolean.TRUE.toString().equals(actionGetOus)) {
            return getJsonOrgUnitList();
        }

        // initialize the right ou
        m_ou = null;
        try {
            m_ou = OpenCms.getOrgUnitManager().readOrganizationalUnit(getCmsObject(), m_oufqn);
        } catch (CmsException e) {
            m_oufqn = CmsOrganizationalUnit.SEPARATOR;
            try {
                m_ou = OpenCms.getOrgUnitManager().readOrganizationalUnit(getCmsObject(), m_oufqn);
            } catch (CmsException exc) {
                LOG.error(exc.getLocalizedMessage(), exc);
            }
        }

        // initialize the requested resource
        m_requestedResource = CmsRequestUtil.getNotEmptyParameter(
            getRequest(),
            CmsWorkplaceManager.PARAM_LOGIN_REQUESTED_RESOURCE);
        if (m_requestedResource == null) {
            // no resource was requested, use default workplace URI
            m_requestedResource = CmsVaadinUtils.getWorkplaceLink();
        }

        if (Boolean.valueOf(m_actionLogin).booleanValue()) {
            CmsMessageContainer emptyValidation = validateUserAndPasswordNotEmpty(m_username, m_password);
            if (emptyValidation != null) {
                m_message = emptyValidation;
            } else {

                // try to login with the given user information
                login((m_oufqn == null ? CmsOrganizationalUnit.SEPARATOR : m_oufqn) + m_username, m_password);

                if (getLoginException() == null) {
                    // the login was successful
                    m_action = ACTION_LOGIN;

                    CmsWorkplaceSettings settings = initSiteAndProject(cms);
                    getRequest().getSession().setAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS, settings);
                    m_directEditPath = getDirectEditPath(cms, settings.getUserSettings());
                } else {
                    // there was an error during login
                    CmsException loginException = getLoginException();

                    if (org.opencms.security.Messages.ERR_LOGIN_FAILED_DISABLED_2 == loginException.getMessageContainer().getKey()) {
                        // the user account is disabled
                        m_message = Messages.get().container(Messages.GUI_LOGIN_FAILED_DISABLED_0);
                    } else if (org.opencms.security.Messages.ERR_LOGIN_FAILED_TEMP_DISABLED_4 == loginException.getMessageContainer().getKey()) {
                        // the user account is temporarily disabled because of too many login failures
                        m_message = Messages.get().container(Messages.GUI_LOGIN_FAILED_TEMP_DISABLED_0);
                    } else if (org.opencms.security.Messages.ERR_LOGIN_FAILED_WITH_MESSAGE_1 == loginException.getMessageContainer().getKey()) {
                        // all logins have been disabled be the Administration
                        CmsLoginMessage loginMessage = OpenCms.getLoginManager().getLoginMessage();
                        if (loginMessage != null) {
                            m_message = Messages.get().container(
                                Messages.GUI_LOGIN_FAILED_WITH_MESSAGE_1,
                                loginMessage.getMessage());
                        }
                    }
                    if (m_message == null) {
                        if (loginException instanceof CmsCustomLoginException) {
                            m_message = loginException.getMessageContainer();
                        } else {
                            // any other error - display default message
                            m_message = Messages.get().container(Messages.GUI_LOGIN_FAILED_0);
                        }
                    }
                }
            }
        } else if (Boolean.valueOf(m_actionLogout).booleanValue()) {
            m_action = ACTION_LOGOUT;
            // store the workplace window data
            Cookie wpDataCookie = getCookie(getRequest(), COOKIE_WP_DATA);
            String wpData = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_WPDATA);
            if (wpData != null) {
                wpData = CmsEncoder.escapeXml(wpData);
                wpDataCookie.setValue(wpData);
                setCookie(wpDataCookie, false, getRequest(), getResponse());
            }
            // after logout this will automatically redirect to the login form again
            logout();
            return null;
        }

        if (m_action == ACTION_LOGIN) {
            // clear message
            m_message = null;
            // login is successful, check if the requested resource can be read
            CmsUriSplitter splitter = new CmsUriSplitter(m_requestedResource, true);
            String resource = splitter.getPrefix();
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(resource)) {
                // bad resource name, use workplace as default
                resource = CmsWorkplace.JSP_WORKPLACE_URI;
            }
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_directEditPath)
                && !getCmsObject().existsResource(resource, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
                // requested resource does either not exist or is not readable by user
                if (CmsWorkplace.JSP_WORKPLACE_URI.equals(resource)) {
                    // we know the Workplace exists, so the user does not have access to the Workplace
                    // probably this is a "Guest" user in a default setup where "Guest" has no access to the Workplace
                    m_message = Messages.get().container(Messages.GUI_LOGIN_FAILED_NO_WORKPLACE_PERMISSIONS_0);
                    m_action = ACTION_DISPLAY;
                } else if (getCmsObject().existsResource(CmsWorkplace.JSP_WORKPLACE_URI)) {
                    // resource does either not exist or is not readable, but general workplace permissions are granted
                    m_message = Messages.get().container(Messages.GUI_LOGIN_UNKNOWN_RESOURCE_1, m_requestedResource);
                    m_requestedResource = CmsWorkplace.JSP_WORKPLACE_URI;
                } else {
                    // resource does not exist and no general workplace permissions granted
                    m_message = Messages.get().container(
                        Messages.GUI_LOGIN_FAILED_NO_TARGET_PERMISSIONS_1,
                        m_requestedResource);
                    m_action = ACTION_DISPLAY;
                }
            }
            if (m_action == ACTION_DISPLAY) {
                //the login was invalid
                m_requestedResource = null;
                // destroy the generated session
                HttpSession session = getRequest().getSession(false);
                if (session != null) {
                    session.invalidate();
                }
                setCookieData(getRequest(), getResponse());
            } else {
                // successfully logged in, so set the cookie
                setCookieData(getRequest(), getResponse());
            }
        }

        return displayLoginForm();
    }
931278
private void validateDialog() throws Exception {

        CmsResource.checkResourceName(m_sitename);
        m_sitename = ensureFoldername(m_sitename);
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_site.getServer())) {
            // the server's URL must not be empty or null
            throw new CmsException(Messages.get().container(Messages.ERR_SERVER_URL_NOT_EMPTY_0));
        }
    }
533822
public void initRoot(CmsObject cms, CmsResource root) {

        addTreeItem(cms, root, null);
        readTreeLevel(cms, root.getStructureId());
    }
29679
public static void askForNewCategoryInfo(CmsUUID parentId, final AsyncCallback<CmsCategoryTitleAndName> callback) {

        CmsSitemapCategoryData categoryData = CmsSitemapView.getInstance().getController().getCategoryData();

        CmsCategoryTreeEntry entry = categoryData.getEntryById(parentId);
        String caption;
        if (entry == null) {
            caption = Messages.get().key(Messages.GUI_SITEMAP_CREATE_CATEGORY_TITLE_0);
        } else {
            caption = Messages.get().key(Messages.GUI_SITEMAP_CREATE_SUBCATEGORY_TITLE_1, entry.getPath());
        }
        CmsFormDialog dlg = new CmsFormDialog(caption, new CmsForm(true));
        dlg.setWidth(CmsPopup.DEFAULT_WIDTH);
        CmsDialogFormHandler fh = new CmsDialogFormHandler();
        fh.setSubmitHandler(new I_CmsFormSubmitHandler() {

            public void onSubmitForm(CmsForm form, Map<String, String> fieldValues, Set<String> editedFields) {

                String title = fieldValues.get("title");
                String name = fieldValues.get("name");
                callback.onSuccess(new CmsCategoryTitleAndName(title, name));

            }
        });

        dlg.setFormHandler(fh);
        fh.setDialog(dlg);
        String nameLabel = Messages.get().key(Messages.GUI_CATEGORY_NAME_LABEL_0);
        String titleLabel = Messages.get().key(Messages.GUI_CATEGORY_TITLE_LABEL_0);
        dlg.getForm().addField(CmsBasicFormField.createField(createBasicStringProperty("title", titleLabel)), "");
        dlg.getForm().addField(CmsBasicFormField.createField(createBasicStringProperty("name", nameLabel)), "");
        dlg.getForm().render();
        dlg.center();

    }
1063736
public static void showDialog(final CmsUUID referenceId, final AsyncCallback<String> createModeCallback) {

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

            @Override
            public void execute() {

                start(0, true);
                CmsCoreProvider.getVfsService().getPageInfo(referenceId, this);

            }

            @Override
            protected void onResponse(CmsListInfoBean result) {

                stop(false);
                Boolean isFolder = result.getIsFolder();
                if ((isFolder != null) && isFolder.booleanValue()) {
                    createModeCallback.onSuccess(null);
                } else {
                    (new CmsCreateModeSelectionDialog(result, createModeCallback)).center();
                }

            }
        };
        action.execute();

    }
1129958
public void displaySelectedURL()
    {
        dispFinished = false;
        if (treeCompWindow != null)
        {
            treeCompWindow.setVisible(false);
            treeCompWindow.dispose();
            treeCompWindow = null;
        }
        
        try {
            int i = rendererCombo.getSelectedIndex();
            if (i != -1)
            {
                BoxTreeProvider btp = rendererCombo.getItemAt(i);
                Page page = proc.renderPage(btp, ((ParamsPanel) rendererParamsPanel).getParams());
                setPage(page);
                
                if (segmAutorunCheckbox.isSelected())
                {
                    segmentPage();
                }
                if (logicalAutorunCheckbox.isSelected())
                {
                    buildLogicalTree();
                }
            }
        } catch (Exception e) {
            System.err.println("*** Error: "+e.getMessage());
            e.printStackTrace();
        }
    }
283337
protected void switchToCurrentProject() throws CmsException {

        if (m_currentProjectId != null) {
            // switch back to the current users project
            getCms().getRequestContext().setCurrentProject(getCms().readProject(m_currentProjectId));
        }
    }
566741
void submit() {

        // switch to root site
        m_clonedCms.getRequestContext().setSiteRoot("");

        CmsSite site = getSiteFromForm();

        if (m_site == null) {

            //Show report field and hide form fields
            m_report.setVisible(true);
            m_tab.setVisible(false);
            m_ok.setEnabled(false);
            m_ok.setVisible(true);
            //Change cancel caption to close (will not interrupt site creation anymore)
            m_cancel.setVisible(false);
            setOkButtonEnabled();
            m_cancel.setCaption(
                CmsVaadinUtils.getMessageText(org.opencms.workplace.Messages.GUI_DIALOG_BUTTON_CLOSE_0));

            Map<String, String> bundle = getBundleMap();

            boolean createOU = m_fieldCreateOU.isEnabled() & m_fieldCreateOU.getValue().booleanValue();
            CmsCreateSiteThread createThread = new CmsCreateSiteThread(
                m_clonedCms,
                m_manager,
                site,
                m_site,
                m_fieldLoadSiteTemplate.getValue(),
                getFieldTemplate(),
                createOU,
                (String)m_fieldSelectParentOU.getValue(),
                (String)m_fieldSelectOU.getValue(),
                m_os,
                bundle,
                new Runnable() {

                    public void run() {

                }

                });

            CmsReportWidget report = new CmsReportWidget(createThread);

            report.setWidth("100%");
            report.setHeight("350px");

            m_threadReport.addComponent(report);
            createThread.start();
        } else {
            if (!site.getSiteRoot().equals(m_site.getSiteRoot())) {
                m_manager.deleteElements(Collections.singletonList(m_site.getSiteRoot()));
            }
            m_manager.writeElement(site);
            m_manager.closeDialogWindow(true);
        }

    }