Builds an IndexedContainer containing the sites selectable by the current user.<p>

@param cms the CMS context
@param captionPropertyName the name of the property used to store captions

@return the container with the available sites
964798
public static IndexedContainer getAvailableSitesContainer(CmsObject cms, String captionPropertyName) {

        CmsSiteSelectorOptionBuilder optBuilder = new CmsSiteSelectorOptionBuilder(cms);
        optBuilder.addNormalSites(true, (new CmsUserSettings(cms)).getStartFolder());
        optBuilder.addSharedSite();
        IndexedContainer availableSites = new IndexedContainer();
        availableSites.addContainerProperty(captionPropertyName, String.class, null);
        for (CmsSiteSelectorOption option : optBuilder.getOptions()) {
            Item siteItem = availableSites.addItem(option.getSiteRoot());
            siteItem.getItemProperty(captionPropertyName).setValue(option.getMessage());
        }
        String currentSiteRoot = cms.getRequestContext().getSiteRoot();
        if (!availableSites.containsId(currentSiteRoot)) {
            availableSites.addItem(currentSiteRoot).getItemProperty(captionPropertyName).setValue(currentSiteRoot);
        }
        return availableSites;
    }
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;
    }
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;
        }
    }
1085176
public Map<String, CmsXmlContentProperty> getPropertyConfigurationAsMap() {

        Map<String, CmsXmlContentProperty> result = new LinkedHashMap<String, CmsXmlContentProperty>();
        for (CmsPropertyConfig propConf : getPropertyConfiguration()) {
            result.put(propConf.getName(), propConf.getPropertyData());
        }
        return result;
    }
1265537
protected static String getResourceName(CmsObject cms, I_CmsResourceContainer contentContainer) {

        if ((contentContainer != null) && (contentContainer.getResourceName() != null)) {
            return contentContainer.getResourceName();
        } else if (cms != null) {
            return cms.getRequestContext().getUri();
        } else {
            return null;
        }
    }
