Class HippoNodeUtils

java.lang.Object
org.onehippo.forge.content.exim.core.util.HippoNodeUtils

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

    • 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 Node getChildNodeOfType(Node baseNode, String childNodeName, String... childNodeTypes) throws 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:
      RepositoryException - if any repository/workflow exception occurs
    • getHippoWorkflow

      public static org.hippoecm.repository.api.Workflow getHippoWorkflow(Session session, String category, Node node) throws 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:
      RepositoryException - if any repository/workflow exception occurs
    • getFirstVariantNode

      public static Node getFirstVariantNode(Node handle) throws 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:
      RepositoryException - if repository exception occurs
    • getDocumentVariantsMap

      public static Map<String,Node> getDocumentVariantsMap(Node handle) throws 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:
      RepositoryException - if any repository/workflow exception occurs
    • getDocumentVariantByHippoStdState

      public static Node getDocumentVariantByHippoStdState(Node handle, String hippoStdState) throws 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:
      RepositoryException - if any repository/workflow exception occurs
    • isDocumentHandleLive

      public static boolean isDocumentHandleLive(Node handle) throws 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:
      RepositoryException - if any repository/workflow exception occurs
    • createMissingHippoFolders

      public static Node createMissingHippoFolders(Session session, String absPath) throws 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:
      RepositoryException - if any repository exception occurs
      org.hippoecm.repository.api.WorkflowException - if any workflow exception occurs
    • getHippoDocumentHandle

      public static Node getHippoDocumentHandle(Node node) throws 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:
      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