/** * Public constructor.<p> * * @param jsp an initialized JSP action element * @param listId the id of the list * @param listName the name of the list * @param searchable searchable flag */ protected A_CmsResourceCategoriesList( CmsJspActionElement jsp, String listId, CmsMessageContainer listName, boolean searchable) { super(jsp, listId, listName, LIST_COLUMN_PATH, CmsListOrderEnum.ORDER_ASCENDING, searchable ? LIST_COLUMN_NAME : null); m_categoryService = CmsCategoryService.getInstance(); }
/** * Public constructor.<p> * * @param jsp an initialized JSP action element * @param listId the id of the list * @param listName the name of the list * @param searchable searchable flag */ protected A_CmsResourceCategoriesList( CmsJspActionElement jsp, String listId, CmsMessageContainer listName, boolean searchable) { super( jsp, listId, listName, LIST_COLUMN_PATH, CmsListOrderEnum.ORDER_ASCENDING, searchable ? LIST_COLUMN_NAME : null); m_categoryService = CmsCategoryService.getInstance(); }
/** * Reads the categories for the given resource. * * @param cms the {@link CmsObject} used for reading the categories. * @param resource the resource for which the categories should be read. * @return the categories assigned to the given resource. */ private static List<CmsCategory> getCategories(CmsObject cms, CmsResource resource) { if ((null != resource) && (null != cms)) { try { return CmsCategoryService.getInstance().readResourceCategories(cms, resource); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } } return new ArrayList<CmsCategory>(0); }
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; } }
/** * Extends the given document by resource category information based on properties.<p> * * @param document the document to extend * @param cms the OpenCms context used for building the search index * @param resource the resource that is indexed * @param extractionResult the plain text extraction result from the resource * @param properties the list of all properties directly attached to the resource (not searched) * @param propertiesSearched the list of all searched properties of the resource * * @return the document extended by resource category information * * @throws CmsException if something goes wrong */ protected I_CmsSearchDocument appendCategories( I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) throws CmsException { CmsCategoryService categoryService = CmsCategoryService.getInstance(); document.addCategoryField(categoryService.readResourceCategories(cms, resource)); return document; }
@Override public Object transform(Object categoryPath) { try { List<CmsCategory> categories = CmsCategoryService.getInstance().readCategories( m_cms, (String)categoryPath, true, m_cms.getRequestContext().getUri()); CmsJspCategoryAccessBean result = new CmsJspCategoryAccessBean( categories, (String)categoryPath); return result; } catch (CmsException e) { LOG.warn(e.getLocalizedMessage(), e); return null; } }
/** * @see org.opencms.gwt.shared.rpc.I_CmsCoreService#getCategories(java.lang.String, boolean, java.util.List) */ public List<CmsCategoryTreeEntry> getCategories(String fromPath, boolean includeSubCats, List<String> refPaths) throws CmsRpcException { CmsObject cms = getCmsObject(); CmsCategoryService catService = CmsCategoryService.getInstance(); List<String> repositories = new ArrayList<String>(); if ((refPaths != null) && !refPaths.isEmpty()) { for (String refPath : refPaths) { repositories.addAll(catService.getCategoryRepositories(getCmsObject(), refPath)); } } else { repositories.add(CmsCategoryService.CENTRALIZED_REPOSITORY); } List<CmsCategoryTreeEntry> result = null; try { // get the categories List<CmsCategory> categories = catService.readCategoriesForRepositories( cms, fromPath, includeSubCats, repositories); result = buildCategoryTree(cms, categories); } catch (Throwable e) { error(e); } return result; }
if (CmsStringUtil.isNotEmpty(getParamGalleryPath())) { try { CmsCategoryService service = CmsCategoryService.getInstance();
if (CmsStringUtil.isNotEmpty(getParamGalleryPath())) { try { CmsCategoryService service = CmsCategoryService.getInstance();
CmsCategoryService catService = CmsCategoryService.getInstance(); List<CmsCategory> categories;
CmsCategoryService catService = CmsCategoryService.getInstance(); List<CmsCategory> foundCategories = Collections.emptyList(); String editedResource = null;
/** * @see org.opencms.gwt.shared.rpc.I_CmsCoreService#getCategoryInfo(org.opencms.util.CmsUUID) */ public CmsResourceCategoryInfo getCategoryInfo(CmsUUID structureId) throws CmsRpcException { CmsObject cms = getCmsObject(); CmsCategoryService catService = CmsCategoryService.getInstance(); try { CmsResource resource = cms.readResource(structureId, CmsResourceFilter.ignoreExpirationOffline(cms)); List<CmsCategory> categories = catService.readResourceCategories(cms, resource); List<String> currentCategories = new ArrayList<String>(); for (CmsCategory category : categories) { currentCategories.add(category.getPath()); } return new CmsResourceCategoryInfo( structureId, CmsVfsService.getPageInfoWithLock(cms, resource), currentCategories, getCategories(null, true, Collections.singletonList(cms.getSitePath(resource)))); } catch (CmsException e) { error(e); } return null; }
/** * @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); } }
List<CmsCategory> categories = new ArrayList<CmsCategory>(0); try { categories = CmsCategoryService.getInstance().readResourceCategories(getCmsObject(), file); } catch (CmsException e) { LOG.error(Messages.get().getBundle().key(Messages.ERROR_FAILED_READING_CATEGORIES_1), e);
/** * Repairs broken categories.<p> * * @param dbc the database context * @param projectId the project id * @param resource the resource to repair the categories for * * @throws CmsException if something goes wrong */ public void repairCategories(CmsDbContext dbc, CmsUUID projectId, CmsResource resource) throws CmsException { CmsObject cms = OpenCms.initCmsObject(new CmsObject(getSecurityManager(), dbc.getRequestContext())); cms.getRequestContext().setSiteRoot(""); cms.getRequestContext().setCurrentProject(readProject(dbc, projectId)); CmsCategoryService.getInstance().repairRelations(cms, resource); }
/** * Repairs broken categories.<p> * * @param dbc the database context * @param projectId the project id * @param resource the resource to repair the categories for * * @throws CmsException if something goes wrong */ public void repairCategories(CmsDbContext dbc, CmsUUID projectId, CmsResource resource) throws CmsException { CmsObject cms = OpenCms.initCmsObject(new CmsObject(getSecurityManager(), dbc.getRequestContext())); cms.getRequestContext().setSiteRoot(""); cms.getRequestContext().setCurrentProject(readProject(dbc, projectId)); CmsCategoryService.getInstance().repairRelations(cms, resource); }
name = OpenCms.getResourceManager().getFileTranslator().translateResource(name.trim().replace('/', '-')); CmsObject cms = getCmsObject(); CmsCategoryService catService = CmsCategoryService.getInstance(); String localRepositoryPath = CmsStringUtil.joinPaths( entryPoint, CmsCategoryService.getInstance().getRepositoryBaseFolderName(getCmsObject()));
CmsCategory cat = CmsCategoryService.getInstance().getCategory(cms, cms.readResource(new CmsUUID(id))); String referencePath = null; try {
/** * @see org.opencms.widgets.A_CmsWidget#setEditorValue(org.opencms.file.CmsObject, java.util.Map, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ @Override public void setEditorValue( CmsObject cms, Map formParameters, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { super.setEditorValue(cms, formParameters, widgetDialog, param); String id = param.getStringValue(cms); if (CmsStringUtil.isEmptyOrWhitespaceOnly(id)) { return; } try { CmsCategory cat = CmsCategoryService.getInstance().getCategory(cms, cms.readResource(new CmsUUID(id))); if (cat.getPath().startsWith(getStartingCategory(cms, cms.getSitePath(getResource(cms, param))))) { param.setStringValue(cms, cat.getRootPath()); } else { param.setStringValue(cms, ""); } } catch (CmsException e) { // invalid value param.setStringValue(cms, ""); } }
/** * @see org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapService#getCategoryData(java.lang.String) */ public CmsSitemapCategoryData getCategoryData(String entryPoint) throws CmsRpcException { CmsObject cms = getCmsObject(); try { CmsResource entryPointResource = cms.readResource(entryPoint); String basePath = CmsStringUtil.joinPaths( entryPointResource.getRootPath(), CmsCategoryService.getInstance().getRepositoryBaseFolderName(getCmsObject())); List<CmsCategoryTreeEntry> entries = CmsCoreService.getCategoriesForSitePathStatic( cms, entryPoint, cms.getRequestContext().removeSiteRoot(basePath)); CmsSitemapCategoryData categoryData = new CmsSitemapCategoryData(); for (CmsCategoryTreeEntry entry : entries) { categoryData.add(entry); } categoryData.setBasePath(basePath); return categoryData; } catch (Exception e) { error(e); return null; } }