Gets beans which represents the siblings of a resource.<p>

@param cms the CMS ccontext
@param locale the locale
@param resource the resource
@return the list of sibling beans

@throws CmsException if something goes wrong
965380
protected List<CmsResourceStatusRelationBean> getSiblings(CmsObject cms, String locale, CmsResource resource)
    throws CmsException {

        List<CmsResourceStatusRelationBean> result = new ArrayList<CmsResourceStatusRelationBean>();
        for (CmsResource sibling : cms.readSiblings(resource, CmsResourceFilter.ALL)) {
            if (sibling.getStructureId().equals(resource.getStructureId())) {
                continue;
            }
            try {
                CmsPermissionInfo permissionInfo = OpenCms.getADEManager().getPermissionInfo(
                    cms,
                    sibling,
                    resource.getRootPath());
                if (permissionInfo.hasViewPermission()) {
                    CmsResourceStatusRelationBean relationBean = createRelationBean(
                        cms,
                        locale,
                        sibling,
                        permissionInfo);
                    result.add(relationBean);
                }
            } catch (CmsException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
        return result;
    }
534342
public static String getSiteSelectOptionsStatic(CmsObject cms, Locale locale) {

        List<CmsSite> sites = OpenCms.getSiteManager().getAvailableSites(
            cms,
            true,
            false,
            cms.getRequestContext().getOuFqn());

        StringBuffer resultBuffer = new StringBuffer();
        Iterator<CmsSite> i = sites.iterator();
        int counter = 0;
        while (i.hasNext()) {
            CmsSite site = i.next();
            String siteRoot = site.getSiteRoot();
            if (!siteRoot.endsWith("/")) {
                siteRoot += "/";
            }
            if (counter != 0) {
                resultBuffer.append("|");
            }
            resultBuffer.append(siteRoot).append(":").append(
                CmsWorkplace.substituteSiteTitleStatic(site.getTitle(), locale));
            counter++;
        }

        if (sites.size() < 1) {
            // no site found, assure that at least the current site is shown in the selector
            String siteRoot = cms.getRequestContext().getSiteRoot();
            CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot);
            if (!siteRoot.endsWith("/")) {
                siteRoot += "/";
            }
            String title = "";
            if (site != null) {
                title = site.getTitle();
            }
            resultBuffer.append(siteRoot).append(":").append(title);
        }
        return resultBuffer.toString();
    }
74609
public List<CmsContainerElementBean> getRecentList(CmsObject cms) throws CmsException {

        CmsUser user = cms.getRequestContext().getCurrentUser();
        Object obj = user.getAdditionalInfo(ADDINFO_ADE_RECENT_LIST);

        List<CmsContainerElementBean> recentList = new ArrayList<CmsContainerElementBean>();
        if (obj instanceof String) {
            try {
                JSONArray array = new JSONArray((String)obj);
                for (int i = 0; i < array.length(); i++) {
                    try {
                        recentList.add(elementFromJson(array.getJSONObject(i)));
                    } catch (Throwable e) {
                        // should never happen, catches wrong or no longer existing values
                        LOG.warn(e.getLocalizedMessage());
                    }
                }
            } catch (Throwable e) {
                // should never happen, catches json parsing
                LOG.warn(e.getLocalizedMessage());
            }
        } else {
            // save to be better next time
            saveRecentList(cms, recentList);
        }

        return recentList;
    }
486761
protected Set<CmsSearchField> getXSDMappings(CmsObject cms, CmsResource resource) {

        try {
            if (CmsResourceTypeXmlContent.isXmlContent(resource)) {
                I_CmsXmlContentHandler handler = CmsXmlContentDefinition.getContentHandlerForResource(cms, resource);
                if ((handler != null) && !handler.getSearchFields().isEmpty()) {
                    return handler.getSearchFields();
                }
            }
        } catch (CmsException e) {
            LOG.error(e.getMessage(), e);
        }
        return null;
    }
1061662
public List<CmsCategory> readResourceCategories(CmsObject cms, CmsResource resource) throws CmsException {

        return internalReadResourceCategories(cms, resource, false);
    }
217429
public static List<Locale> getPossibleLocales(CmsObject cms, CmsResource currentResource) {

        CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(currentResource.getRootPath());
        List<Locale> secondaryLocales = Lists.newArrayList();
        Locale mainLocale = null;
        if (site != null) {
            List<Locale> siteLocales = site.getSecondaryTranslationLocales();
            mainLocale = site.getMainTranslationLocale(null);
            if ((siteLocales == null) || siteLocales.isEmpty()) {
                siteLocales = OpenCms.getLocaleManager().getAvailableLocales();
                if (mainLocale == null) {
                    mainLocale = siteLocales.get(0);
                }
            }
            secondaryLocales.addAll(siteLocales);
        }

        try {
            CmsProperty secondaryLocaleProp = cms.readPropertyObject(
                currentResource,
                CmsPropertyDefinition.PROPERTY_SECONDARY_LOCALES,
                true);
            String propValue = secondaryLocaleProp.getValue();
            if (!CmsStringUtil.isEmptyOrWhitespaceOnly(propValue)) {
                List<Locale> restrictionLocales = Lists.newArrayList();
                String[] tokens = propValue.trim().split(" *, *"); //$NON-NLS-1$
                for (String token : tokens) {
                    OpenCms.getLocaleManager();
                    Locale localeForToken = CmsLocaleManager.getLocale(token);
                    restrictionLocales.add(localeForToken);
                }
                if (!restrictionLocales.isEmpty()) {
                    secondaryLocales.retainAll(restrictionLocales);
                }
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
        List<Locale> result = new ArrayList<Locale>();
        result.add(mainLocale);
        for (Locale secondaryLocale : secondaryLocales) {
            if (!result.contains(secondaryLocale)) {
                result.add(secondaryLocale);
            }
        }
        return result;
    }
681095
protected CmsBrokenLinkBean createSitemapBrokenLinkBean(CmsResource resource) throws CmsException {

        CmsObject cms = getCmsObject();
        CmsProperty titleProp = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, true);
        String typeName = OpenCms.getResourceManager().getResourceType(resource).getTypeName();
        String defaultTitle = "";
        String title = titleProp.getValue(defaultTitle);
        String path = cms.getSitePath(resource);
        String subtitle = path;

        CmsBrokenLinkBean result = new CmsBrokenLinkBean(resource.getStructureId(), title, subtitle, typeName);

        return result;
    }
1308770
public void setLocale(Locale locale) throws CmsException {

        CmsUserSettings settings = getSettings();
        if (settings != null) {
            settings.setLocale(locale);
            settings.save(m_cms);
            m_messages = Messages.get().getBundle(locale);
        }
    }
976131
public String[] getResourceInfo(CmsResource resource) {

        String rootPath = resource.getRootPath();
        String title = "-";

        try {
            CmsProperty titleProp = m_adminCms.readPropertyObject(
                resource,
                CmsPropertyDefinition.PROPERTY_TITLE,
                false);
            if (!titleProp.isNullProperty()) {
                title = titleProp.getValue();
            }
        } catch (CmsException e) {
            // ignore
        }
        return new String[] {rootPath, title};
    }
242104
public Map<String, String> getValues() throws CmsException {

        CmsFile file = m_cms.readFile(m_editResource);
        CmsXmlContent content = unmarshalXmlContent(file);
        Locale locale = m_cms.getRequestContext().getLocale();
        if (!content.hasLocale(locale)) {
            content.addLocale(m_cms, locale);
        }
        return getContentValues(content, locale);
    }
581697
public CmsSitemapTreeNodeData getData(CmsResource resource) {

        try {
            CmsVfsSitemapService svc = new CmsVfsSitemapService();
            CmsObject cms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
            cms.getRequestContext().setSiteRoot("");
            svc.setCms(cms);

            CmsClientSitemapEntry ent = svc.getChildren(resource.getRootPath(), resource.getStructureId(), 0);
            CmsSitemapTreeNodeData data = new CmsSitemapTreeNodeData(
                m_localeContext.getRootLocale(),
                m_localeContext.getComparisonLocale());
            data.setClientEntry(ent);
            data.initialize(cms);
            return data;
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            return null;
        }

    }
1229402
private List<CmsResource> getContents(String folderPath, String type) throws CmsException {

        CmsPathMap<CmsResource> pathMap = getPathMapForType(type);
        return pathMap.getChildValues(folderPath);
    }
108485
private CmsUgcContent readContent(CmsUgcSession session, CmsResource resource) throws CmsException {

        CmsUgcContent formContent = new CmsUgcContent();
        Map<String, String> contentValues = session.getValues();
        formContent.setContentValues(contentValues);
        formContent.setSessionId(session.getId());
        formContent.setResourceType(OpenCms.getResourceManager().getResourceType(resource).getTypeName());
        formContent.setSitePath(getCmsObject().getSitePath(resource));
        formContent.setStrucureId(resource.getStructureId());
        return formContent;
    }
205157
protected Locale getLocaleToUse(CmsObject cms, CmsXmlContent xmlContent) {

        Locale contextLocale = cms.getRequestContext().getLocale();
        if (xmlContent.hasLocale(contextLocale)) {
            return contextLocale;
        }
        Locale defaultLocale = CmsLocaleManager.getDefaultLocale();
        if (xmlContent.hasLocale(defaultLocale)) {
            return defaultLocale;
        }
        if (!xmlContent.getLocales().isEmpty()) {
            return xmlContent.getLocales().get(0);
        } else {
            return defaultLocale;
        }
    }
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);

    }
