Returns the requested container-page resource.<p>

@param cms the current cms object

@return the container-page resource

@throws CmsException if the resource could not be read for any reason
350268
private CmsResource getContainerpage(CmsObject cms) throws CmsException {

        String currentUri = cms.getRequestContext().getUri();
        CmsResource containerPage = cms.readResource(currentUri);
        if (!CmsResourceTypeXmlContainerPage.isContainerPage(containerPage)) {
            // container page is used as template
            String cntPagePath = cms.readPropertyObject(
                containerPage,
                CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS,
                true).getValue("");
            try {
                containerPage = cms.readResource(cntPagePath);
            } catch (CmsException e) {
                if (!LOG.isDebugEnabled()) {
                    LOG.warn(e.getLocalizedMessage());
                }
                LOG.debug(e.getLocalizedMessage(), e);
            }
        }
        return containerPage;
    }
152668
public CmsResourceUtil getResourceUtil() {

        if (m_resourceUtil == null) {
            try {
                m_resourceUtil = new CmsResourceUtil(OpenCms.initCmsObject(getCms()));
                m_resourceUtil.setReferenceProject(getProject());
            } catch (CmsException ex) {
                if (LOG.isErrorEnabled()) {
                    LOG.error(ex.getLocalizedMessage(), ex);
                }
            }
        }
        return m_resourceUtil;
    }
744531
public I_CmsEditHandler getEditHandler(CmsObject cms) {

        String schema = getSchema();

        try {
            CmsXmlContentDefinition contentDefinition = CmsXmlContentDefinition.unmarshal(cms, schema);
            // get the content handler for the resource type to create
            I_CmsXmlContentHandler handler = contentDefinition.getContentHandler();
            return handler.getEditHandler();

        } catch (CmsXmlException e) {
            LOG.error(e.getMessage(), e);
        }
        return null;
    }
113283
public static CmsResource lookupPage(CmsObject cms, String uri) throws CmsException {

        try {
            CmsResource res = cms.readResource(uri);
            return res;
        } catch (CmsVfsResourceNotFoundException e) {
            String detailName = CmsResource.getName(uri).replaceAll("/$", "");
            CmsUUID detailId = cms.readIdForUrlName(detailName);
            if (detailId != null) {
                return cms.readResource(detailId);
            }
            throw new CmsVfsResourceNotFoundException(
                org.opencms.db.generic.Messages.get().container(
                    org.opencms.db.generic.Messages.ERR_READ_RESOURCE_1,
                    uri));
        }
    }
391245
private CmsObject getClonedCmsObject(CmsObject cms) throws CmsException {

        CmsObject clonedCms = OpenCms.initCmsObject(cms);
        // only online images get caches
        clonedCms.getRequestContext().setCurrentProject(clonedCms.readProject(CmsProject.ONLINE_PROJECT_ID));
        // paths are always root path
        clonedCms.getRequestContext().setSiteRoot("");

        return clonedCms;
    }
482716
public void load(CmsObject cms, CmsResource resource) throws CmsException {

        CmsFile file = cms.readFile(resource);
        CmsObject rootCms = OpenCms.initCmsObject(cms);
        rootCms.getRequestContext().setSiteRoot("");
        CmsXmlContent content = CmsXmlContentFactory.unmarshal(cms, file);
        Locale en = new Locale("en");
        for (I_CmsXmlContentValue value : content.getValues(N_INCLUDE, en)) {
            String include = value.getStringValue(rootCms);
            if (!CmsStringUtil.isEmpty(include)) {
                m_includes.add(include);
            }
        }
        for (I_CmsXmlContentValue value : content.getValues(N_EXCLUDE, en)) {
            String exclude = value.getStringValue(rootCms);
            if (!CmsStringUtil.isEmpty(exclude)) {
                m_excludes.add(exclude);
            }
        }
        I_CmsXmlContentValue robotsValue = content.getValue(N_MODE, en);
        m_mode = robotsValue.getStringValue(rootCms);

        I_CmsXmlContentValue robotsTxtTextValue = content.getValue(N_ROBOTS_TXT_TEXT, en);
        if (robotsTxtTextValue != null) {
            m_robotsTxtText = robotsTxtTextValue.getStringValue(rootCms);
        }

        I_CmsXmlContentValue computeContPageDates = content.getValue(N_COMPUTE_CONTAINER_PAGE_DATES, en);
        if (computeContPageDates != null) {
            m_computeContainerPageDates = Boolean.parseBoolean(computeContPageDates.getStringValue(rootCms));
        }

        I_CmsXmlContentValue generatorClassValue = content.getValue(N_GENERATOR_CLASS, en);
        if (generatorClassValue != null) {
            m_generatorClassName = generatorClassValue.getStringValue(rootCms);
        }

        I_CmsXmlContentValue cacheValue = content.getValue(N_CACHE, en);
        if (cacheValue != null) {
            m_useCache = Boolean.parseBoolean(cacheValue.getStringValue(rootCms));
        }

        I_CmsXmlContentValue serverUrlValue = content.getValue(N_SERVER_URL, en);
        if (serverUrlValue != null) {
            m_serverUrl = serverUrlValue.getStringValue(rootCms);
        }
    }
346768
public CmsGroupContainerBean getGroupContainer(CmsObject cms) {

        if (m_groupContainers.containsKey(CmsLocaleManager.MASTER_LOCALE)) {
            return m_groupContainers.get(CmsLocaleManager.MASTER_LOCALE);
        } else if (!m_groupContainers.isEmpty()) {
            return m_groupContainers.get(m_groupContainers.keySet().iterator().next());
        } else {
            return null;
        }
    }
