Reads out all forms and creates a site object.<p>

@return the site object.
489604
private CmsSite getSiteFromForm() {

        String siteRoot = getSiteRoot();
        CmsSiteMatcher matcher = (CmsStringUtil.isNotEmpty(m_fieldSecureServer.getValue())
            & m_simpleFieldEncryption.getValue().equals(CmsSSLMode.SECURE_SERVER))
            ? new CmsSiteMatcher(m_fieldSecureServer.getValue())
            : null;
        CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot);
        CmsUUID uuid = new CmsUUID();
        if ((site != null) && (site.getSiteMatcher() != null)) {
            uuid = (CmsUUID)site.getSiteRootUUID().clone();
        }
        String errorPage = CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_fieldErrorPage.getValue())
        ? m_fieldErrorPage.getValue()
        : null;
        List<CmsSiteMatcher> aliases = getAliases();
        CmsSite ret = new CmsSite(
            siteRoot,
            uuid,
            getFieldTitle(),
            new CmsSiteMatcher(getFieldServer()),
            ((PositionComboBoxElementBean)m_fieldPosition.getValue()).getPosition() == -1
            ? String.valueOf(m_site.getPosition())
            : String.valueOf(((PositionComboBoxElementBean)m_fieldPosition.getValue()).getPosition()),
            errorPage,
            matcher,
            m_fieldExclusiveURL.getValue().booleanValue(),
            m_fieldExclusiveError.getValue().booleanValue(),
            m_fieldWebServer.getValue().booleanValue(),
            aliases);
        ret.setParameters((SortedMap<String, String>)getParameter());
        ret.setSSLMode((CmsSSLMode)m_simpleFieldEncryption.getValue());
        return ret;
    }
551666
public CmsContainerPageBean build() {

        List<CmsContainerBean> containers = Lists.newArrayList();
        for (String containerName : m_containerInfos.keySet()) {
            CmsContainerBean containerBean = buildContainerBean(m_containerInfos.get(containerName));
            containers.add(containerBean);
        }
        return new CmsContainerPageBean(containers);
    }
1050141
public I_CmsWidget getWidgetObject() {

        if (getWidget() == null) {
            if (m_params == null) {
                return new CmsInputWidget();
            } else {
                return new CmsInputWidget(m_params);
            }
        }
        try {
            if (m_params == null) {
                return (I_CmsWidget)Class.forName(getWidget()).newInstance();
            }
            Class<?> clazz = Class.forName(getWidget());
            Constructor<?> ctor = clazz.getConstructor(new Class[] {String.class});
            return (I_CmsWidget)ctor.newInstance(new Object[] {m_params});
        } catch (Exception e) {
            return new CmsInputWidget();
        }
    }
249134
def get_queryset(self):
        

        queryset = super(SingletonManager, self).get_queryset()

        # Get current site
        current_site = None
        if getattr(settings, 'SITE_ID', None) is not None:
            current_site = Site.objects.get_current()

        # If site found limit queryset to site.
        if current_site is not None:
            queryset = queryset.filter(sites=settings.SITE_ID)

        if not queryset.exists():
            # Create object (for current site) if it doesn't exist.
            obj = self.model.objects.create()
            if current_site is not None:
                obj.sites.add(current_site)

        return queryset
1315948
public CmsFile getFile() {

        if (m_base instanceof CmsFile) {
            CmsFile file = (CmsFile)m_base;

            return new CmsFile(
                file.getStructureId(),
                file.getResourceId(),
                m_rootPath,
                m_typeId,
                file.getFlags(),
                file.getProjectLastModified(),
                file.getState(),
                file.getDateCreated(),
                file.getUserCreated(),
                file.getDateLastModified(),
                file.getUserLastModified(),
                file.getDateReleased(),
                file.getDateExpired(),
                file.getSiblingCount(),
                file.getLength(),
                file.getDateContent(),
                file.getVersion(),
                file.getContents());
        }

        return new CmsFile(getResource());
    }
