Class UGCUtil


  • public class UGCUtil
    extends Object
    Collection of utilities revolving around CQ Social Collaboration features.
    Since:
    CQ 5.6
    • Constructor Detail

      • UGCUtil

        public UGCUtil()
    • Method Detail

      • resourceToUGCPath

        public static String resourceToUGCPath​(Resource resource)
        This method maps the given resource to its equivalent path in /usergenerated, e.g. as the relationship a page /content/test to its comment at /content/usergenerated/content/test.
        Parameters:
        resource - The resource to transpose to the comment's UCG path.
        Returns:
        A String representing the equivalent UCG path.
      • UGCToResourcePath

        public static String UGCToResourcePath​(Resource resource)
        This method maps the given resource in /content/usergenerated to its equivalent path in the normal content tree, e.g. as the relationship of a comment in //content/usergenerated/content/test to its parent resource at /content/test.
        Parameters:
        resource - The resource to transpose.
        Returns:
        A String representing the equivalent normal content path.
      • getPagePath

        public static String getPagePath​(Resource resource)
        Returns the given resource's path without its potential /jcr:content/... suffix, thus representing a page path.
        Parameters:
        resource - The resource to check.
        Returns:
        A String representing the page path.
      • prepareUserGeneratedContent

        public static String prepareUserGeneratedContent​(ResourceResolver resolver,
                                                         String pagePath)
                                                  throws WCMException
        Gets or creates user generated content node
        Parameters:
        resolver - The resource resolver.
        pagePath - The page path.
        Returns:
        A String representing the UCG path.
        Throws:
        WCMException - If an error occurs while getting or creating user generated content node
      • getIdFromResource

        public static String getIdFromResource​(Resource resource)
        Returns the given resource's name without selectors and / or file extension.
        Parameters:
        resource - The resource from which to retrieve its name.
        Returns:
        A String representing the id.