1004945
protected void fillItem(CmsObject cms, CmsResource resource, Locale locale) {

        Item resourceItem = m_container.getItem(resource.getStructureId().toString());
        if (resourceItem == null) {
            resourceItem = m_container.addItem(resource.getStructureId().toString());
        }
        fillItemDefault(resourceItem, cms, resource, locale);
        for (I_ResourcePropertyProvider provider : m_propertyProviders) {
            provider.addItemProperties(resourceItem, cms, resource, locale);
        }
    }
248542
protected void deleteRelationsWithSiblings(CmsDbContext dbc, CmsResource resource) throws CmsException {

        // get all siblings
        List<CmsResource> siblings;
        if (resource.getSiblingCount() > 1) {
            siblings = readSiblings(dbc, resource, CmsResourceFilter.ALL);
        } else {
            siblings = new ArrayList<CmsResource>();
            siblings.add(resource);
        }
        // clean the relations in content for all siblings
        I_CmsVfsDriver vfsDriver = getVfsDriver(dbc);
        Iterator<CmsResource> it = siblings.iterator();
        while (it.hasNext()) {
            CmsResource sibling = it.next();
            // clean the relation information for this sibling
            vfsDriver.deleteRelations(
                dbc,
                dbc.currentProject().getUuid(),
                sibling,
                CmsRelationFilter.TARGETS.filterDefinedInContent());
        }
    }