Gets the detail information for the given container page.<p>

@param containerPage the container page
@return the detail information
765916
private Collection<DetailInfo> getDetailInfosForPage(CmsResource containerPage) {

        if (m_detailInfosByPage == null) {
            m_detailInfosByPage = ArrayListMultimap.create();
            for (DetailInfo detailInfo : m_detailInfos) {
                m_detailInfosByPage.put(detailInfo.getDetailPageInfo().getUri(), detailInfo);
            }
        }
        String folderPath = CmsResource.getParentFolder(containerPage.getRootPath());
        Collection<DetailInfo> result = m_detailInfosByPage.get(containerPage.getRootPath());
        if (result.isEmpty()) {
            result = m_detailInfosByPage.get(folderPath);
        }
        return result;
    }
1355251
private CmsContainerElementData getBaseElementData(CmsResource page, CmsContainerElementBean element)
    throws CmsException {

        CmsResourceUtil resUtil = new CmsResourceUtil(m_cms, element.getResource());
        CmsContainerElementData elementData = new CmsContainerElementData();
        setElementInfo(element, elementData);
        elementData.setLoadTime(System.currentTimeMillis());
        elementData.setLastModifiedDate(element.getResource().getDateLastModified());
        elementData.setLastModifiedByUser(m_cms.readUser(element.getResource().getUserLastModified()).getName());
        elementData.setNavText(resUtil.getNavText());
        Map<String, CmsXmlContentProperty> settingConfig = CmsXmlContentPropertyHelper.getPropertyInfo(
            m_cms,
            page,
            element.getResource());
        elementData.setSettings(
            CmsXmlContentPropertyHelper.convertPropertiesToClientFormat(
                m_cms,
                element.getIndividualSettings(),
                settingConfig));
        return elementData;
    }
229725
@SafeVarargs
  public static <E extends Enum<E> & TemplatePathInfo> TemplatePathInfo forPage(@NotNull Page page, @NotNull Class<E> @NotNull... templateEnums) {
    if (page == null || templateEnums == null) {
      return null;
    }
    String templatePath = page.getProperties().get(NameConstants.PN_TEMPLATE, String.class);
    return forTemplatePath(templatePath, templateEnums);
  }
524391
public static HelpViewerMode getViewerMode(Page page) {
        return page == null || !page.hasAttribute(EMBEDDED_ATTRIB) ? defaultMode
                : (HelpViewerMode) page.getAttribute(EMBEDDED_ATTRIB);
    }
1183476
public boolean getExecuteChildren(Page page) {
        ContentEntityObject entityObject = getContentEntityManager().getById(page.getId());
        String value = getContentPropertyManager().getStringProperty(entityObject, EXECUTE_CHILDREN);
        return value == null ? false : Boolean.valueOf(value);
    }
1182978
protected boolean isValidDetailPage(CmsObject cms, CmsResource page, CmsResource detailRes) {

        if (OpenCms.getSystemInfo().isRestrictDetailContents()) {
            // in 'restrict detail contents mode', do not allow detail contents from a real site on a detail page of a different real site
            CmsSite pageSite = OpenCms.getSiteManager().getSiteForRootPath(page.getRootPath());
            CmsSite detailSite = OpenCms.getSiteManager().getSiteForRootPath(detailRes.getRootPath());
            if ((pageSite != null)
                && (detailSite != null)
                && !pageSite.getSiteRoot().equals(detailSite.getSiteRoot())) {
                return false;
            }
        }
        return OpenCms.getADEManager().isDetailPage(cms, page);
    }
