Class HippoNodeUtils


  • public class HippoNodeUtils
    extends Object
    Hippo specific node related utilities.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static javax.jcr.Node createMissingHippoFolders​(javax.jcr.Session session, String absPath)
      Checks if all the folders exist in the given absPath and creates folders if not existing.
      static javax.jcr.Node getChildNodeOfType​(javax.jcr.Node baseNode, String childNodeName, String... childNodeTypes)
      Finds a child node by childNodeName and childNodeTypes under the baseNode.
      static org.hippoecm.repository.api.StringCodec getDefaultUriEncoding()
      Return the default StringCodec used in folder and document node name generation.
      static javax.jcr.Node getDocumentVariantByHippoStdState​(javax.jcr.Node handle, String hippoStdState)
      Finds a variant node by the HippoStdNodeType.HIPPOSTD_STATE property value such as HippoStdNodeType.PUBLISHED or HippoStdNodeType.UNPUBLISHED.
      static Map<String,​javax.jcr.Node> getDocumentVariantsMap​(javax.jcr.Node handle)
      Returns a map of variant nodes, keyed by variant states such as HippoStdNodeType.PUBLISHED or HippoStdNodeType.UNPUBLISHED.
      static javax.jcr.Node getFirstVariantNode​(javax.jcr.Node handle)
      Find and return the first found variant node under the handle node.
      static javax.jcr.Node getHippoDocumentHandle​(javax.jcr.Node node)
      Returns node if it is a document handle node or its parent if it is a document variant node.
      static org.hippoecm.repository.api.Workflow getHippoWorkflow​(javax.jcr.Session session, String category, javax.jcr.Node node)
      Returns Workflow instance by the category for the node.
      static boolean isAssetPath​(String path)
      Return true if the path reflects a asset path in Hippo.
      static boolean isBinaryPath​(String path)
      Return true if the path reflects a gallery or asset path in Hippo.
      static boolean isDocumentHandleLive​(javax.jcr.Node handle)
      Detects if the document handle is representing a live document at the moment.
      static boolean isDocumentPath​(String path)
      Return true if the path reflects a document path in Hippo.
      static boolean isGalleryPath​(String path)
      Return true if the path reflects a gallery path in Hippo.
    • Method Detail

      • getDefaultUriEncoding

        public static org.hippoecm.repository.api.StringCodec getDefaultUriEncoding()
        Return the default StringCodec used in folder and document node name generation.
        Returns:
        the default StringCodec used in folder and document node name generation
      • getChildNodeOfType

        public static javax.jcr.Node getChildNodeOfType​(javax.jcr.Node baseNode,
                                                        String childNodeName,
                                                        String... childNodeTypes)
                                                 throws javax.jcr.RepositoryException
        Finds a child node by childNodeName and childNodeTypes under the baseNode.
        Parameters:
        baseNode - base node
        childNodeName - child node name
        childNodeTypes - child node type names
        Returns:
        a child node by childNodeName and childNodeTypes under the baseNode
        Throws:
        javax.jcr.RepositoryException - if any repository/workflow exception occurs
      • getHippoWorkflow

        public static org.hippoecm.repository.api.Workflow getHippoWorkflow​(javax.jcr.Session session,
                                                                            String category,
                                                                            javax.jcr.Node node)
                                                                     throws javax.jcr.RepositoryException
        Returns Workflow instance by the category for the node.
        Parameters:
        session - JCR session
        category - workflow category
        node - folder or document node
        Returns:
        Workflow instance for the node and the category
        Throws:
        javax.jcr.RepositoryException - if any repository/workflow exception occurs
      • getFirstVariantNode

        public static javax.jcr.Node getFirstVariantNode​(javax.jcr.Node handle)
                                                  throws javax.jcr.RepositoryException
        Find and return the first found variant node under the handle node.
        Parameters:
        handle - handle node
        Returns:
        the first found variant node under the handle node
        Throws:
        javax.jcr.RepositoryException - if repository exception occurs
      • getDocumentVariantsMap

        public static Map<String,​javax.jcr.Node> getDocumentVariantsMap​(javax.jcr.Node handle)
                                                                       throws javax.jcr.RepositoryException
        Returns a map of variant nodes, keyed by variant states such as HippoStdNodeType.PUBLISHED or HippoStdNodeType.UNPUBLISHED.
        Parameters:
        handle - document handle node
        Returns:
        a map of variant nodes, keyed by variant states such as HippoStdNodeType.PUBLISHED or HippoStdNodeType.UNPUBLISHED
        Throws:
        javax.jcr.RepositoryException - if any repository/workflow exception occurs
      • getDocumentVariantByHippoStdState

        public static javax.jcr.Node getDocumentVariantByHippoStdState​(javax.jcr.Node handle,
                                                                       String hippoStdState)
                                                                throws javax.jcr.RepositoryException
        Finds a variant node by the HippoStdNodeType.HIPPOSTD_STATE property value such as HippoStdNodeType.PUBLISHED or HippoStdNodeType.UNPUBLISHED.
        Parameters:
        handle - document handle node
        hippoStdState - HippoStdNodeType.HIPPOSTD_STATE property value such as HippoStdNodeType.PUBLISHED or HippoStdNodeType.UNPUBLISHED
        Returns:
        a variant node by the HippoStdNodeType.HIPPOSTD_STATE property value
        Throws:
        javax.jcr.RepositoryException - if any repository/workflow exception occurs
      • isDocumentHandleLive

        public static boolean isDocumentHandleLive​(javax.jcr.Node handle)
                                            throws javax.jcr.RepositoryException
        Detects if the document handle is representing a live document at the moment.
        Parameters:
        handle - document handle node
        Returns:
        true if the document handle is representing a live document at the moment
        Throws:
        javax.jcr.RepositoryException - if any repository/workflow exception occurs
      • createMissingHippoFolders

        public static javax.jcr.Node createMissingHippoFolders​(javax.jcr.Session session,
                                                               String absPath)
                                                        throws javax.jcr.RepositoryException,
                                                               org.hippoecm.repository.api.WorkflowException
        Checks if all the folders exist in the given absPath and creates folders if not existing.
        Parameters:
        session - JCR session
        absPath - absolute folder node path
        Returns:
        the final folder node if successful
        Throws:
        javax.jcr.RepositoryException - if any repository exception occurs
        org.hippoecm.repository.api.WorkflowException - if any workflow exception occurs
      • getHippoDocumentHandle

        public static javax.jcr.Node getHippoDocumentHandle​(javax.jcr.Node node)
                                                     throws javax.jcr.RepositoryException
        Returns node if it is a document handle node or its parent if it is a document variant node. Otherwise returns null.
        Parameters:
        node - JCR node
        Returns:
        node if it is a document handle node or its parent if it is a document variant node. Otherwise returns null.
        Throws:
        javax.jcr.RepositoryException - if repository exception occurs
      • isDocumentPath

        public static boolean isDocumentPath​(String path)
        Return true if the path reflects a document path in Hippo.
        Parameters:
        path - document path
        Returns:
        true if the path reflects a document path in Hippo
      • isGalleryPath

        public static boolean isGalleryPath​(String path)
        Return true if the path reflects a gallery path in Hippo.
        Parameters:
        path - gallery path
        Returns:
        true if the path reflects a gallery path in Hippo
      • isAssetPath

        public static boolean isAssetPath​(String path)
        Return true if the path reflects a asset path in Hippo.
        Parameters:
        path - asset path
        Returns:
        true if the path reflects a asset path in Hippo
      • isBinaryPath

        public static boolean isBinaryPath​(String path)
        Return true if the path reflects a gallery or asset path in Hippo.
        Parameters:
        path - gallery or asset path
        Returns:
        true if the path reflects a gallery or asset path in Hippo