1092486
public CmsResource createResource() throws CmsException {

        String path = OpenCms.getResourceManager().getNameGenerator().getNewFileName(
            m_cms,
            m_pathWithPattern,
            5,
            m_explorerNameGeneration);
        Locale contentLocale = OpenCms.getLocaleManager().getDefaultLocale(m_cms, CmsResource.getFolderPath(path));
        CmsRequestContext context = m_cms.getRequestContext();
        if (m_modelResource != null) {
            context.setAttribute(CmsRequestContext.ATTRIBUTE_MODEL, m_modelResource.getRootPath());
        }
        context.setAttribute(CmsRequestContext.ATTRIBUTE_NEW_RESOURCE_LOCALE, contentLocale);
        CmsResource res = m_cms.createResource(
            path,
            OpenCms.getResourceManager().getResourceType(m_type),
            null,
            new ArrayList<CmsProperty>());
        if (m_propChanges != null) {
            CmsPropertyEditorHelper helper = new CmsPropertyEditorHelper(m_cms);
            helper.overrideStructureId(res.getStructureId());
            helper.saveProperties(m_propChanges);
        }
        // Path or other metadata may have changed
        m_createdResource = m_cms.readResource(res.getStructureId(), CmsResourceFilter.IGNORE_EXPIRATION);
        try {
            m_cms.unlockResource(m_createdResource);
        } catch (CmsException e) {
            LOG.info(e.getLocalizedMessage(), e);
        }
        for (I_Callback callback : m_callbacks) {
            callback.onResourceCreated(this);
        }
        return m_createdResource;
    }
461138
private List<CmsSelectWidgetOption> getSites() {

        List<CmsSelectWidgetOption> sites = new ArrayList<CmsSelectWidgetOption>();
        List<CmsSite> sitesList = OpenCms.getSiteManager().getAvailableSites(getCms(), true, false, getParamOufqn());

        String defSite = null;
        if ((m_user != null) && CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_user.getName())) {
            defSite = new CmsUserSettings(m_user).getStartSite();
        }
        if (defSite == null) {
            defSite = getCms().getRequestContext().getSiteRoot();
        }
        if (!defSite.endsWith("/")) {
            defSite += "/";
        }

        Iterator<CmsSite> itSites = sitesList.iterator();
        while (itSites.hasNext()) {
            CmsSite site = itSites.next();
            String siteRoot = site.getSiteRoot();
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(siteRoot)) {
                if (sitesList.size() > 1) {
                    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_user.getName())) {
                        if (!OpenCms.getRoleManager().hasRole(getCms(), m_user.getName(), CmsRole.VFS_MANAGER)) {
                            // skip the root site if not accessible
                            continue;
                        }
                    }
                }
            }
            if (!siteRoot.endsWith("/")) {
                siteRoot += "/";
            }
            boolean selected = defSite.equals(siteRoot);
            sites.add(new CmsSelectWidgetOption(siteRoot, selected, substituteSiteTitle(site.getTitle()), null));
        }
        return sites;
    }
504110
public List<SiteNode> getNodesInScopeFromSiteTree() {
		List<SiteNode> nodes = new LinkedList<>();
		SiteNode rootNode = getSiteTree().getRoot();
		fillNodesInScope(rootNode, nodes);
		return nodes;
	}
91915
protected void initializeForm() {

        String target = CmsSitemapView.getInstance().getController().getData().getAliasImportUrl();
        m_formPanel.setAction(target);
        m_formPanel.setMethod(FormPanel.METHOD_POST);
        m_formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
        Hidden siteRootField = new Hidden(I_CmsAliasConstants.PARAM_SITEROOT);
        siteRootField.setValue(CmsCoreProvider.get().getSiteRoot());
        m_formPanelContents.add(siteRootField);
        m_formPanelContents.add(m_separatorField);
        m_formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {

            public void onSubmitComplete(SubmitCompleteEvent event) {

                final String formPostResults = event.getResults();
                final I_CmsSitemapServiceAsync service = CmsSitemapView.getInstance().getController().getService();
                CmsRpcAction<List<CmsAliasImportResult>> action = new CmsRpcAction<List<CmsAliasImportResult>>() {

                    @Override
                    public void execute() {

                        start(200, false);
                        service.getAliasImportResult(formPostResults.trim(), this);
                    }

                    @Override
                    public void onResponse(List<CmsAliasImportResult> result) {

                        stop(false);
                        handleImportResults(result);
                        Timer resizeTimer = new Timer() {

                            @Override
                            public void run() {

                                m_scrollPanel.onResizeDescendant();
                            }
                        };
                        resizeTimer.schedule(100);
                    }
                };
                action.execute();
            }
        });
    }
955257
public CmsHtmlList getList() {

        if ((m_list != null) && (m_list.getMetadata() == null)) {
            m_list.setMetadata(getMetadata(getClass().getName(), m_list.getId()));
        }
        return m_list;
    }