1179228
public CmsJspResourceWrapper getPageResource() {

        try {
            if (m_pageResource == null) {
                // get the container page itself, checking the history first
                m_pageResource = CmsJspResourceWrapper.wrap(
                    m_cms,
                    (CmsResource)CmsHistoryResourceHandler.getHistoryResource(m_request));
                if (m_pageResource == null) {
                    m_pageResource = CmsJspResourceWrapper.wrap(
                        m_cms,
                        m_cms.readResource(m_cms.getRequestContext().getUri()));
                }
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
        return m_pageResource;
    }
924311
public List<String> getDetailPages(CmsObject cms, String type) {

        CmsConfigurationCache cache = isOnline(cms) ? m_onlineCache : m_offlineCache;
        return cache.getState().getDetailPages(type);
    }
76609
protected List<CmsPublishedResource> findRelatedContainerPages(
        CmsObject adminCms,
        List<CmsPublishedResource> updateResources) {

        Set<CmsResource> elementGroups = new HashSet<CmsResource>();
        Set<CmsResource> containerPages = new HashSet<CmsResource>();
        int containerPageTypeId = -1;
        try {
            containerPageTypeId = CmsResourceTypeXmlContainerPage.getContainerPageTypeId();
        } catch (CmsLoaderException e) {
            // will happen during setup, when container page type is not available yet
            LOG.info(e.getLocalizedMessage(), e);
        }
        if (containerPageTypeId != -1) {
            for (CmsPublishedResource pubRes : updateResources) {
                try {
                    if (OpenCms.getResourceManager().getResourceType(
                        pubRes.getType()) instanceof CmsResourceTypeXmlContent) {
                        CmsRelationFilter filter = CmsRelationFilter.relationsToStructureId(pubRes.getStructureId());
                        filter.filterStrong();
                        List<CmsRelation> relations = adminCms.readRelations(filter);
                        for (CmsRelation relation : relations) {
                            CmsResource res = relation.getSource(adminCms, CmsResourceFilter.ALL);
                            if (CmsResourceTypeXmlContainerPage.isContainerPage(res)) {
                                containerPages.add(res);
                                if (CmsDetailOnlyContainerUtil.isDetailContainersPage(
                                    adminCms,
                                    adminCms.getSitePath(res))) {
                                    addDetailContent(adminCms, containerPages, adminCms.getSitePath(res));
                                }
                            } else if (OpenCms.getResourceManager().getResourceType(
                                res.getTypeId()).getTypeName().equals(
                                    CmsResourceTypeXmlContainerPage.GROUP_CONTAINER_TYPE_NAME)) {
                                elementGroups.add(res);
                            }
                        }
                    }
                    if (containerPageTypeId == pubRes.getType()) {
                        addDetailContent(
                            adminCms,
                            containerPages,
                            adminCms.getRequestContext().removeSiteRoot(pubRes.getRootPath()));
                    }
                } catch (CmsException e) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
            }
            for (CmsResource pubRes : elementGroups) {
                try {
                    CmsRelationFilter filter = CmsRelationFilter.relationsToStructureId(pubRes.getStructureId());
                    filter.filterStrong();
                    List<CmsRelation> relations = adminCms.readRelations(filter);
                    for (CmsRelation relation : relations) {
                        CmsResource res = relation.getSource(adminCms, CmsResourceFilter.ALL);
                        if (CmsResourceTypeXmlContainerPage.isContainerPage(res)) {
                            containerPages.add(res);
                            if (CmsDetailOnlyContainerUtil.isDetailContainersPage(
                                adminCms,
                                adminCms.getSitePath(res))) {
                                addDetailContent(adminCms, containerPages, adminCms.getSitePath(res));
                            }
                        }
                    }
                } catch (CmsException e) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
            }
            // add all found container pages as published resource objects to the list
            for (CmsResource page : containerPages) {
                CmsPublishedResource pubCont = new CmsPublishedResource(page);
                if (!updateResources.contains(pubCont)) {
                    // ensure container page is added only once
                    updateResources.add(pubCont);
                }
            }
        }
        return updateResources;
    }
611490
private CmsContainerElementBean getDetailFunctionElement(
        CmsObject cms,
        CmsResource detailFunctionPage,
        ServletRequest req) {

        try {
            CmsXmlContainerPage xmlContainerPage = CmsXmlContainerPageFactory.unmarshal(cms, detailFunctionPage, req);

            CmsContainerPageBean page = xmlContainerPage.getContainerPage(cms);
            CmsContainerBean container = page.getContainers().get(DETAIL_FUNCTION_CONTAINER_NAME);
            if (container == null) {
                for (Entry<String, CmsContainerBean> entry : page.getContainers().entrySet()) {
                    if (entry.getKey().endsWith("-" + DETAIL_FUNCTION_CONTAINER_NAME)) {
                        container = entry.getValue();
                        break;
                    }
                }
            }
            if (container != null) {
                return container.getElements().get(0);
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
        return null;
    }
1111175
public CmsDetailPageInfo getMainDetailPage(String type) {

        List<CmsDetailPageInfo> detailPages = getDetailPagesForType(type);
        if ((detailPages == null) || detailPages.isEmpty()) {
            return null;
        }
        return detailPages.get(0);
    }
1099982
public CmsContainerElementData getElementData(
        CmsResource page,
        CmsContainerElementBean element,
        Collection<CmsContainer> containers)
    throws CmsException {

        Locale requestLocale = m_cms.getRequestContext().getLocale();
        m_cms.getRequestContext().setLocale(m_locale);
        element.initResource(m_cms);
        if (element.getResource().isFolder()) {
            return null;
        }
        CmsContainerElementData elementData = getBaseElementData(page, element);
        CmsFormatterConfiguration formatterConfiguraton = getFormatterConfiguration(element.getResource());
        Map<String, String> contents = new HashMap<String, String>();
        if (element.isGroupContainer(m_cms)) {
            Map<String, CmsContainer> containersByName = new HashMap<String, CmsContainer>();
            for (CmsContainer container : containers) {
                containersByName.put(container.getName(), container);
            }
            CmsXmlGroupContainer xmlGroupContainer = CmsXmlGroupContainerFactory.unmarshal(
                m_cms,
                element.getResource(),
                m_req);
            CmsGroupContainerBean groupContainer = xmlGroupContainer.getGroupContainer(m_cms);
            // make sure to use the content title and not the property title
            elementData.setTitle(groupContainer.getTitle());
            elementData.setTypes(groupContainer.getTypes());
            elementData.setDescription(groupContainer.getDescription());
            if (groupContainer.getTypes().isEmpty()) {
                if (groupContainer.getElements().isEmpty()) {
                    String emptySub = "<div>NEW AND EMPTY</div>";
                    for (CmsContainer cont : containersByName.values()) {
                        if (formatterConfiguraton.hasFormatter(cont.getType(), cont.getWidth())) {
                            contents.put(cont.getName(), emptySub);
                        }
                    }
                } else {
                    // TODO: throw appropriate exception
                    return null;
                }
            } else {

                // add formatter and content entries for the supported types
                for (CmsContainer cnt : containersByName.values()) {

                    String type = cnt.getType();
                    if (checkGroupAllowed(type, groupContainer)) {
                        contents.put(cnt.getName(), "<div>should not be used</div>");
                    }
                }
            }
            // add subitems
            List<String> subItems = new ArrayList<String>();

            for (CmsContainerElementBean subElement : groupContainer.getElements()) {
                // collect ids
                subItems.add(subElement.editorHash());
            }
            elementData.setSubItems(subItems);
        } else if (element.isInheritedContainer(m_cms)) {
            CmsInheritanceReferenceParser parser = new CmsInheritanceReferenceParser(m_cms);
            parser.parse(element.getResource());
            CmsInheritanceReference ref = parser.getReference(m_locale);
            String name = null;
            // check for new inheritance reference
            if (ref != null) {
                name = ref.getName();
                elementData.setDescription(ref.getDescription());
                elementData.setTitle(ref.getTitle());
            }
            for (CmsContainer container : containers) {
                if (formatterConfiguraton.hasFormatter(container.getType(), container.getWidth())) {
                    contents.put(container.getName(), "<div>should not be used</div>");
                }
            }

            List<CmsInheritanceInfo> inheritanceInfos = new ArrayList<CmsInheritanceInfo>();
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(name)) {
                CmsInheritedContainerState result = OpenCms.getADEManager().getInheritedContainerState(
                    m_cms,
                    m_cms.addSiteRoot(m_currentPageUri),
                    name);
                for (CmsContainerElementBean subElement : result.getElements(true)) {
                    CmsInheritanceInfo inheritanceInfo = subElement.getInheritanceInfo();
                    inheritanceInfo.setClientId(subElement.editorHash());
                    inheritanceInfos.add(inheritanceInfo);
                }
            } else {
                // setting a new id for name, will be persisted once the inheritance reference is edited and saved.
                // use the structure id so it will always be the same for the resource
                name = element.getResource().getStructureId().toString();
            }
            elementData.setInheritanceInfos(inheritanceInfos);
            elementData.setInheritanceName(name);
        } else {

            for (CmsContainer cnt : containers) {
                boolean missesFormatterSetting = !elementData.getSettings().containsKey(
                    CmsFormatterConfig.getSettingsKeyForContainer(cnt.getName()));
                if (missesFormatterSetting) {
                    if (element.getFormatterId() == null) {
                        I_CmsFormatterBean formatter = getStartFormatter(
                            m_cms,
                            cnt,
                            m_adeConfig,
                            element,
                            CmsADESessionCache.getCache(m_req, m_cms));
                        if (formatter != null) {
                            elementData.getSettings().put(
                                CmsFormatterConfig.getSettingsKeyForContainer(cnt.getName()),
                                formatter.getId());
                            element.addFormatterSetting(cnt.getName(), formatter.getId());
                        }
                    } else {
                        Map<String, I_CmsFormatterBean> formatterSelection = formatterConfiguraton.getFormatterSelection(
                            cnt.getType(),
                            cnt.getWidth());
                        for (Entry<String, I_CmsFormatterBean> formatterEntry : formatterSelection.entrySet()) {
                            I_CmsFormatterBean formatter = formatterEntry.getValue();
                            String id = formatterEntry.getKey();
                            if (element.getFormatterId().equals(formatter.getJspStructureId())) {
                                elementData.getSettings().put(
                                    CmsFormatterConfig.getSettingsKeyForContainer(cnt.getName()),
                                    id);
                                break;
                            }
                        }
                    }
                }
            }
            // get the formatter configuration
            Map<String, String> contentsByName = getContentsByContainerName(element, containers);
            contents = contentsByName;
        }
        elementData.setContents(contents);
        m_cms.getRequestContext().setLocale(requestLocale);
        return elementData;
    }
1002445
public static String getDetailType(CmsObject cms, CmsResource detailPage, CmsResource parentFolder) {

        String type = null;
        try {
            if (OpenCms.getADEManager().isDetailPage(cms, detailPage)) {
                List<CmsDetailPageInfo> detailPages = OpenCms.getADEManager().getAllDetailPages(cms);
                if (parentFolder == null) {
                    parentFolder = cms.readParentFolder(detailPage.getStructureId());
                }
                for (CmsDetailPageInfo info : detailPages) {
                    if (info.getId().equals(detailPage.getStructureId())
                        || info.getId().equals(parentFolder.getStructureId())) {
                        type = info.getType();
                        if (type.startsWith(CmsDetailPageInfo.FUNCTION_PREFIX)) {
                            type = CmsXmlDynamicFunctionHandler.TYPE_FUNCTION;
                        }
                        break;
                    }
                }
            }
        } catch (CmsException e) {
            // parent folder can't be read, ignore
        }
        return type;
    }
231269
public CmsDetailPageInfo getBestDetailPage(String type) {

        List<CmsDetailPageInfo> infos = m_map.get(type);
        if ((infos == null) || infos.isEmpty()) {
            return null;
        }
        return infos.get(0);
    }
319921
public CmsContainerPageBean removeModelGroupContainers(CmsContainerPageBean page) {

        Map<String, List<CmsContainerBean>> containersByParent = getContainerByParent(page);
        Set<String> modelInstances = new HashSet<String>();
        for (CmsContainerElementBean element : page.getElements()) {
            if (element.getIndividualSettings().containsKey(CmsContainerElement.MODEL_GROUP_ID)) {
                modelInstances.add(element.getInstanceId());
            }
        }

        Set<String> descendingInstances = new HashSet<String>();
        for (String modelInstance : modelInstances) {
            descendingInstances.addAll(collectDescendingInstances(modelInstance, containersByParent));
        }
        List<CmsContainerBean> containers = new ArrayList<CmsContainerBean>();
        for (CmsContainerBean container : page.getContainers().values()) {
            if ((container.getParentInstanceId() == null)
                || !descendingInstances.contains(container.getParentInstanceId())) {
                // iterate the container elements to replace the model group elements
                List<CmsContainerElementBean> elements = new ArrayList<CmsContainerElementBean>();
                for (CmsContainerElementBean element : container.getElements()) {
                    if (modelInstances.contains(element.getInstanceId())) {
                        CmsUUID modelId = new CmsUUID(
                            element.getIndividualSettings().get(CmsContainerElement.MODEL_GROUP_ID));
                        CmsContainerElementBean replacer = new CmsContainerElementBean(
                            modelId,
                            element.getFormatterId(),
                            element.getIndividualSettings(),
                            false);
                        elements.add(replacer);
                    } else {
                        elements.add(element);
                    }
                }
                containers.add(
                    new CmsContainerBean(
                        container.getName(),
                        container.getType(),
                        container.getParentInstanceId(),
                        container.isRootContainer(),
                        container.getMaxElements(),
                        elements));

            }
        }
        return new CmsContainerPageBean(containers);
    }
299324
protected void parseDetailPage(I_CmsXmlContentLocation node) throws CmsException {

        I_CmsXmlContentValueLocation pageLoc = node.getSubValue(N_PAGE);
        String typeName = getString(node.getSubValue(N_TYPE));
        try {
            String page = pageLoc.asString(m_cms);
            CmsResource detailPageRes = m_cms.readResource(page);
            CmsUUID id = detailPageRes.getStructureId();
            String iconClasses;
            if (typeName.startsWith(CmsDetailPageInfo.FUNCTION_PREFIX)) {
                iconClasses = CmsIconUtil.getIconClasses(CmsXmlDynamicFunctionHandler.TYPE_FUNCTION, null, false);
            } else {
                iconClasses = CmsIconUtil.getIconClasses(typeName, null, false);
            }

            CmsDetailPageInfo detailPage = new CmsDetailPageInfo(id, page, typeName, iconClasses);
            m_detailPageConfigs.add(detailPage);
        } catch (CmsVfsResourceNotFoundException e) {
            CmsUUID structureId = pageLoc.asId(m_cms);
            CmsResource detailPageRes = m_cms.readResource(structureId);
            CmsDetailPageInfo detailPage = new CmsDetailPageInfo(
                structureId,
                m_cms.getSitePath(detailPageRes),
                typeName,
                CmsIconUtil.getIconClasses(typeName, null, false));
            m_detailPageConfigs.add(detailPage);
        }
    }
784856
protected void addDetailLinks(CmsResource containerPage, Locale locale) throws CmsException {

        List<I_CmsResourceType> types = getDetailTypesForPage(containerPage);
        for (I_CmsResourceType type : types) {
            List<CmsResource> resourcesForType = getDetailResources(type);
            for (CmsResource detailRes : resourcesForType) {
                if (!isValidDetailPageCombination(containerPage, locale, detailRes)) {
                    continue;
                }
                List<CmsProperty> detailProps = m_guestCms.readPropertyObjects(detailRes, true);
                String detailLink = getDetailLink(containerPage, detailRes, locale);
                detailLink = CmsFileUtil.removeTrailingSeparator(detailLink);
                CmsXmlSitemapUrlBean detailUrlBean = new CmsXmlSitemapUrlBean(
                    replaceServerUri(detailLink),
                    detailRes.getDateLastModified(),
                    getChangeFrequency(detailProps),
                    getPriority(detailProps));
                detailUrlBean.setOriginalResource(detailRes);
                detailUrlBean.setDetailPageResource(containerPage);
                addResult(detailUrlBean, 2);
            }
        }
    }