1374368
protected CmsObject getSearchCms(CmsGallerySearchBean searchObj) throws CmsException {

        CmsObject searchCms = getCmsObject();
        if (searchObj.isIncludeExpired()) {
            searchCms = OpenCms.initCmsObject(getCmsObject());
            searchCms.getRequestContext().setRequestTime(CmsResource.DATE_RELEASED_EXPIRED_IGNORE);
        }
        return searchCms;
    }
1001463
public CmsContainerPageBean getContainerPage(CmsObject cms) {

        Locale masterLocale = CmsLocaleManager.MASTER_LOCALE;
        Locale localeToLoad = null;
        // always use master locale if possible, otherwise use the first locale.
        // this is important for 'legacy' container pages which were created before container pages became locale independent
        if (m_cntPages.containsKey(masterLocale)) {
            localeToLoad = masterLocale;
        } else if (!m_cntPages.isEmpty()) {
            localeToLoad = m_cntPages.keySet().iterator().next();
        }
        if (localeToLoad == null) {
            return null;
        } else {
            CmsContainerPageBean result = m_cntPages.get(localeToLoad);
            return result;
        }
    }
660859
private CmsResource readResourceFromCurrentOrRootSite(CmsObject cms, String name) throws CmsException {

        CmsResource resource = null;
        try {
            resource = cms.readResource(name, CmsResourceFilter.IGNORE_EXPIRATION);
        } catch (CmsVfsResourceNotFoundException e) {
            String originalSiteRoot = cms.getRequestContext().getSiteRoot();
            try {
                cms.getRequestContext().setSiteRoot("");
                resource = cms.readResource(name, CmsResourceFilter.IGNORE_EXPIRATION);
            } finally {
                cms.getRequestContext().setSiteRoot(originalSiteRoot);
            }

        }
        return resource;
    }
837386
private CmsResource readResource(String resourceName) throws CmsException {

        CmsResource resource = null;
        try {
            resource = getCms().readResource(resourceName, CmsResourceFilter.ALL);
        } catch (CmsVfsResourceNotFoundException e) {
            throw new CmsVfsResourceNotFoundException(
                Messages.get().container(
                    Messages.ERR_RESOURCE_DOES_NOT_EXIST_3,
                    resourceName,
                    getCms().getRequestContext().getCurrentProject().getName(),
                    getCms().getRequestContext().getSiteRoot()),
                e);
        }
        return resource;
    }
1365670
@SuppressWarnings("unused")
    public Set<String> getCSSHeadIncludes(CmsObject cms, CmsResource resource) throws CmsException {

        return getCSSHeadIncludes();
    }
1332540
protected CmsObjectWrapper getCms(SrvSession session, TreeConnection connection) throws CmsException {

        CmsJlanRepository repository = ((CmsJlanDeviceContext)connection.getContext()).getRepository();
        CmsObjectWrapper result = repository.getCms(session, connection);
        return result;
    }
940894
protected CmsBrokenLinkBean createSitemapBrokenLinkBean(CmsResource resource) throws CmsException {

        CmsObject cms = getCmsObject();
        CmsProperty titleProp = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, true);
        String defaultTitle = "";
        String title = titleProp.getValue(defaultTitle);
        String path = cms.getSitePath(resource);
        String subtitle = path;
        return new CmsBrokenLinkBean(resource.getStructureId(), title, subtitle);

    }
719960
protected CmsResource getResource(CmsObject cms, I_CmsWidgetParameter param) {

        I_CmsXmlContentValue value = (I_CmsXmlContentValue)param;
        CmsFile file = value.getDocument().getFile();
        String resourceName = cms.getSitePath(file);
        if (CmsWorkplace.isTemporaryFile(file)) {
            StringBuffer result = new StringBuffer(resourceName.length() + 2);
            result.append(CmsResource.getFolderPath(resourceName));
            result.append(CmsResource.getName(resourceName).substring(1));
            resourceName = result.toString();
        }
        try {
            List<CmsResource> listsib = cms.readSiblings(resourceName, CmsResourceFilter.ALL);
            for (int i = 0; i < listsib.size(); i++) {
                CmsResource resource = listsib.get(i);
                // get the default locale of the resource
                Locale locale = getDefaultLocale(cms, cms.getSitePath(resource));
                if (locale.equals(value.getLocale())) {
                    // get the property for the right locale
                    return resource;
                }
            }
        } catch (CmsVfsResourceNotFoundException e) {
            // may hapen if editing a new resource
            if (LOG.isDebugEnabled()) {
                LOG.debug(e.getLocalizedMessage(), e);
            }
        } catch (CmsException e) {
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
        return file;
    }
194991
public static I_CmsXmlContentHandler getContentHandlerForResource(CmsObject cms, CmsResource resource)
    throws CmsException {

        return getContentDefinitionForResource(cms, resource).getContentHandler();
    }
1053606
public I_CmsContainerpageServiceAsync getContainerpageService() {

        if (m_containerpageService == null) {
            m_containerpageService = GWT.create(I_CmsContainerpageService.class);
            String serviceUrl = CmsCoreProvider.get().link("org.opencms.ade.containerpage.CmsContainerpageService.gwt");
            ((ServiceDefTarget)m_containerpageService).setServiceEntryPoint(serviceUrl);
        }
        return m_containerpageService;
    }