1353276
private List<CmsResourceInfo> getResourceInfos() {

        List<CmsResourceInfo> infos = new ArrayList<CmsResourceInfo>();
        for (CmsSite site : m_sitesToDelete) {
            infos.add(
                new CmsResourceInfo(site.getTitle(), site.getSiteRoot(), m_manager.getFavIcon(site.getSiteRoot())));
        }
        return infos;
    }
401492
private void createAllWebserverConfigs() throws IOException {

        List<CmsSite> sites = OpenCms.getSiteManager().getAvailableSites(getCms(), true);
        for (CmsSite site : sites) {
            if ((site.getSiteMatcher() != null) && site.isWebserver()) {

                String filename = m_targetPath
                    + m_filePrefix
                    + "_"
                    + generateWebserverConfigName(site.getSiteMatcher(), "_");
                getReport().println(
                    Messages.get().container(Messages.RPT_CREATING_CONFIG_FOR_SITE_2, filename, site),
                    I_CmsReport.FORMAT_OK);
                File newFile = new File(filename);
                if (!newFile.exists()) {
                    newFile.getParentFile().mkdirs();
                    newFile.createNewFile();
                }

                String content = createConfigForSite(site, FileUtils.readFileToString(new File(m_templatePath)));
                if (site.hasSecureServer()) {
                    content += createConfigForSite(site, FileUtils.readFileToString(new File(m_secureTemplate)));
                }

                FileUtils.writeStringToFile(newFile, content);
                m_writtenFiles.add(newFile.getAbsolutePath());
            }
        }
    }
1120770
private List getTemplates() {

        ArrayList ret = new ArrayList();
        TreeMap templates = null;

        try {
            templates = CmsNewResourceXmlPage.getTemplates(getJsp().getCmsObject(), null);

            // loop through all templates and build the entries
            Iterator i = templates.entrySet().iterator();
            while (i.hasNext()) {
                Map.Entry entry = (Map.Entry)i.next();
                String title = (String)entry.getKey();
                String path = (String)entry.getValue();

                ret.add(new CmsSelectWidgetOption(path, false, title));
            }
        } catch (CmsException e) {
            // not necessary
        }

        return ret;
    }
1293791
private String createConfigForSite(CmsSite site, String templateContent) {

        StringTemplate config = new StringTemplate(templateContent);

        // system info
        String webappPath = OpenCms.getSystemInfo().getWebApplicationRfsPath();
        config.setAttribute("DOCUMENT_ROOT", webappPath.substring(0, webappPath.length() - 1));
        config.setAttribute("WEBAPP_NAME", OpenCms.getSystemInfo().getWebApplicationName());
        config.setAttribute("CONTEXT_PATH", OpenCms.getSystemInfo().getContextPath());
        config.setAttribute("SERVLET_PATH", OpenCms.getSystemInfo().getServletPath());
        config.setAttribute("DEFAULT_ENCODING", OpenCms.getSystemInfo().getDefaultEncoding());
        config.setAttribute("CONFIG_FILENAME", generateWebserverConfigName(site.getSiteMatcher(), "_"));
        config.setAttribute("LOGGING_DIRECTORY", m_loggingDir);

        // site info
        config.setAttribute("SERVER_URL", site.getUrl());
        config.setAttribute("SERVER_PROTOCOL", site.getSiteMatcher().getServerProtocol());
        config.setAttribute("SERVER_NAME", site.getSiteMatcher().getServerName());
        config.setAttribute("SERVER_PORT", site.getSiteMatcher().getServerPort());
        config.setAttribute("SERVER_NAME_WITH_PORT", generateWebserverConfigName(site.getSiteMatcher(), ":"));
        config.setAttribute("SITE_TITLE", site.getTitle());
        if (site.getErrorPage() != null) {
            config.setAttribute("ERROR_PAGE", site.getErrorPage());
        }

        // alias info
        if ((site.getAliases() != null) && !site.getAliases().isEmpty()) {
            config.setAttribute("ALIAS_DIRECTIVE", "ServerAlias");
            for (CmsSiteMatcher alias : site.getAliases()) {
                config.setAttribute("SERVER_ALIASES", generateWebserverConfigName(alias, ":") + " ");
            }
        }

        // secure info
        if (site.hasSecureServer()) {
            if (site.getSecureUrl() != null) {
                config.setAttribute("SECURE_URL", site.getSecureUrl());
            }
            if (site.getSecureServer() != null) {
                config.setAttribute("SECURE_SRV_WITH_PORT", generateWebserverConfigName(site.getSecureServer(), ":"));
                config.setAttribute("SECURE_SERVER_NAME", site.getSecureServer().getServerName());
                config.setAttribute("SECURE_SERVER_PORT", site.getSecureServer().getServerPort());
                config.setAttribute("SECURE_SERVER_PROTOCOL", site.getSecureServer().getServerProtocol());
            }
        }
        return config.toString();
    }