166069
public static List<CmsContextMenuEntryBean> getContextMenuEntries(
        final CmsObject cms,
        CmsUUID structureId,
        final AdeContext context) {

        Map<String, CmsContextMenuEntryBean> entries = new LinkedHashMap<String, CmsContextMenuEntryBean>();
        try {
            final List<CmsResource> resources;
            CmsResource resource = cms.readResource(structureId, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED);
            // in case of sitemap editor check visibility with empty list
            if (context.equals(AdeContext.sitemapeditor)) {
                resources = Collections.emptyList();
            } else {
                resources = Collections.singletonList(resource);
            }
            Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms);
            // context to check item visibility
            I_CmsDialogContext dcontext = new I_CmsDialogContextWithAdeContext() {

                public void error(Throwable error) {
                    // not supported
                }

                public void finish(CmsProject project, String siteRoot) {
                    // not supported
                }

                public void finish(Collection<CmsUUID> result) {
                    // not supported
                }

                public void focus(CmsUUID id) {
                    // not supported
                }

                public AdeContext getAdeContext() {

                    return context;
                }

                public List<CmsUUID> getAllStructureIdsInView() {

                    return null;
                }

                public String getAppId() {

                    return context.name();
                }

                public CmsObject getCms() {

                    return cms;
                }

                public ContextType getContextType() {

                    ContextType type;
                    switch (context) {
                        case pageeditor:
                        case editprovider:
                            type = ContextType.containerpageToolbar;
                            break;
                        case sitemapeditor:
                            type = ContextType.sitemapToolbar;
                            break;
                        default:
                            type = ContextType.fileTable;
                    }
                    return type;
                }

                public List<CmsResource> getResources() {

                    return resources;
                }

                public void navigateTo(String appId) {
                    // not supported
                }

                public void onViewChange() {
                    // not supported
                }

                public void reload() {
                    // not supported
                }

                public void setWindow(Window window) {
                    // not supported
                }

                public void start(String title, Component dialog) {
                    // not supported
                }

                public void start(String title, Component dialog, DialogWidth width) {
                    // not supported
                }

                public void updateUserInfo() {
                    // not supported
                }
            };
            Map<String, List<CmsContextMenuEntryBean>> submenus = new HashMap<String, List<CmsContextMenuEntryBean>>();
            List<I_CmsContextMenuItem> items = new ArrayList<I_CmsContextMenuItem>(
                OpenCms.getWorkplaceAppManager().getMenuItemProvider().getMenuItems());
            Collections.sort(items, new Comparator<I_CmsContextMenuItem>() {

                public int compare(I_CmsContextMenuItem arg0, I_CmsContextMenuItem arg1) {

                    return Float.compare(arg0.getOrder(), arg1.getOrder());
                }
            });

            for (I_CmsContextMenuItem item : items) {

                if (!item.isLeafItem()) {
                    CmsMenuItemVisibilityMode visibility = item.getVisibility(dcontext);
                    if (!visibility.isInVisible()) {
                        entries.put(
                            item.getId(),
                            new CmsContextMenuEntryBean(
                                visibility.isActive(),
                                true,
                                null,
                                item.getTitle(locale),
                                null,
                                CmsStringUtil.isEmptyOrWhitespaceOnly(visibility.getMessageKey())
                                ? null
                                : OpenCms.getWorkplaceManager().getMessages(locale).getString(
                                    visibility.getMessageKey()),
                                false,
                                new ArrayList<CmsContextMenuEntryBean>()));
                    }
                } else if ((item instanceof I_CmsADEAction) && ((I_CmsADEAction)item).isAdeSupported()) {
                    CmsMenuItemVisibilityMode visibility = item.getVisibility(dcontext);
                    if (!visibility.isInVisible()) {
                        String jspPath = ((I_CmsADEAction)item).getJspPath();
                        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(jspPath)) {
                            jspPath = OpenCms.getLinkManager().substituteLink(cms, jspPath);
                        }
                        CmsContextMenuEntryBean itemBean = new CmsContextMenuEntryBean(
                            visibility.isActive(),
                            true,
                            jspPath,
                            item.getTitle(locale),
                            ((I_CmsADEAction)item).getCommandClassName(),
                            CmsStringUtil.isEmptyOrWhitespaceOnly(visibility.getMessageKey())
                            ? null
                            : OpenCms.getWorkplaceManager().getMessages(locale).getString(visibility.getMessageKey()),
                            false,
                            null);
                        Map<String, String> params = ((I_CmsADEAction)item).getParams();
                        if (params != null) {
                            params = new HashMap<String, String>(params);
                            for (Entry<String, String> param : params.entrySet()) {
                                String value = CmsVfsService.prepareFileNameForEditor(cms, resource, param.getValue());
                                param.setValue(value);
                            }
                            itemBean.setParams(params);
                        }
                        entries.put(item.getId(), itemBean);
                        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(item.getParentId())) {
                            List<CmsContextMenuEntryBean> submenu;
                            if (submenus.containsKey(item.getParentId())) {
                                submenu = submenus.get(item.getParentId());
                            } else {
                                submenu = new ArrayList<CmsContextMenuEntryBean>();
                                submenus.put(item.getParentId(), submenu);
                            }
                            submenu.add(itemBean);
                        }
                    }
                }
            }
            List<CmsContextMenuEntryBean> result = new ArrayList<CmsContextMenuEntryBean>();
            for (I_CmsContextMenuItem item : items) {
                if (entries.containsKey(item.getId())) {
                    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(item.getParentId())) {
                        if (entries.containsKey(item.getParentId())) {
                            CmsContextMenuEntryBean parent = entries.get(item.getParentId());
                            if (parent.getSubMenu() != null) {
                                parent.getSubMenu().add(entries.get(item.getId()));
                            }
                        }
                    } else {
                        result.add(entries.get(item.getId()));
                    }
                }
            }
            return result;
        } catch (CmsException e) {
            // ignore, the user probably has not enough permissions to read the resource
            LOG.debug(e.getLocalizedMessage(), e);
        }
        return Collections.emptyList();
    }
424418
private IndexedContainer getStartViewContainer(String caption) {

        List<I_CmsWorkplaceAppConfiguration> apps = OpenCms.getWorkplaceAppManager().getDefaultQuickLaunchConfigurations();

        IndexedContainer res = new IndexedContainer();

        res.addContainerProperty(caption, String.class, "");

        for (I_CmsWorkplaceAppConfiguration app : apps) {
            if (hasRoleForApp(app)) {
                Item item = res.addItem(app.getId());
                item.getItemProperty(caption).setValue(app.getName(A_CmsUI.get().getLocale()));
            }
        }
        return res;
    }
611442
private IndexedContainer createContainerForBundleWithoutDescriptor() throws IOException, CmsException {

        IndexedContainer container = new IndexedContainer();

        // create properties
        container.addContainerProperty(TableProperty.KEY, String.class, "");
        container.addContainerProperty(TableProperty.TRANSLATION, String.class, "");

        // add entries
        SortedProperties localization = getLocalization(m_locale);
        Set<Object> keySet = m_keyset.getKeySet();
        for (Object key : keySet) {

            Object itemId = container.addItem();
            Item item = container.getItem(itemId);
            item.getItemProperty(TableProperty.KEY).setValue(key);
            Object translation = localization.get(key);
            item.getItemProperty(TableProperty.TRANSLATION).setValue(null == translation ? "" : translation);
        }

        return container;
    }
