/** * Creates an xpath from the given components.<p> * * @param components the xpath componentns * * @return the composed xpath */ public static String path(String... components) { return CmsStringUtil.joinPaths(components); }
/** * Checks if a path matches another part.<p> * * This is basically an equality test, but ignores the presence/absence of trailing slashes. * * @param expected the expected path * @param actual the actual path * @return true if the actual path matches the expected path */ private boolean matchPath(String expected, String actual) { return CmsStringUtil.joinPaths(actual, "/").equals(CmsStringUtil.joinPaths(expected, "/")); } }
/** * Checks if the given path is that of a shared folder.<p> * * @param name a path prefix * * @return true if the given prefix represents a shared folder */ public boolean isSharedFolder(String name) { return (m_sharedFolder != null) && m_sharedFolder.equals(CmsStringUtil.joinPaths("/", name, "/")); }
/** * Gets the path to the XSLT transformation file that should be used for the configuration.<p> * * @return the path to the XSLT transformation */ String getTransformationPath() { String path = System.getProperty("opencms.config.transform"); if (path == null) { path = CmsStringUtil.joinPaths(m_baseFolder.getAbsolutePath(), DEFAULT_XSLT_FILENAME); } return path; }
/** * Computes the relative path given an ancestor folder path.<p> * * @param ancestor the ancestor folder * @param rootPath the path for which the relative path should be computed * * @return the relative path */ protected String getRelativePath(String ancestor, String rootPath) { String result = rootPath.substring(ancestor.length()); result = CmsStringUtil.joinPaths("/", result, "/"); return result; }
/** * Prefixes a simple name with an OU.<p> * * @param ou the OU to use as a prefix * @param principal the simple name to which the OU should be prepended * * @return the FQN */ public static String prefixWithOu(String ou, String principal) { String result = CmsStringUtil.joinPaths(ou, principal); if (result.startsWith("/")) { result = result.substring(1); } return result; }
/** * Checks whether a given root path is a site root.<p> * * @param rootPath a root path * * @return true if the given path is the path of a site root */ public boolean isSiteRoot(String rootPath) { String siteRoot = getSiteRoot(rootPath); rootPath = CmsStringUtil.joinPaths(rootPath, "/"); return rootPath.equals(siteRoot); }
/** * Creates a new path value with the same value as this one, but with a prefix prepended to the path.<p> * * @param pathPart the path part which should be prepended to the path * * @return the new path value */ public CmsPathValue prepend(String pathPart) { return new CmsPathValue(m_value, CmsStringUtil.joinPaths(pathPart, m_path)); }
/** * Gets the content folder path.<p> * * For example, if the configuration file is located at /sites/default/.content/.config, the content folder path is /sites/default/.content * * @return the content folder path */ public String getContentFolderPath() { return CmsStringUtil.joinPaths(m_data.getBasePath(), CmsADEManager.CONTENT_FOLDER_NAME); }
/** * Returns the context path for embedded dialogs.<p> * * @return the context path for embedded dialogs */ public static String getEmbeddedDialogsContextPath() { return CmsStringUtil.joinPaths(OpenCms.getSystemInfo().getWorkplaceContext(), DIALOGS_PATH); }
/** * Gets the link to an image below the img-extra folder.<p> * * @param imagePath the image path below img-extra * * @return the complete image link */ public static String getImageLink(String imagePath) { return CmsStringUtil.joinPaths( OpenCms.getSystemInfo().getContextPath(), "VAADIN/themes/opencms/img-extra", imagePath); }
/** * Gets the link to the (new) workplace.<p> * * @return the link to the workplace */ public static String getWorkplaceLink() { return CmsStringUtil.joinPaths("/", OpenCms.getSystemInfo().getContextPath(), "workplace"); }
/** * Inserts the given entry at the given position.<p> * * @param entry the entry to insert * @param position the position * @param controller a sitemap controller instance */ public void insertSubEntry(CmsClientSitemapEntry entry, int position, I_CmsSitemapController controller) { entry.updateSitePath(CmsStringUtil.joinPaths(m_sitePath, entry.getName()), controller); m_subEntries.add(position, entry); updatePositions(position); }
/** * Sets the shared folder path.<p> * * @param sharedFolder the shared folder path */ public void setSharedFolder(String sharedFolder) { if (m_frozen) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_CONFIG_FROZEN_0)); } m_sharedFolder = CmsStringUtil.joinPaths("/", sharedFolder, "/"); }
/** * Adds the given entry to the children.<p> * * @param entry the entry to add * @param controller a sitemap controller instance */ public void addSubEntry(CmsClientSitemapEntry entry, I_CmsSitemapController controller) { entry.setPosition(m_subEntries.size()); entry.updateSitePath(CmsStringUtil.joinPaths(m_sitePath, entry.getName()), controller); entry.setFolderDefaultPage(entry.isLeafType() && getVfsPath().equals(entry.getVfsPath())); m_subEntries.add(entry); }
/** * Returns the URI to static resources served from the class path.<p> * * @param resourceName the resource name * @param versionInfo add an additional version info parameter to avoid browser caching issues * * @return the URI */ public static String getStaticResourceUri(String resourceName, String versionInfo) { resourceName = CmsStaticResourceHandler.removeStaticResourcePrefix(resourceName); String uri = CmsStringUtil.joinPaths(OpenCms.getSystemInfo().getStaticResourceContext(), resourceName); if (versionInfo != null) { uri += "?v=" + versionInfo; } return uri; }
/** * Returns the path to the associated detail content.<p> * * @param detailContainersPage the detail containers page path * * @return the path to the associated detail content */ public static String getDetailContentPath(String detailContainersPage) { String detailName = CmsResource.getName(detailContainersPage); String parentFolder = CmsResource.getParentFolder(CmsResource.getParentFolder(detailContainersPage)); if (parentFolder.endsWith("/" + DETAIL_CONTAINERS_FOLDER_NAME + "/")) { // this will be the case for locale dependent detail only pages, move one level up parentFolder = CmsResource.getParentFolder(parentFolder); } detailName = CmsStringUtil.joinPaths(parentFolder, detailName); return detailName; }
/** * Returns the new resource site path.<p> * * @return the new resource site path * @throws CmsException if something goes wrong */ private String getNewContentName() throws CmsException { String sitePath = OpenCms.getResourceManager().getNameGenerator().getNewFileName( m_cms, CmsStringUtil.joinPaths( m_cms.getRequestContext().removeSiteRoot(m_configuration.getContentParentFolder().getRootPath()), m_configuration.getNamePattern()), 5); return sitePath; }
/** * @see org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapService#removeModelPage(java.lang.String, org.opencms.util.CmsUUID) */ public void removeModelPage(String entryPointUri, CmsUUID id) throws CmsRpcException { try { CmsObject cms = getCmsObject(); CmsResource rootResource = cms.readResource(entryPointUri); CmsModelPageHelper helper = new CmsModelPageHelper(getCmsObject(), rootResource); String configPath = CmsStringUtil.joinPaths(entryPointUri, ".content/.config"); CmsResource configResource = cms.readResource(configPath); helper.removeModelPage(configResource, id); OpenCms.getADEManager().waitForCacheUpdate(false); } catch (Throwable e) { error(e); } }
/** The dialog mode. */ public static enum DialogMode { /** Allow copy only. */ copy, /** Allow copy and move. */ copy_and_move, /** Allow move only. */ move }