1137757
private static BeanItemContainer<CmsSite> setUpWorkplaceComboBox(
        List<CmsSite> allSites,
        final ComboBox combo,
        boolean nullselect,
        String defaultValue,
        CmsSSLMode sslMode) {

        final List<CmsSite> modSites = new ArrayList<CmsSite>();
        CmsSite siteWithDefaultURL = null;

        String defaultURL = defaultValue;

        for (CmsSite site : allSites) {
            CmsSite si = new CmsSite("dummy", site.getUrl());
            si.setSSLMode(site.getSSLMode());
            modSites.add(si);
            if (defaultValue != null) {
                if (defaultURL.equals(si.getUrl())) { //SSL sensitive ('http'!='https')
                    siteWithDefaultURL = si;
                }
            }
        }
        if (defaultValue != null) {
            if (siteWithDefaultURL == null) {
                siteWithDefaultURL = new CmsSite("dummy", defaultURL);
                siteWithDefaultURL.setSSLMode(sslMode);
                modSites.add(0, siteWithDefaultURL);
            }
        }

        final BeanItemContainer<CmsSite> objects = new BeanItemContainer<CmsSite>(CmsSite.class, modSites);
        combo.setContainerDataSource(objects);
        combo.setNullSelectionAllowed(nullselect);
        combo.setItemCaptionPropertyId("url");
        combo.setValue(siteWithDefaultURL);
        combo.setNewItemsAllowed(true);
        combo.setImmediate(true);
        combo.setNewItemHandler(new NewItemHandler() {

            private static final long serialVersionUID = -4760590374697520609L;

            public void addNewItem(String newItemCaption) {

                CmsSite newItem = new CmsSite("dummy", newItemCaption);
                newItem.setSSLMode(newItemCaption.contains("https:") ? CmsSSLMode.MANUAL : CmsSSLMode.NO);
                objects.addBean(newItem);
                combo.select(newItem);
            }
        });
        return objects;
    }
798849
private CmsResource createSiteRootIfNeeded(String siteRoot) throws CmsException {

        CmsResource siteRootResource = null;

        // check if the site root already exists
        try {
            // take the existing site and do not perform any OU related actions
            if (m_cms.existsResource(siteRoot)) {
                siteRootResource = m_cms.readResource(siteRoot);
            } else {
                CmsResource onlineVersion = m_cmsOnline.readResource(siteRoot);
                siteRootResource = m_cms.readResource(onlineVersion.getStructureId());
            }

        } catch (CmsVfsResourceNotFoundException e) {
            // not create a new site folder and the according OU if option is checked checked
            getReport().println(
                Messages.get().container(Messages.RPT_SITE_CREATE_RESOURCES_0),
                I_CmsReport.FORMAT_DEFAULT);
            I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(
                CmsResourceTypeFolderSubSitemap.TYPE_SUBSITEMAP);
            siteRootResource = m_cms.createResource(siteRoot, type);
            CmsProperty folderTitle = new CmsProperty(
                CmsPropertyDefinition.PROPERTY_TITLE,
                m_site.getTitle(),
                m_site.getTitle());
            m_cms.writePropertyObject(siteRoot, folderTitle);

        }
        return siteRootResource;
    }
656838
private String getSiteOU() {

        try {
            m_clonedCms.getRequestContext().setSiteRoot("");
            CmsResource resource = m_clonedCms.readResource(m_site.getSiteRoot());
            List<CmsRelation> relations = m_clonedCms.getRelationsForResource(resource, CmsRelationFilter.SOURCES);
            for (CmsRelation relation : relations) {
                if (relation.getSourcePath().startsWith("/system/orgunits/")) {
                    return (relation.getSourcePath().substring("/system/orgunits/".length()));
                }
            }
        } catch (CmsException e) {
            LOG.error("Error on reading OUs", e);
        }
        return "/";
    }