/** * Returns the adjusted site root for a resoure this context current site root.<p> * * @param resourcename the resource name to get the adjusted site root for * @return the adjusted site root for the resoure * @see #getAdjustedSiteRoot(String, String) */ public String getAdjustedSiteRoot(String resourcename) { return getAdjustedSiteRoot(m_siteRoot, resourcename); }
/** * Returns the adjusted site root for a resoure this context current site root.<p> * * @param resourcename the resource name to get the adjusted site root for * @return the adjusted site root for the resoure * @see #getAdjustedSiteRoot(String, String) */ public String getAdjustedSiteRoot(String resourcename) { return getAdjustedSiteRoot(m_siteRoot, resourcename); }
/** * Removes the report site root prefix from the absolute path in the resource name, * that is adjusts the resource name for the report site root.<p> * * If the site root for this report has not been set, * or the resource name does not start with the report site root, * the name it is left untouched.<p> * * @param resourcename the resource name (full path) * * @return the resource name adjusted for the report site root * * @see CmsRequestContext#removeSiteRoot(String) */ public String removeSiteRoot(String resourcename) { if (m_siteRoot == null) { // site root has not been set return resourcename; } String siteRoot = CmsRequestContext.getAdjustedSiteRoot(m_siteRoot, resourcename); if ((siteRoot.equals(m_siteRoot)) && resourcename.startsWith(siteRoot)) { resourcename = resourcename.substring(siteRoot.length()); } return resourcename; }
/** * Removes the report site root prefix from the absolute path in the resource name, * that is adjusts the resource name for the report site root.<p> * * If the site root for this report has not been set, * or the resource name does not start with the report site root, * the name it is left untouched.<p> * * @param resourcename the resource name (full path) * * @return the resource name adjusted for the report site root * * @see CmsRequestContext#removeSiteRoot(String) */ public String removeSiteRoot(String resourcename) { if (m_siteRoot == null) { // site root has not been set return resourcename; } String siteRoot = CmsRequestContext.getAdjustedSiteRoot(m_siteRoot, resourcename); if ((siteRoot.equals(m_siteRoot)) && resourcename.startsWith(siteRoot)) { resourcename = resourcename.substring(siteRoot.length()); } return resourcename; }
/** * Removes the current site root prefix from the absolute path in the resource name, * that is adjusts the resource name for the current site root.<p> * * If the resource name does not start with the current site root, * it is left untouched.<p> * * @param resourcename the resource name * * @return the resource name adjusted for the current site root * * @see #getSitePath(CmsResource) */ public String removeSiteRoot(String resourcename) { String siteRoot = getAdjustedSiteRoot(m_siteRoot, resourcename); if ((siteRoot == m_siteRoot) && resourcename.startsWith(siteRoot) && ((resourcename.length() == siteRoot.length()) || (resourcename.charAt(siteRoot.length()) == '/'))) { resourcename = resourcename.substring(siteRoot.length()); } return resourcename; }
/** * Removes the current site root prefix from the absolute path in the resource name, * that is adjusts the resource name for the current site root.<p> * * If the resource name does not start with the current site root, * it is left untouched.<p> * * @param resourcename the resource name * * @return the resource name adjusted for the current site root * * @see #getSitePath(CmsResource) */ public String removeSiteRoot(String resourcename) { String siteRoot = getAdjustedSiteRoot(m_siteRoot, resourcename); if ((siteRoot == m_siteRoot) && resourcename.startsWith(siteRoot) && ((resourcename.length() == siteRoot.length()) || (resourcename.charAt(siteRoot.length()) == '/'))) { resourcename = resourcename.substring(siteRoot.length()); } if (resourcename.length() == 0) { // input was a site root folder without trailing slash resourcename = "/"; } return resourcename; }
/** * Adds the given site root of this context to the given resource name, * taking into account special folders like "/system" where no site root must be added, * and also translates the resource name with the configured the directory translator.<p> * * @param siteRoot the site root to add * @param resourcename the resource name * @return the translated resource name including site root */ public String addSiteRoot(String siteRoot, String resourcename) { if ((resourcename == null) || (siteRoot == null)) { return null; } siteRoot = getAdjustedSiteRoot(siteRoot, resourcename); StringBuffer result = new StringBuffer(128); result.append(siteRoot); if (((siteRoot.length() == 0) || (siteRoot.charAt(siteRoot.length() - 1) != '/')) && ((resourcename.length() == 0) || (resourcename.charAt(0) != '/'))) { // add slash between site root and resource if required result.append('/'); } result.append(resourcename); return m_directoryTranslator.translateResource(result.toString()); }
/** * Adds the given site root of this context to the given resource name, * taking into account special folders like "/system" where no site root must be added, * and also translates the resource name with the configured the directory translator.<p> * * @param siteRoot the site root to add * @param resourcename the resource name * @return the translated resource name including site root */ public String addSiteRoot(String siteRoot, String resourcename) { if ((resourcename == null) || (siteRoot == null)) { return null; } siteRoot = getAdjustedSiteRoot(siteRoot, resourcename); StringBuffer result = new StringBuffer(128); result.append(siteRoot); if (((siteRoot.length() == 0) || (siteRoot.charAt(siteRoot.length() - 1) != '/')) && ((resourcename.length() == 0) || (resourcename.charAt(0) != '/'))) { // add slash between site root and resource if required result.append('/'); } result.append(resourcename); return m_directoryTranslator.translateResource(result.toString()); }