/** * Removes a resource identified by the given resource name from the category * identified by the given category path.<p> * * The resource has to be previously locked.<p> * * @param cms the current cms context * @param resourceName the site relative path to the resource to remove * @param categoryPath the path of the category to remove the resource from * * @throws CmsException if something goes wrong */ public void removeResourceFromCategory(CmsObject cms, String resourceName, String categoryPath) throws CmsException { CmsCategory category = readCategory(cms, categoryPath, resourceName); removeResourceFromCategory(cms, resourceName, category); }
/** * Removes a resource identified by the given resource name from the category * identified by the given category path.<p> * * The resource has to be previously locked.<p> * * @param cms the current cms context * @param resourceName the site relative path to the resource to remove * @param categoryPath the path of the category to remove the resource from * * @throws CmsException if something goes wrong */ public void removeResourceFromCategory(CmsObject cms, String resourceName, String categoryPath) throws CmsException { CmsCategory category = readCategory(cms, categoryPath, resourceName); removeResourceFromCategory(cms, resourceName, category); }
/** * Adds a resource identified by the given resource name to the category * identified by the given category path.<p> * * Only the most global category matching the given category path for the * given resource will be affected.<p> * * The resource has to be locked.<p> * * @param cms the current cms context * @param resourceName the site relative path to the resource to add * @param categoryPath the path of the category to add the resource to * * @throws CmsException if something goes wrong */ public void addResourceToCategory(CmsObject cms, String resourceName, String categoryPath) throws CmsException { CmsCategory category = readCategory(cms, categoryPath, resourceName); addResourceToCategory(cms, resourceName, category); }
/** * Adds a resource identified by the given resource name to the category * identified by the given category path.<p> * * Only the most global category matching the given category path for the * given resource will be affected.<p> * * The resource has to be locked.<p> * * @param cms the current cms context * @param resourceName the site relative path to the resource to add * @param categoryPath the path of the category to add the resource to * * @throws CmsException if something goes wrong */ public void addResourceToCategory(CmsObject cms, String resourceName, String categoryPath) throws CmsException { CmsCategory category = readCategory(cms, categoryPath, resourceName); addResourceToCategory(cms, resourceName, category); }
public Object transform(Object categoryPath) { try { return CmsCategoryService.getInstance().readCategory( m_cms, (String)categoryPath, getRequestContext().getUri()); } catch (CmsException e) { LOG.warn(e.getLocalizedMessage(), e); return null; } }
filter = filter.filterIncludeChildren(); CmsCategory category = readCategory(cms, categoryPath, referencePath); Iterator itRelations = cms.getRelationsForResource( cms.getRequestContext().removeSiteRoot(category.getRootPath()),
/** * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String) */ @Override protected void fillDetails(String detailId) { // get content List<CmsListItem> items = getList().getAllContent(); Iterator<CmsListItem> itCategories = items.iterator(); while (itCategories.hasNext()) { CmsListItem item = itCategories.next(); String categoryPath = item.getId(); StringBuffer html = new StringBuffer(512); try { CmsCategory category = m_categoryService.readCategory(getCms(), categoryPath, getParamResource()); if (detailId.equals(LIST_DETAIL_PATH)) { html.append(category.getRootPath()); } else if (detailId.equals(LIST_DETAIL_DESCRIPTION)) { // Append the description if one is given if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(category.getDescription())) { html.append(category.getDescription()); } } } catch (Exception e) { // noop } item.set(detailId, html.toString()); } }
/** * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String) */ @Override protected void fillDetails(String detailId) { // get content List users = getList().getAllContent(); Iterator itCategories = users.iterator(); while (itCategories.hasNext()) { CmsListItem item = (CmsListItem)itCategories.next(); String categoryPath = item.getId(); StringBuffer html = new StringBuffer(512); try { CmsCategory category = m_categoryService.readCategory(getCms(), categoryPath, getParamResource()); if (detailId.equals(LIST_DETAIL_PATH)) { html.append(category.getRootPath()); } else if (detailId.equals(LIST_DETAIL_DESCRIPTION)) { // Append the description if one is given if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(category.getDescription())) { html.append(category.getDescription()); } } } catch (Exception e) { // noop } item.set(detailId, html.toString()); } }
filter = filter.filterIncludeChildren(); CmsCategory category = readCategory(cms, categoryPath, referencePath); Iterator<CmsRelation> itRelations = cms.getRelationsForResource( cms.getRequestContext().removeSiteRoot(category.getRootPath()),
/** * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isEnabled() */ @Override public boolean isEnabled() { try { A_CmsResourceCategoriesList wp = (A_CmsResourceCategoriesList)getWp(); if (wp.getResourceCategories().contains( wp.getCategoryService().readCategory(wp.getCms(), getItem().getId(), wp.getParamResource()))) { return false; } } catch (CmsException e) { // ignore } return true; } };
/** * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isEnabled() */ @Override public boolean isEnabled() { try { A_CmsResourceCategoriesList wp = (A_CmsResourceCategoriesList)getWp(); if (wp.getResourceCategories().contains( wp.getCategoryService().readCategory(wp.getCms(), getItem().getId(), wp.getParamResource()))) { return false; } } catch (CmsException e) { // ignore } return true; } };
+ cat.getId() + "', '" + CmsCategoryService.getInstance().readCategory( cms, CmsResource.getParentFolder(cat.getPath()), i, options, (selected != null ? CmsCategoryService.getInstance().readCategory( cms, CmsResource.getPathPart(selected.getPath(), i + baseLevel),
result.add(category); } else { CmsCategory actualCat = readCategory(cms, category.getPath(), resourceName); if (!category.getId().equals(actualCat.getId())) { CmsCategory actualCat = readCategory( cms, CmsCategory.getCategoryPath(relation.getTargetPath(), baseFolder),
result.add(category); } else { CmsCategory actualCat = readCategory(cms, category.getPath(), resourceName); if (!category.getId().equals(actualCat.getId())) { CmsCategory actualCat = readCategory(cms, CmsCategory.getCategoryPath( relation.getTargetPath(), baseFolder), resourceName);
String catPath = CmsCategoryService.getInstance().getCategory(cms, val).getPath(); String refPath = getReferencePath(cms, value); CmsCategoryService.getInstance().readCategory(cms, catPath, refPath); if (((CmsCategoryWidget)widget).isOnlyLeafs()) { if (!CmsCategoryService.getInstance().readCategories(cms, catPath, false, refPath).isEmpty()) {
String catPath = CmsCategoryService.getInstance().getCategory(cms, stringValue).getPath(); String refPath = getReferencePath(cms, value); CmsCategoryService.getInstance().readCategory(cms, catPath, refPath); if (((CmsCategoryWidget)widget).isOnlyLeafs()) { if (!CmsCategoryService.getInstance().readCategories(cms, catPath, false, refPath).isEmpty()) {
/** * Deletes the category identified by the given path.<p> * * Only the most global category matching the given category path for the * given resource will be affected.<p> * * This method will try to lock the involved resource.<p> * * @param cms the current cms context * @param categoryPath the path of the category to delete * @param referencePath the reference path to find the category repositories * * @throws CmsException if something goes wrong */ public void deleteCategory(CmsObject cms, String categoryPath, String referencePath) throws CmsException { CmsCategory category = readCategory(cms, categoryPath, referencePath); String folderPath = cms.getRequestContext().removeSiteRoot(category.getRootPath()); CmsLock lock = cms.getLock(folderPath); if (lock.isNullLock()) { cms.lockResource(folderPath); } else if (lock.isLockableBy(cms.getRequestContext().currentUser())) { cms.changeLock(folderPath); } cms.deleteResource(folderPath, CmsResource.DELETE_PRESERVE_SIBLINGS); }
/** * Deletes the category identified by the given path.<p> * * Only the most global category matching the given category path for the * given resource will be affected.<p> * * This method will try to lock the involved resource.<p> * * @param cms the current cms context * @param categoryPath the path of the category to delete * @param referencePath the reference path to find the category repositories * * @throws CmsException if something goes wrong */ public void deleteCategory(CmsObject cms, String categoryPath, String referencePath) throws CmsException { CmsCategory category = readCategory(cms, categoryPath, referencePath); String folderPath = cms.getRequestContext().removeSiteRoot(category.getRootPath()); CmsLock lock = cms.getLock(folderPath); if (lock.isNullLock()) { cms.lockResource(folderPath); } else if (lock.isLockableBy(cms.getRequestContext().getCurrentUser())) { cms.changeLock(folderPath); } cms.deleteResource(folderPath, CmsResource.DELETE_PRESERVE_SIBLINGS); }
/** * 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))); }
/** * 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))); }