521801
public void addContainerElement(String name, CmsResource resource) {

        getContainerInfo(name).getResources().add(resource);
    }
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;
    }
720820
public String buildResourceList() throws CmsException {

        List resourcesWithProperty = getCms().readResourcesWithProperty(getParamPropertyName());

        return buildResourceList(resourcesWithProperty, false);
    }
909984
public static IndexedContainer getPrincipalContainer(
        CmsObject cms,
        List<? extends I_CmsPrincipal> list,
        String captionID,
        String descID,
        String iconID,
        String ouID,
        String icon,
        List<FontIcon> iconList) {

        IndexedContainer res = new IndexedContainer();

        res.addContainerProperty(captionID, String.class, "");
        res.addContainerProperty(ouID, String.class, "");
        res.addContainerProperty(iconID, FontIcon.class, new CmsCssIcon(icon));
        if (descID != null) {
            res.addContainerProperty(descID, String.class, "");
        }

        for (I_CmsPrincipal group : list) {

            Item item = res.addItem(group);
            item.getItemProperty(captionID).setValue(group.getSimpleName());
            item.getItemProperty(ouID).setValue(group.getOuFqn());
            if (descID != null) {
                item.getItemProperty(descID).setValue(group.getDescription(A_CmsUI.get().getLocale()));
            }
        }

        for (int i = 0; i < iconList.size(); i++) {
            res.getItem(res.getIdByIndex(i)).getItemProperty(iconID).setValue(iconList.get(i));
        }

        return res;
    }
556356
public Map<String, CmsXmlContentProperty> getElementSettings(CmsObject cms, CmsResource resource)
    throws CmsException {

        if (CmsResourceTypeXmlContent.isXmlContent(resource)) {
            Map<String, CmsXmlContentProperty> result = new LinkedHashMap<String, CmsXmlContentProperty>();
            Map<String, CmsXmlContentProperty> settings = CmsXmlContentDefinition.getContentHandlerForResource(
                cms,
                resource).getSettings(cms, resource);
            result.putAll(settings);
            return CmsXmlContentPropertyHelper.copyPropertyConfiguration(result);
        }
        return Collections.<String, CmsXmlContentProperty> emptyMap();
    }
668613
private String getSite(CmsObject cms, CmsFavoriteEntry entry) {

        CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(entry.getSiteRoot());
        Item item = m_sitesContainer.getItem(entry.getSiteRoot());
        if (item != null) {
            return (String)(item.getItemProperty("caption").getValue());
        }
        String result = entry.getSiteRoot();
        if (site != null) {
            if (!CmsStringUtil.isEmpty(site.getTitle())) {
                result = site.getTitle();
            }
        }
        return result;
    }
403207
public CmsInheritedContainerState getInheritedContainerState(CmsObject cms, CmsResource resource, String name) {

        String rootPath = resource.getRootPath();
        if (!resource.isFolder()) {
            rootPath = CmsResource.getParentFolder(rootPath);
        }
        CmsInheritedContainerState result = new CmsInheritedContainerState();
        boolean online = isOnline(cms);
        CmsContainerConfigurationCache cache = online
        ? m_onlineContainerConfigurationCache
        : m_offlineContainerConfigurationCache;
        result.addConfigurations(cache, rootPath, name);
        return result;

    }
797357
protected Panel createResourceListPanel(String caption, List<CmsResource> resources) {

        Panel result = null;
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(caption)) {
            result = new Panel();
        } else {
            result = new Panel(caption);
        }
        result.addStyleName("v-scrollable");
        result.setSizeFull();
        VerticalLayout resourcePanel = new VerticalLayout();
        result.setContent(resourcePanel);
        resourcePanel.addStyleName(OpenCmsTheme.REDUCED_MARGIN);
        resourcePanel.addStyleName(OpenCmsTheme.REDUCED_SPACING);
        resourcePanel.setSpacing(true);
        resourcePanel.setMargin(true);
        for (CmsResource resource : resources) {
            resourcePanel.addComponent(new CmsResourceInfo(resource));
        }
        return result;
    }
194991
public static I_CmsXmlContentHandler getContentHandlerForResource(CmsObject cms, CmsResource resource)
    throws CmsException {

        return getContentDefinitionForResource(cms, resource).getContentHandler();
    }