/** * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(CmsCategory cat) { boolean thisGlobal = getBasePath().equals(CmsCategoryService.CENTRALIZED_REPOSITORY); boolean thatGlobal = cat.getBasePath().equals(CmsCategoryService.CENTRALIZED_REPOSITORY); if ((thisGlobal && thatGlobal) || (!thisGlobal && !thatGlobal)) { return getPath().compareTo(cat.getPath()); } return thisGlobal ? -1 : 1; }
/** * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(Object that) { if (!(that instanceof CmsCategory)) { return -1; } CmsCategory cat = (CmsCategory)that; boolean thisGlobal = this.getBasePath().equals(CmsCategoryService.CENTRALIZED_REPOSITORY); boolean thatGlobal = cat.getBasePath().equals(CmsCategoryService.CENTRALIZED_REPOSITORY); if ((thisGlobal && thatGlobal) || (!thisGlobal && !thatGlobal)) { return this.getPath().compareTo(cat.getPath()); } return thisGlobal ? -1 : 1; }
/** * Constructor.<p> * * @param category the server-side category */ public CmsCategoryBean(CmsCategory category) { this( category.getId(), category.getTitle(), category.getDescription(), category.getPath(), category.getBasePath(), category.getRootPath()); }
for (CmsCategory category : categories) { if (category.getPath().startsWith(mainCategoryPath)) { pathes.append(category.getBasePath()).append(category.getPath()).append(',');
/** * 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))); }