public int compare(CmsSite o1, CmsSite o2) { if (isSharedFolder(o1.getSiteRoot())) { return +1; } if (isSharedFolder(o2.getSiteRoot())) { return -1; } return o1.compareTo(o2); } });
/** * Constructs a new site object without title and id information, * with a site matcher generated from the provided URL.<p> * * This is to be used for test purposes only.<p> * * @param siteRoot root directory of this site in the OpenCms VFS * @param siteURL the URL to create the site matcher for this site from */ public CmsSite(String siteRoot, String siteURL) { this(siteRoot, new CmsSiteMatcher(siteURL)); }
/** * Returns the server url of this site root.<p> * * @return the server url */ public String getUrl() { return m_siteMatcher.getUrl(); }
/** * Initializes the member variables.<p> * * @param serverProtocol to protocol required to access this site * @param serverName the server URL prefix to which this site is mapped * @param serverPort the port required to access this site * @param timeOffset the time offset */ private void init(String serverProtocol, String serverName, int serverPort, long timeOffset) { setServerProtocol(serverProtocol); setServerName(serverName); setServerPort(serverPort); setTimeOffset(timeOffset); } }
/** * Returns true if this request goes to a secure site.<p> * * @param req the request to check * * @return true if the request goes to a secure site */ public boolean usesSecureSite(HttpServletRequest req) { CmsSite site = matchRequest(req); if (site == null) { return false; } CmsSiteMatcher secureMatcher = site.getSecureServerMatcher(); boolean result = false; if (secureMatcher != null) { result = secureMatcher.equals(getRequestMatcher(req)); } return result; }
/** * Returns <code>true</code> if the given request is against the configured OpenCms workplace.<p> * * @param req the request to match * * @return <code>true</code> if the given request is against the configured OpenCms workplace */ public boolean isWorkplaceRequest(HttpServletRequest req) { if (req == null) { // this may be true inside a static export test case scenario return false; } return isWorkplaceRequest(getRequestMatcher(req)); }
/** * Returns a list of all {@link CmsSite} instances that are compatible to the given organizational unit.<p> * * @param cms the current OpenCms user context * @param workplaceMode if true, the root and current site is included for the admin user * and the view permission is required to see the site root * @param ouFqn the organizational unit * * @return a list of all site available for the current user */ public List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode, String ouFqn) { return getAvailableSites(cms, workplaceMode, workplaceMode, ouFqn); }
/** * Constructs a new site matcher object.<p> * * @param serverProtocol to protocol required to access this site * @param serverName the server URL prefix to which this site is mapped * @param serverPort the port required to access this site */ public CmsSiteMatcher(String serverProtocol, String serverName, int serverPort) { init(serverProtocol, serverName, serverPort, 0); }
/** * Gets the main translation locale configured for the given root path.<p> * * @param rootPath a root path * * @return the main translation locale configured for the given path, or null if none was found */ public Locale getMainLocale(String rootPath) { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(rootPath); if (site == null) { return null; } return site.getMainTranslationLocale(null); }
/** * Returns <code>true</code> if the given site matcher matches the configured OpenCms workplace.<p> * * @param matcher the site matcher to match the site with * * @return <code>true</code> if the given site matcher matches the configured OpenCms workplace */ public boolean isWorkplaceRequest(CmsSiteMatcher matcher) { return (m_workplaceSiteMatcher != null) && m_workplaceSiteMatcher.equals(matcher); }
/** * Returns <code>true</code> if the given request is against the configured OpenCms workplace.<p> * * @param req the request to match * * @return <code>true</code> if the given request is against the configured OpenCms workplace */ public boolean isWorkplaceRequest(HttpServletRequest req) { if (req == null) { // this may be true inside a static export test case scenario return false; } return isWorkplaceRequest(getRequestMatcher(req)); }
/** * Constructs a new site matcher object.<p> * * @param serverProtocol to protocol required to access this site * @param serverName the server URL prefix to which this site is mapped * @param serverPort the port required to access this site * @param timeOffset the time offset */ public CmsSiteMatcher(String serverProtocol, String serverName, int serverPort, long timeOffset) { init(serverProtocol, serverName, serverPort, timeOffset); }
/** * Returns a clone of this Objects instance.<p> * * @return a clone of this instance */ @Override public Object clone() { return new CmsSiteMatcher(m_serverProtocol, m_serverName, m_serverPort, (m_timeOffset / 1000L)); }
/** * Returns the secure server url of this site root.<p> * * @return the secure server url */ public String getSecureUrl() { return m_secureServer.getUrl(); }
/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof CmsSite) { return (m_siteMatcher != null) && m_siteMatcher.equals(((CmsSite)obj).m_siteMatcher); } return false; }
/** * Constructs a new site matcher object.<p> * * @param serverProtocol to protocol required to access this site * @param serverName the server URL prefix to which this site is mapped * @param serverPort the port required to access this site */ public CmsSiteMatcher(String serverProtocol, String serverName, int serverPort) { init(serverProtocol, serverName, serverPort, 0); }
/** * Returns a clone of this Objects instance.<p> * * @return a clone of this instance */ @Override public Object clone() { return new CmsSiteMatcher(m_serverProtocol, m_serverName, m_serverPort, (m_timeOffset / 1000L)); }
/** * Returns the server url of this site root.<p> * * @return the server url */ public String getUrl() { return m_siteMatcher.getUrl(); }
/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof CmsSite) { ((CmsSite)obj).m_siteMatcher.equals(m_siteMatcher); } return false; }
/** * Constructs a new site matcher object.<p> * * @param serverProtocol to protocol required to access this site * @param serverName the server URL prefix to which this site is mapped * @param serverPort the port required to access this site * @param timeOffset the time offset */ public CmsSiteMatcher(String serverProtocol, String serverName, int serverPort, long timeOffset) { init(serverProtocol, serverName, serverPort, timeOffset); }