Class NodeHelper

java.lang.Object
org.ametys.plugins.repository.jcr.NodeHelper

public final class NodeHelper extends Object
Provides helper methods on nodes.
  • Method Summary

    Modifier and Type
    Method
    Description
    static javax.jcr.Node
    cloneNode(javax.jcr.Node nodeToCopy, javax.jcr.Node parentNode)
    Clone the node to the given parent node keeping the identifiers.
    static javax.jcr.Node
    cloneNode(javax.jcr.Node nodeToCopy, javax.jcr.Node parentNode, String nodeName)
    Clone the node to the given parent node keeping the identifiers.
    static String
    Get the path with hashed nodes.
    static javax.jcr.Node
    getOrCreateFinalHashNode(javax.jcr.Node parentNode, String name)
    Get or create hash nodes for the given name, intermediate nodes are of type "ametys:collectionElement".
    static javax.jcr.Node
    getOrCreateFinalHashNode(javax.jcr.Node parentNode, String name, String hashType)
    Get or create hash nodes for the given name and intermediate primary type.
    static List<String>
    Computes a hashed path in the JCR tree from the name of the child object.
    Subclasses may override this method to provide a more suitable hash function.
    This implementation relies on the buzhash algorithm.
    static void
    rename(javax.jcr.Node node, String newName)
    Rename the given Node with the given new name

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • rename

      public static void rename(javax.jcr.Node node, String newName) throws AmetysRepositoryException
      Rename the given Node with the given new name
      Parameters:
      node - the node to rename
      newName - the new name of the node
      Throws:
      AmetysRepositoryException - if an error occurs.
    • cloneNode

      public static javax.jcr.Node cloneNode(javax.jcr.Node nodeToCopy, javax.jcr.Node parentNode) throws AmetysRepositoryException
      Clone the node to the given parent node keeping the identifiers. To be able to do that, parent node should be in another workspace than the node to copy. The destination node should not already contains a node with the same name as the node to copy except if same name siblings is allowed. This method does not save the parent node.
      Parameters:
      nodeToCopy - The node to copy.
      parentNode - The parent node of the destination node.
      Returns:
      the create node
      Throws:
      AmetysRepositoryException - if an error occurs
    • cloneNode

      public static javax.jcr.Node cloneNode(javax.jcr.Node nodeToCopy, javax.jcr.Node parentNode, String nodeName) throws AmetysRepositoryException
      Clone the node to the given parent node keeping the identifiers. To be able to do that, parent node should be in another workspace than the node to copy. The destination node should not already contains a node with the given node name except if same name siblings is allowed. This method does not save the parent node.
      Parameters:
      nodeToCopy - The node to copy.
      parentNode - The parent node of the destination node.
      nodeName - The destination node name.
      Returns:
      the create node
      Throws:
      AmetysRepositoryException - if an error occurs
    • hashAsList

      public static List<String> hashAsList(String name)
      Computes a hashed path in the JCR tree from the name of the child object.
      Subclasses may override this method to provide a more suitable hash function.
      This implementation relies on the buzhash algorithm. This method MUST return an array of the same length for each name.
      Parameters:
      name - the name of the child object
      Returns:
      a hashed path of the name.
    • getFullHashPath

      public static String getFullHashPath(String name)
      Get the path with hashed nodes.
      Parameters:
      name - the name of the final node
      Returns:
      the path with hashed nodes
    • getOrCreateFinalHashNode

      public static javax.jcr.Node getOrCreateFinalHashNode(javax.jcr.Node parentNode, String name) throws AmetysRepositoryException
      Get or create hash nodes for the given name, intermediate nodes are of type "ametys:collectionElement". The final node is not created. The session is not saved.
      Parameters:
      parentNode - the parent node of the hashed nodes
      name - the name of the final node.
      Returns:
      the last level of hashed nodes
      Throws:
      AmetysRepositoryException - if an error occurs
    • getOrCreateFinalHashNode

      public static javax.jcr.Node getOrCreateFinalHashNode(javax.jcr.Node parentNode, String name, String hashType) throws AmetysRepositoryException
      Get or create hash nodes for the given name and intermediate primary type. The final node is not created. The session is not saved.
      Parameters:
      parentNode - the parent node of the hashed nodes
      name - the name of the final node.
      hashType - the primary type of hashed nodes
      Returns:
      the last level of hashed nodes
      Throws:
      AmetysRepositoryException - if an error occurs