/** * Reads the category identified by the given category path.<p> * * This method will only lookup in the centralized repository.<p> * * @param cms the current cms context * @param categoryPath the path of the category to read * * @return the category * * @throws CmsException if something goes wrong * * @deprecated use {@link #readCategory(CmsObject, String, String)} instead */ public CmsCategory readCategory(CmsObject cms, String categoryPath) throws CmsException { return getCategory(cms, internalCategoryRootPath(CmsCategoryService.CENTRALIZED_REPOSITORY, categoryPath)); }
try { cats.addAll( internalReadSubCategories(cms, internalCategoryRootPath(repository, catPath), includeSubCats)); } catch (CmsVfsResourceNotFoundException e) {
/** * Reads all categories identified by the given category path for the given reference path.<p> * * @param cms the current cms context * @param categoryPath the path of the category to read * @param referencePath the reference path to find all the category repositories * * @return a list of matching categories, could also be empty, if no category exists with the given path * * @throws CmsException if something goes wrong */ public CmsCategory readCategory(CmsObject cms, String categoryPath, String referencePath) throws CmsException { // iterate all possible category repositories, starting with the most global one Iterator<String> it = getCategoryRepositories(cms, referencePath).iterator(); while (it.hasNext()) { String repository = it.next(); try { return getCategory(cms, internalCategoryRootPath(repository, categoryPath)); } catch (CmsVfsResourceNotFoundException e) { // throw the exception if no repository left if (!it.hasNext()) { throw e; } } } // this will never be executed return null; }
/** * Reads all categories identified by the given category path for the given reference path.<p> * * @param cms the current cms context * @param categoryPath the path of the category to read * @param referencePath the reference path to find all the category repositories * * @return a list of matching categories, could also be empty, if no category exists with the given path * * @throws CmsException if something goes wrong */ public CmsCategory readCategory(CmsObject cms, String categoryPath, String referencePath) throws CmsException { // iterate all possible category repositories, starting with the most global one Iterator it = getCategoryRepositories(cms, referencePath).iterator(); while (it.hasNext()) { String repository = (String)it.next(); try { return getCategory(cms, internalCategoryRootPath(repository, categoryPath)); } catch (CmsVfsResourceNotFoundException e) { // throw the exception if no repository left if (!it.hasNext()) { throw e; } } } // this will never be executed return null; }
cats.addAll(internalReadSubCategories( cms, internalCategoryRootPath(repository, catPath), includeSubCats)); } catch (CmsVfsResourceNotFoundException e) {
String repositoryPath = internalCategoryRootPath(path, categoryBase); if (cms.existsResource(repositoryPath)) { ret.add(repositoryPath);
String repositoryPath = internalCategoryRootPath(path, base); if (cms.existsResource(repositoryPath)) { ret.add(repositoryPath);
folderPath = cms.getRequestContext().removeSiteRoot(internalCategoryRootPath(folderPath, name)); CmsResource resource; try {
folderPath = cms.getRequestContext().removeSiteRoot(internalCategoryRootPath(folderPath, name)); CmsResource resource; try {
/** * Renames/Moves a category from the old path to the new one.<p> * * This method will keep all categories in their original repository.<p> * * @param cms the current cms context * @param oldCatPath the path of the category to move * @param newCatPath the new category path * @param referencePath the reference path to find the category * * @throws CmsException if something goes wrong */ public void moveCategory(CmsObject cms, String oldCatPath, String newCatPath, String referencePath) throws CmsException { CmsCategory category = readCategory(cms, oldCatPath, referencePath); String catPath = cms.getRequestContext().removeSiteRoot(category.getRootPath()); CmsLock lock = cms.getLock(catPath); if (lock.isNullLock()) { cms.lockResource(catPath); } else if (lock.isLockableBy(cms.getRequestContext().currentUser())) { cms.changeLock(catPath); } cms.moveResource(catPath, cms.getRequestContext().removeSiteRoot( internalCategoryRootPath(category.getBasePath(), newCatPath))); }
/** * Renames/Moves a category from the old path to the new one.<p> * * This method will keep all categories in their original repository.<p> * * @param cms the current cms context * @param oldCatPath the path of the category to move * @param newCatPath the new category path * @param referencePath the reference path to find the category * * @throws CmsException if something goes wrong */ public void moveCategory(CmsObject cms, String oldCatPath, String newCatPath, String referencePath) throws CmsException { CmsCategory category = readCategory(cms, oldCatPath, referencePath); String catPath = cms.getRequestContext().removeSiteRoot(category.getRootPath()); CmsLock lock = cms.getLock(catPath); if (lock.isNullLock()) { cms.lockResource(catPath); } else if (lock.isLockableBy(cms.getRequestContext().getCurrentUser())) { cms.changeLock(catPath); } cms.moveResource( catPath, cms.getRequestContext().removeSiteRoot(internalCategoryRootPath(category.getBasePath(), newCatPath))); }