Codota Logo
CmsCategoryService.readResourceCategories
Code IndexAdd Codota to your IDE (free)

How to use
readResourceCategories
method
in
org.opencms.relations.CmsCategoryService

Best Java code snippets using org.opencms.relations.CmsCategoryService.readResourceCategories (Showing top 12 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: org.opencms/opencms-core

/**
 * 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);
}
origin: org.opencms/org.opencms.workplace

/**
 * Returns a list of a categories related to the current request resource.<p>
 *
 * @return a list of a categories related to the current request resource
 *
 * @throws CmsException if something goes wrong
 */
protected List<CmsCategory> getResourceCategories() throws CmsException {
  if (m_resCats == null) {
    m_resCats = m_categoryService.readResourceCategories(getJsp().getCmsObject(), getParamResource());
  }
  return m_resCats;
}
origin: org.opencms/opencms-core

/**
 * 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;
}
origin: org.opencms/opencms-solr

/**
 * Returns a list of a categories related to the current request resource.<p>
 * 
 * @return a list of a categories related to the current request resource
 * 
 * @throws CmsException if something goes wrong 
 */
protected List getResourceCategories() throws CmsException {
  if (m_resCats == null) {
    m_resCats = m_categoryService.readResourceCategories(getJsp().getCmsObject(), getParamResource());
  }
  return m_resCats;
}
origin: org.opencms/opencms-solr

/**
 * Adds a resource identified by the given resource name to the given category.<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 category the category to add the resource to
 * 
 * @throws CmsException if something goes wrong
 */
public void addResourceToCategory(CmsObject cms, String resourceName, CmsCategory category) throws CmsException {
  if (readResourceCategories(cms, resourceName).contains(category)) {
    return;
  }
  String sitePath = cms.getRequestContext().removeSiteRoot(category.getRootPath());
  cms.addRelationToResource(resourceName, sitePath, CmsRelationType.CATEGORY.getName());
  String parentCatPath = category.getPath();
  // recursively add to higher level categories
  if (parentCatPath.endsWith("/")) {
    parentCatPath = parentCatPath.substring(0, parentCatPath.length() - 1);
  }
  if (parentCatPath.lastIndexOf('/') > 0) {
    addResourceToCategory(cms, resourceName, parentCatPath.substring(0, parentCatPath.lastIndexOf('/') + 1));
  }
}
origin: org.opencms/opencms-core

/**
 * Adds a resource identified by the given resource name to the given category.<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 category the category to add the resource to
 *
 * @throws CmsException if something goes wrong
 */
public void addResourceToCategory(CmsObject cms, String resourceName, CmsCategory category) throws CmsException {
  if (readResourceCategories(cms, cms.readResource(resourceName, CmsResourceFilter.IGNORE_EXPIRATION)).contains(
    category)) {
    return;
  }
  String sitePath = cms.getRequestContext().removeSiteRoot(category.getRootPath());
  cms.addRelationToResource(resourceName, sitePath, CmsRelationType.CATEGORY.getName());
  String parentCatPath = category.getPath();
  // recursively add to higher level categories
  if (parentCatPath.endsWith("/")) {
    parentCatPath = parentCatPath.substring(0, parentCatPath.length() - 1);
  }
  if (parentCatPath.lastIndexOf('/') > 0) {
    addResourceToCategory(cms, resourceName, parentCatPath.substring(0, parentCatPath.lastIndexOf('/') + 1));
  }
}
origin: org.opencms/opencms-solr

while (itResources.hasNext()) {
  resource = (CmsResource)itResources.next();
  Iterator itCategories = service.readResourceCategories(cms, cms.getSitePath(resource)).iterator();
  while (itCategories.hasNext()) {
    CmsCategory category = (CmsCategory)itCategories.next();
origin: org.opencms/opencms-core

/**
 * @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;
}
origin: org.opencms/opencms-core

while (itResources.hasNext()) {
  resource = itResources.next();
  Iterator<CmsCategory> itCategories = service.readResourceCategories(cms, resource).iterator();
  while (itCategories.hasNext()) {
    CmsCategory category = itCategories.next();
origin: org.opencms/opencms-core

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);
origin: org.opencms/opencms-core

/**
 * @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);
  }
}
origin: org.opencms/opencms-core

  categories = CmsCategoryService.getInstance().readResourceCategories(cms, file);
} catch (CmsException e) {
  LOG.error(Messages.get().getBundle().key(Messages.ERROR_FAILED_READING_CATEGORIES_1), e);
org.opencms.relationsCmsCategoryServicereadResourceCategories

Javadoc

Reads the categories for a resource identified by the given resource name.

Popular methods of CmsCategoryService

  • addResourceToCategory
    Adds a resource identified by the given resource name to the given category. The resource has to be
  • getInstance
    Returns the singleton instance.
  • readCategories
    Returns all categories given some search parameters.
  • readCategory
    Reads all categories identified by the given category path for the given reference path.
  • removeResourceFromCategory
    Removes a resource identified by the given resource name from the given category. The resource has t
  • repairRelations
    Repairs broken category relations. This could be caused by renaming/moving a category folder, or cha
  • <init>
  • clearCategoriesForResource
    Removes the given resource from all categories.
  • createCategory
    Creates a new category. Will use the same category repository as the parent if specified, or the clo
  • getCategory
    Creates a category from the given resource.
  • getCategoryRepositories
    Returns all category repositories for the given reference path.
  • getRepositoryBaseFolderName
    Returns the category repositories base folder name.
  • getCategoryRepositories,
  • getRepositoryBaseFolderName,
  • internalCategoryRootPath,
  • internalReadResourceCategories,
  • internalReadSubCategories,
  • readCategoryResources,
  • deleteCategory,
  • moveCategory,
  • readCategoriesForRepositories

Popular in Java

  • Start an intent from android
  • startActivity (Activity)
  • findViewById (Activity)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • LinkedHashMap (java.util)
    Hash table and linked list implementation of the Map interface, with predictable iteration order. Th
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • ImageIO (javax.imageio)
  • JLabel (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now