code: 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);
      }
docs: 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.