/** * 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); }
/** * @see org.opencms.gwt.shared.rpc.I_CmsCoreService#setResourceCategories(org.opencms.util.CmsUUID, java.util.List) */ public void setResourceCategories(CmsUUID structureId, List<String> categories) throws CmsRpcException { CmsObject cms = getCmsObject(); CmsCategoryService catService = CmsCategoryService.getInstance(); try { CmsResource resource = cms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION); ensureLock(resource); String sitePath = cms.getSitePath(resource); List<CmsCategory> previousCategories = catService.readResourceCategories(cms, resource); for (CmsCategory category : previousCategories) { if (categories.contains(category.getPath())) { categories.remove(category.getPath()); } else { catService.removeResourceFromCategory(cms, sitePath, category); } } for (String path : categories) { catService.addResourceToCategory(cms, sitePath, path); } tryUnlock(resource); } catch (Throwable t) { error(t); } }
if (category.getPath().startsWith(mainCategoryPath)) { try { CmsCategoryService.getInstance().removeResourceFromCategory( cms, cms.getSitePath(file),
/** * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions() */ @Override public void executeListSingleActions() throws CmsRuntimeException { if (getParamListAction().equals(LIST_ACTION_REMOVE1) || getParamListAction().equals(LIST_ACTION_REMOVE2)) { try { // lock resource if autolock is enabled checkLock(getParamResource()); CmsListItem listItem = getSelectedItem(); String categoryPath = listItem.getId(); getCategoryService().removeResourceFromCategory(getCms(), getParamResource(), categoryPath); getCategoryService().repairRelations(getCms(), getParamResource()); } catch (CmsException e) { throw new CmsRuntimeException(e.getMessageContainer(), e); } } else { throwListUnsupportedActionException(); } listSave(); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions() */ @Override public void executeListSingleActions() throws CmsRuntimeException { if (getParamListAction().equals(LIST_ACTION_REMOVE1) || getParamListAction().equals(LIST_ACTION_REMOVE2)) { try { // lock resource if autolock is enabled checkLock(getParamResource()); CmsListItem listItem = getSelectedItem(); String categoryPath = listItem.getId(); getCategoryService().removeResourceFromCategory(getCms(), getParamResource(), categoryPath); getCategoryService().repairRelations(getCms(), getParamResource()); } catch (CmsException e) { throw new CmsRuntimeException(e.getMessageContainer(), e); } } else { throwListUnsupportedActionException(); } listSave(); }