/** * @see org.opencms.repository.I_CmsRepositorySession#list(java.lang.String) */ public List list(String path) throws CmsException { List ret = new ArrayList(); path = validatePath(path); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_LIST_ITEMS_1, path)); } List resources = m_cms.getResourcesInFolder(path, CmsResourceFilter.DEFAULT); Iterator iter = resources.iterator(); while (iter.hasNext()) { CmsResource res = (CmsResource)iter.next(); if (!isFiltered(m_cms.getRequestContext().removeSiteRoot(res.getRootPath()))) { // open the original resource (for virtual files this is the resource in the VFS // which the virtual resource is based on) // this filters e.g. property files for resources that are filtered out and thus // should not be displayed CmsResource org = m_cms.readResource(res.getStructureId(), CmsResourceFilter.DEFAULT); if (!isFiltered(m_cms.getRequestContext().removeSiteRoot(org.getRootPath()))) { ret.add(new CmsRepositoryItem(res, m_cms)); } } } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_LIST_ITEMS_SUCESS_1, new Integer(ret.size()))); } return ret; }
/** * @see org.opencms.repository.I_CmsRepositorySession#list(java.lang.String) */ public List<I_CmsRepositoryItem> list(String path) throws CmsException { List<I_CmsRepositoryItem> ret = new ArrayList<I_CmsRepositoryItem>(); path = validatePath(path); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_LIST_ITEMS_1, path)); } List<CmsResource> resources = m_cms.getResourcesInFolder(path, CmsResourceFilter.DEFAULT); Iterator<CmsResource> iter = resources.iterator(); while (iter.hasNext()) { CmsResource res = iter.next(); if (!isFiltered(m_cms.getRequestContext().removeSiteRoot(res.getRootPath()))) { // open the original resource (for virtual files this is the resource in the VFS // which the virtual resource is based on) // this filters e.g. property files for resources that are filtered out and thus // should not be displayed CmsResource org = m_cms.readResource(res.getStructureId(), CmsResourceFilter.DEFAULT); if (!isFiltered(m_cms.getRequestContext().removeSiteRoot(org.getRootPath()))) { ret.add(new CmsRepositoryItem(res, m_cms)); } } } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_LIST_ITEMS_SUCESS_1, new Integer(ret.size()))); } return ret; }
/** * Validates (translates) the given path and checks if it is filtered out.<p> * * @param path the path to validate * * @return the validated path * * @throws CmsSecurityException if the path is filtered out */ private String validatePath(String path) throws CmsSecurityException { // Problems with spaces in new folders (default: "Neuer Ordner") // Solution: translate this to a correct name. String ret = m_cms.getRequestContext().getFileTranslator().translateResource(path); // add site root only works correct if system folder ends with a slash if (CmsResource.VFS_FOLDER_SYSTEM.equals(ret)) { ret = ret.concat("/"); } // filter path if (isFiltered(ret)) { throw new CmsSecurityException(Messages.get().container(Messages.ERR_ITEM_FILTERED_1, path)); } return ret; } }
/** * Validates (translates) the given path and checks if it is filtered out.<p> * * @param path the path to validate * * @return the validated path * * @throws CmsSecurityException if the path is filtered out */ private String validatePath(String path) throws CmsSecurityException { // Problems with spaces in new folders (default: "Neuer Ordner") // Solution: translate this to a correct name. String ret = m_cms.getRequestContext().getFileTranslator().translateResource(path); // add site root only works correct if system folder ends with a slash if (CmsResource.VFS_FOLDER_SYSTEM.equals(ret)) { ret = ret.concat("/"); } // filter path if (isFiltered(ret)) { throw new CmsSecurityException(Messages.get().container(Messages.ERR_ITEM_FILTERED_1, path)); } return ret; } }