/** * Gets the name of the parent folder of the requested file.<p> * * @return the name of the parent folder of the requested file */ public String getFolderUri() { return CmsResource.getFolderPath(m_uri); }
/** * Gets the name of the parent folder of the requested file.<p> * * @return the name of the parent folder of the requested file */ public String getFolderUri() { return CmsResource.getFolderPath(m_uri); }
/** * @see org.opencms.search.I_CmsSearchDocument#addPathField(java.lang.String) */ public void addPathField(String rootPath) { String folderName = CmsResource.getFolderPath(rootPath); for (int i = 0; i < folderName.length(); i++) { char c = folderName.charAt(i); if (c == '/') { m_doc.addField(CmsSearchField.FIELD_PARENT_FOLDERS, folderName.substring(0, i + 1)); } } }
/** * Initializes this bean.<p> * * @param cms the current cms context * @param locale the locale for which properties should be read */ public void init(CmsObject cms, Locale locale) { m_cms = cms; m_locale = locale; m_requestUri = m_cms.getRequestContext().getUri(); m_requestUriFolder = CmsResource.getFolderPath(m_requestUri); }
/** * Returns the current explorer path for use in Javascript of new sibling dialog.<p> * * @return the current explorer path */ public String getCurrentPath() { String path = getSettings().getExplorerResource(); if (path == null) { path = "/"; } return CmsResource.getFolderPath(path); }
/** * Initiliazes this bean.<p> * * @param cms context provider for the current request */ public void init(CmsObject cms) { m_cms = cms; m_requestUri = m_cms.getRequestContext().getUri(); m_requestUriFolder = CmsResource.getFolderPath(m_requestUri); } }
/** * Returns the current folder set as URI in the request context.<p> * * @return the current folder * @throws Exception if something goes wrong * @see org.opencms.file.CmsRequestContext#getUri() * @see CmsResource#getFolderPath(String) */ public String pwd() throws Exception { return CmsResource.getFolderPath(m_cms.getRequestContext().getUri()); }
/** * Returns the current folder set as URI in the request context.<p> * * @return the current folder * @throws Exception if something goes wrong * @see org.opencms.file.CmsRequestContext#getUri() * @see CmsResource#getFolderPath(String) */ public String pwd() throws Exception { return CmsResource.getFolderPath(m_cms.getRequestContext().getUri()); }
/** * Returns the current explorer path for use in Javascript of new sibling dialog.<p> * * @return the current explorer path */ public String getCurrentPath() { String path = getSettings().getExplorerResource(); if (path == null) { path = "/"; } return CmsResource.getFolderPath(path); }
/** * Displays a list of all resources in the current folder.<p> * * @throws Exception if something goes wrong * @see CmsObject#getResourcesInFolder(String, CmsResourceFilter) */ public void ls() throws Exception { String folder = CmsResource.getFolderPath(m_cms.getRequestContext().getUri()); List resources = m_cms.getResourcesInFolder(folder, CmsResourceFilter.IGNORE_EXPIRATION); System.out.println("\n" + getMessages().key(Messages.GUI_SHELL_LS_2, folder, new Integer(resources.size()))); Iterator i = resources.iterator(); while (i.hasNext()) { CmsResource r = (CmsResource)i.next(); System.out.println(m_cms.getSitePath(r)); } System.out.println(); }
/** * Creates the parent folder for a exported resource in the RFS.<p> * * @param exportPath the path to export the file * @param rfsName the rfs name of the resource * * @throws CmsException if the folder could not be created */ protected void createExportFolder(String exportPath, String rfsName) throws CmsException { String exportFolderName = CmsFileUtil.normalizePath(exportPath + CmsResource.getFolderPath(rfsName)); File exportFolder = new File(exportFolderName); if (!exportFolder.exists()) { // in case of concurrent requests to create this folder, check the folder existence again if (!exportFolder.mkdirs() && !exportFolder.exists()) { throw new CmsStaticExportException(Messages.get().container(Messages.ERR_CREATE_FOLDER_1, rfsName)); } } }
/** * Creates the parent folder for a exported resource in the RFS.<p> * * @param exportPath the path to export the file * @param rfsName the rfs name of the resource * * @throws CmsException if the folder could not be created */ protected void createExportFolder(String exportPath, String rfsName) throws CmsException { String exportFolderName = CmsFileUtil.normalizePath(exportPath + CmsResource.getFolderPath(rfsName)); File exportFolder = new File(exportFolderName); if (!exportFolder.exists()) { if (!exportFolder.mkdirs()) { throw new CmsStaticExportException(Messages.get().container(Messages.ERR_CREATE_FOLDER_1, rfsName)); } } }
/** * Sets the parent path to read visited resources from using the given resource as parent.<p> * * @param parentResource the resource to use as parent resource */ public void setParentResource(CmsResource parentResource) { if (parentResource.isFile()) { m_parentPath = CmsResource.getFolderPath(parentResource.getRootPath()); } else { m_parentPath = parentResource.getRootPath(); } }
/** * Displays a list of all resources in the current folder.<p> * * @throws Exception if something goes wrong * @see CmsObject#getResourcesInFolder(String, CmsResourceFilter) */ public void ls() throws Exception { String folder = CmsResource.getFolderPath(m_cms.getRequestContext().getUri()); List<CmsResource> resources = m_cms.getResourcesInFolder(folder, CmsResourceFilter.IGNORE_EXPIRATION); m_shell.getOut().println( "\n" + getMessages().key(Messages.GUI_SHELL_LS_2, folder, new Integer(resources.size()))); Iterator<CmsResource> i = resources.iterator(); while (i.hasNext()) { CmsResource r = i.next(); m_shell.getOut().println(m_cms.getSitePath(r)); } m_shell.getOut().println(); }
/** * Returns the selected files contentsls as a String.<p> * * @param filename the file to read the contents from * @throws CmsException if something goes wrong * @return the selected files contents */ public String readFileContent(String filename) throws CmsException { filename = CmsLinkManager.getAbsoluteUri( filename, CmsResource.getFolderPath(m_cms.getRequestContext().getUri())); CmsFile file = m_cms.readFile(filename, CmsResourceFilter.IGNORE_EXPIRATION); return new String(file.getContents()); }
/** * Returns the selected files contentsls as a String.<p> * * @param filename the file to read the contents from * @throws CmsException if something goes wrong * @return the selected files contents */ public String readFileContent(String filename) throws CmsException { filename = CmsLinkManager.getAbsoluteUri( filename, CmsResource.getFolderPath(m_cms.getRequestContext().getUri())); CmsFile file = m_cms.readFile(filename, CmsResourceFilter.IGNORE_EXPIRATION); return new String(file.getContents()); }
/** * Initializes the gallery dialog before redirecting.<p> * * @param wp the workplace object */ public static void initGallery(CmsDialog wp) { // 1. get "gallerytypename" by reading the folderpath String galleryTypeName = null; if (wp.useNewStyle()) { galleryTypeName = CmsResource.getName(CmsResource.getFolderPath(wp.getAdminTool().getHandler().getLink())); } else { galleryTypeName = CmsResource.getName(CmsResource.getFolderPath(wp.getJsp().getRequestContext().getUri())); } if (galleryTypeName.endsWith("/")) { galleryTypeName = galleryTypeName.substring(0, galleryTypeName.length() - 1); } if (!galleryTypeName.equals("commons")) { // 2. set in user settings wp.getSettings().setGalleryType(galleryTypeName); } }
/** * Renames the vfs resource bundle files within the target module according to the new module's name.<p> * * @param resources the vfs resource bundle files * @param targetModule the target module * @param name the package name of the source module * * @return a list of all xml vfs bundles within the given module * @throws CmsException if something gows wrong */ private List<CmsResource> renameXmlVfsBundles(List<CmsResource> resources, CmsModule targetModule, String name) throws CmsException { for (CmsResource res : resources) { String newName = res.getName().replaceAll(name, targetModule.getName()); String targetRootPath = CmsResource.getFolderPath(res.getRootPath()) + newName; if (!getCms().existsResource(targetRootPath)) { getCms().moveResource(res.getRootPath(), targetRootPath); } } return resources; }
/** * Sets the title of the dialog depending on the operation type, multiple or single operation.<p> * * @param singleKey the key for the single operation * @param multiKey the key for the multiple operation */ public void setDialogTitle(String singleKey, String multiKey) { if (isMultiOperation()) { // generate title with number of selected resources and parent folder parameters String resCount = String.valueOf(getResourceList().size()); String currentFolder = CmsResource.getFolderPath(getSettings().getExplorerResource()); currentFolder = CmsStringUtil.formatResourceName(currentFolder, 40); Object[] params = new Object[] {resCount, currentFolder}; setParamTitle(key(multiKey, params)); } else { // generate title using the resource name as parameter for the key String resourceName = CmsStringUtil.formatResourceName(getParamResource(), 50); setParamTitle(key(singleKey, new Object[] {resourceName})); } }
/** * Sets the title of the dialog depending on the operation type, multiple or single operation.<p> * * @param singleKey the key for the single operation * @param multiKey the key for the multiple operation */ public void setDialogTitle(String singleKey, String multiKey) { if (isMultiOperation()) { // generate title with number of selected resources and parent folder parameters String resCount = String.valueOf(getResourceList().size()); String currentFolder = CmsResource.getFolderPath(getSettings().getExplorerResource()); currentFolder = CmsStringUtil.formatResourceName(currentFolder, 40); Object[] params = new Object[] {resCount, currentFolder}; setParamTitle(key(multiKey, params)); } else { // generate title using the resource name as parameter for the key String resourceName = CmsStringUtil.formatResourceName(getParamResource(), 50); setParamTitle(key(singleKey, new Object[] {resourceName})); } }