/** * Constructor, only package visible.<p> */ CmsWorkplaceSettings() { m_explorerPage = 1; m_explorerResource = new HashMap<String, String>(); m_treeType = new HashMap<String, String>(); m_treeSite = new HashMap<String, String>(); m_frameUris = new HashMap<String, String>(); m_lastUsedGalleries = new HashMap<String, String>(); m_currentSite = OpenCms.getSiteManager().getDefaultSite().getSiteRoot(); }
/** * Returns a clone of this Objects instance.<p> * * @return a clone of this instance */ @Override public Object clone() { return new CmsSite( getSiteRoot(), (CmsUUID)getSiteRootUUID().clone(), getTitle(), (CmsSiteMatcher)getSiteMatcher().clone(), String.valueOf(getPosition())); }
/** * Constructor, only package visible.<p> */ CmsWorkplaceSettings() { m_explorerPage = 1; m_explorerResource = new HashMap(); m_treeType = new HashMap(); m_treeSite = new HashMap(); m_frameUris = new HashMap(); m_lastUsedGalleries = new HashMap(); m_currentSite = OpenCms.getSiteManager().getDefaultSite().getSiteRoot(); }
/** * Returns a clone of this Objects instance.<p> * * @return a clone of this instance */ @Override public Object clone() { return new CmsSite( getSiteRoot(), (CmsUUID)getSiteRootUUID().clone(), getTitle(), (CmsSiteMatcher)getSiteMatcher().clone(), String.valueOf(getPosition()), getErrorPage(), getSecureServer(), isExclusiveUrl(), isExclusiveError(), isWebserver(), getAliases()); }
public int compare(CmsSite o1, CmsSite o2) { if (isSharedFolder(o1.getSiteRoot())) { return +1; } if (isSharedFolder(o2.getSiteRoot())) { return -1; } return o1.compareTo(o2); } });
/** * Checks if the link target is a secure link.<p * * @param cms the current CMS context * @param vfsName the path of the link target * @param targetSite the target site containing the detail page * @param secureRequest true if the currently running request is secure * * @return true if the link should be a secure link */ protected boolean isSecureLink(CmsObject cms, String vfsName, CmsSite targetSite, boolean secureRequest) { return OpenCms.getStaticExportManager().isSecureLink(cms, vfsName, targetSite.getSiteRoot(), secureRequest); }
public int rank(CmsResourceStatusRelationBean r) { if (m_rankCache.containsKey(r.getSiteRoot())) { return m_rankCache.get(r.getSiteRoot()).intValue(); } int j = 0; int result = Integer.MAX_VALUE; for (CmsSite site : sites) { if (site.getSiteRoot().equals(r.getSiteRoot())) { result = j; break; } j += 1; } m_rankCache.put(r.getSiteRoot(), new Integer(result)); return result; } });
/** * Returns the site root part for the given resources root path, * or <code>null</code> if the given resources root path does not match any site root.<p> * * The site root returned will have the form: * <code>/sites/default</code>.<br> * That means there will a leading, but no trailing slash.<p> * * @param rootPath the root path of a resource * * @return the site root part of the resources root path, * or <code>null</code> if the path does not match any site root * * @see #getSiteForRootPath(String) */ public String getSiteRoot(String rootPath) { // add a trailing slash, because the path may be the path of a site root itself if (!rootPath.endsWith("/")) { rootPath = rootPath + "/"; } // most sites will be below the "/sites/" folder, CmsSite site = lookupSitesFolder(rootPath); if (site != null) { return site.getSiteRoot(); } // look through all folders that are not below "/sites/" return lookupAdditionalSite(rootPath); }
/** * Returns a html select box filled with the current users accessible sites.<p> * * @param htmlAttributes attributes that will be inserted into the generated html * @return a html select box filled with the current users accessible sites */ public String getSiteSelect(String htmlAttributes) { List options = new ArrayList(); List values = new ArrayList(); int selectedIndex = 0; List sites = OpenCms.getSiteManager().getAvailableSites(getCms(), true); Iterator i = sites.iterator(); int pos = 0; while (i.hasNext()) { CmsSite site = (CmsSite)i.next(); values.add(site.getSiteRoot()); options.add(site.getTitle()); if (site.getSiteRoot().equals(getSettings().getSite())) { // this is the user's current site selectedIndex = pos; } pos++; } return buildSelect(htmlAttributes, options, values, selectedIndex); }
/** * Returns the site root part for the given resources root path, * or <code>null</code> if the given resources root path does not match any site root.<p> * * The site root returned will have the form: * <code>/sites/default</code>.<br> * That means there will a leading, but no trailing slash.<p> * * @param rootPath the root path of a resource * * @return the site root part of the resources root path, * or <code>null</code> if the path does not match any site root * * @see #getSiteForRootPath(String) */ public String getSiteRoot(String rootPath) { // most sites will be below the "/sites/" folder, CmsSite site = lookupSitesFolder(rootPath); if (site != null) { return site.getSiteRoot(); } // look through all folders that are not below "/sites/" return lookupAdditionalSite(rootPath); }
/** * @see org.opencms.staticexport.CmsDefaultLinkSubstitutionHandler#getRootPathForSite(org.opencms.file.CmsObject, java.lang.String, java.lang.String, boolean) */ @Override protected String getRootPathForSite(CmsObject cms, String path, String siteRoot, boolean isRootPath) { CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot); if ((site != null) && CmsSite.LocalizationMode.singleTree.equals(site.getLocalizationMode())) { if (isRootPath) { path = path.substring(site.getSiteRoot().length()); } Locale locale = CmsSingleTreeLocaleHandler.getLocaleFromPath(path); if (locale != null) { path = path.substring(locale.toString().length() + 1); } return cms.getRequestContext().addSiteRoot(site.getSiteRoot(), path); } else { return super.getRootPathForSite(cms, path, siteRoot, isRootPath); } }
/** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(CmsExportname o1, CmsExportname o2) { if (((o1.getSite() == null) && (o2.getSite() == null)) || ((o1.getSite() == null) && (o2.getSite() != null)) || ((o1.getSite() != null) && (o2.getSite() == null)) || o1.getSite().getSiteRoot().equals(o2.getSite().getSiteRoot())) { return m_comp.compare(o1.getExportname(), o2.getExportname()); } else { int siteComp = o1.getSite().getSiteRoot().compareTo(o2.getSite().getSiteRoot()); if (siteComp == 0) { return m_comp.compare(o1.getExportname(), o2.getExportname()); } return siteComp; } } }
/** * Checks whether the given detail page is valid for the given resource.<p> * * @param cms the CMS context * @param page the detail page * @param detailRes the detail resource * * @return true if the given detail page is valid */ 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); } }
/** * @see org.opencms.ui.components.fileselect.A_CmsFileSelectField#setResourceValue(org.opencms.file.CmsResource) */ @Override protected void setResourceValue(CmsResource resource) { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(resource.getRootPath()); if (!m_useRootPaths && (site != null) && A_CmsUI.getCmsObject().getRequestContext().getSiteRoot().equals(site.getSiteRoot())) { setValue(true, A_CmsUI.getCmsObject().getSitePath(resource)); } else { setValue(true, resource.getRootPath()); } }
cms.getRequestContext().setSiteRoot(errorSite.getSiteRoot()); String relPath = cms.getRequestContext().removeSiteRoot(rootPath); if (cms.existsResource(relPath)) {
/** * Returns the workplace link.<p> * * @param cms the cms context * @param resourceRootFolder the resource folder root path * * @return the workplace link */ public static String getVaadinWorkplaceLink(CmsObject cms, String resourceRootFolder) { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(resourceRootFolder); String siteRoot = site != null ? site.getSiteRoot() : OpenCms.getSiteManager().startsWithShared(resourceRootFolder) ? OpenCms.getSiteManager().getSharedFolder() : ""; String link = getFileExplorerLink(cms, siteRoot) + cms.getRequestContext().removeSiteRoot(resourceRootFolder); return link; }
/** * Creates a new sitemap generator instance.<p> * * @param folderRootPath the root folder for the XML sitemap to generate * * @throws CmsException if something goes wrong */ public CmsXmlSitemapGenerator(String folderRootPath) throws CmsException { m_baseFolderRootPath = CmsFileUtil.removeTrailingSeparator(folderRootPath); m_guestCms = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest()); m_siteGuestCms = OpenCms.initCmsObject(m_guestCms); CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(CmsStringUtil.joinPaths(folderRootPath, "/")); m_siteRoot = site.getSiteRoot(); m_siteGuestCms.getRequestContext().setSiteRoot(m_siteRoot); m_baseFolderSitePath = CmsStringUtil.joinPaths( "/", m_siteGuestCms.getRequestContext().removeSiteRoot(m_baseFolderRootPath)); }
/** * Returns the CMS object.<p> * * @param req the request * * @return the CMS object * * @throws CmsException if something goes wrong */ protected CmsObject getCmsObject(HttpServletRequest req) throws CmsException { CmsObject cms = OpenCmsCore.getInstance().initCmsObjectFromSession(req); // use the guest user as fall back if (cms == null) { cms = OpenCmsCore.getInstance().initCmsObject(OpenCms.getDefaultUsers().getUserGuest()); String siteRoot = OpenCmsCore.getInstance().getSiteManager().matchRequest(req).getSiteRoot(); cms.getRequestContext().setSiteRoot(siteRoot); } String baseUri = getBaseUri(req, cms); if (baseUri != null) { cms.getRequestContext().setUri(baseUri); } return cms; }
/** * Returns the CMS object.<p> * * @param req the request * * @return the CMS object * * @throws CmsException if something goes wrong */ protected CmsObject getCmsObject(HttpServletRequest req) throws CmsException { CmsObject cms = OpenCmsCore.getInstance().initCmsObjectFromSession(req); // use the guest user as fall back if (cms == null) { cms = OpenCmsCore.getInstance().initCmsObject(OpenCms.getDefaultUsers().getUserGuest()); String siteRoot = OpenCmsCore.getInstance().getSiteManager().matchRequest(req).getSiteRoot(); cms.getRequestContext().setSiteRoot(siteRoot); } String baseUri = getBaseUri(req, cms); if (baseUri != null) { cms.getRequestContext().setUri(baseUri); } return cms; }
/** * @see org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapService#prepareReloadSitemap(org.opencms.util.CmsUUID, org.opencms.ade.sitemap.shared.CmsSitemapData.EditorMode) */ public String prepareReloadSitemap(CmsUUID rootId, EditorMode mode) throws CmsRpcException { try { CmsObject cms = getCmsObject(); CmsResource res = cms.readResource(CmsADEManager.PATH_SITEMAP_EDITOR_JSP); CmsResource target = cms.readResource(rootId, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED); String targetRootPath = OpenCms.getADEManager().getSubSiteRoot(cms, target.getRootPath()); CmsSite targetSite = OpenCms.getSiteManager().getSiteForRootPath(targetRootPath); CmsADESessionCache.getCache(getRequest(), getCmsObject()).setSitemapEditorMode(mode); if (targetSite != null) { cms.getRequestContext().setSiteRoot(targetSite.getSiteRoot()); String path = cms.getRequestContext().removeSiteRoot(targetRootPath); String link = OpenCms.getLinkManager().substituteLink(cms, res); link = link + "?path=" + path; return link; } return null; } catch (Exception e) { error(e); return null; } }