Class ContentNodeUtils

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

public class ContentNodeUtils extends Object
Utilities to handle ContentNode objects.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Default JXPath expression to select all the nodes having hippo:docbase property.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    containsStringValueInProperty(org.onehippo.forge.content.pojo.model.ContentNode contentNode, String propertyName, String value)
    Return true if the property (by the given propertyName) in the contentNode has the same string value as value.
    static void
    prependUrlPrefixInJcrDataValues(org.onehippo.forge.content.pojo.model.ContentNode baseContentNode, String startsWith, String urlPrefix)
    Find a given urlPrefix in the URL value of jcr:data property, and prepend it with the given urlPrefix if the value starts with the startsWith.
    static void
    removeUrlPrefixInJcrDataValues(org.onehippo.forge.content.pojo.model.ContentNode baseContentNode, String urlPrefix)
    Find a given urlPrefix in the URL value of jcr:data property, and remove the prefix if the value starts with the urlPrefix.
    static void
    replaceDocbasePropertiesByPaths(Session session, org.onehippo.forge.content.pojo.model.ContentNode baseContentNode, String jxpath)
    Selects all the ContentProperty objects under baseContentNode by the given JXPath expression, jxpath and replace the string docbase property value by the path of the JCR node found by the existing UUID string value.
    static void
    replaceDocbasesByPaths(Session session, org.onehippo.forge.content.pojo.model.ContentNode baseContentNode)
    Selects all the ContentNode objects under baseContentNode by the default JXPath expression, MIRROR_DOCBASES_XPATH and replace the hippo:docbase property value by the path of the JCR node found by the existing UUID string value.
    static void
    replaceDocbasesByPaths(Session session, org.onehippo.forge.content.pojo.model.ContentNode baseContentNode, String jxpath)
    Selects all the ContentNode objects under baseContentNode by the given JXPath expression, jxpath and replace the hippo:docbase property value by the path of the JCR node found by the existing UUID string value.
    static void
    replaceDocbasesByPaths(Session session, org.onehippo.forge.content.pojo.model.ContentNode baseContentNode, String jxpath, Collection<String> paths)
    Selects all the ContentNode objects under baseContentNode by the given JXPath expression, jxpath and replace the hippo:docbase property value by the path of the JCR node found by the existing UUID string value, and add those paths to paths collection.

    Methods inherited from class java.lang.Object

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

    • MIRROR_DOCBASES_XPATH

      public static final String MIRROR_DOCBASES_XPATH
      Default JXPath expression to select all the nodes having hippo:docbase property.
      See Also:
  • Method Details

    • replaceDocbasesByPaths

      public static void replaceDocbasesByPaths(Session session, org.onehippo.forge.content.pojo.model.ContentNode baseContentNode) throws RepositoryException
      Selects all the ContentNode objects under baseContentNode by the default JXPath expression, MIRROR_DOCBASES_XPATH and replace the hippo:docbase property value by the path of the JCR node found by the existing UUID string value. session is used when finding a JCR node associated by the UUID value at the existing hippo:docbase property.
      Parameters:
      session - JCR session
      baseContentNode - base ContentNode instance
      Throws:
      RepositoryException - if fails to find a JCR node associated by the UUID value
    • replaceDocbasesByPaths

      public static void replaceDocbasesByPaths(Session session, org.onehippo.forge.content.pojo.model.ContentNode baseContentNode, String jxpath) throws RepositoryException
      Selects all the ContentNode objects under baseContentNode by the given JXPath expression, jxpath and replace the hippo:docbase property value by the path of the JCR node found by the existing UUID string value. session is used when finding a JCR node associated by the UUID value at the existing hippo:docbase property.
      Parameters:
      session - JCR session
      baseContentNode - base ContentNode instance
      jxpath - JXPath expression
      Throws:
      RepositoryException - if fails to find a JCR node associated by the UUID value
    • replaceDocbasesByPaths

      public static void replaceDocbasesByPaths(Session session, org.onehippo.forge.content.pojo.model.ContentNode baseContentNode, String jxpath, Collection<String> paths) throws RepositoryException
      Selects all the ContentNode objects under baseContentNode by the given JXPath expression, jxpath and replace the hippo:docbase property value by the path of the JCR node found by the existing UUID string value, and add those paths to paths collection. session is used when finding a JCR node associated by the UUID value at the existing hippo:docbase property.
      Parameters:
      session - JCR session
      baseContentNode - base ContentNode instance
      jxpath - JXPath expression
      paths - replaced paths collection
      Throws:
      RepositoryException - if fails to find a JCR node associated by the UUID value
    • replaceDocbasePropertiesByPaths

      public static void replaceDocbasePropertiesByPaths(Session session, org.onehippo.forge.content.pojo.model.ContentNode baseContentNode, String jxpath) throws RepositoryException
      Selects all the ContentProperty objects under baseContentNode by the given JXPath expression, jxpath and replace the string docbase property value by the path of the JCR node found by the existing UUID string value. session is used when finding a JCR node associated by the UUID value at the existing string UUID property value.
      Parameters:
      session - JCR session
      baseContentNode - base ContentNode instance
      jxpath - JXPath expression
      Throws:
      RepositoryException - if fails to find a JCR node associated by the UUID value
    • removeUrlPrefixInJcrDataValues

      public static void removeUrlPrefixInJcrDataValues(org.onehippo.forge.content.pojo.model.ContentNode baseContentNode, String urlPrefix)
      Find a given urlPrefix in the URL value of jcr:data property, and remove the prefix if the value starts with the urlPrefix.
      Parameters:
      baseContentNode - base content node
      urlPrefix - url prefix
    • prependUrlPrefixInJcrDataValues

      public static void prependUrlPrefixInJcrDataValues(org.onehippo.forge.content.pojo.model.ContentNode baseContentNode, String startsWith, String urlPrefix)
      Find a given urlPrefix in the URL value of jcr:data property, and prepend it with the given urlPrefix if the value starts with the startsWith.
      Parameters:
      baseContentNode - base content node
      startsWith - start with string of the value
      urlPrefix - url prefix
    • containsStringValueInProperty

      public static boolean containsStringValueInProperty(org.onehippo.forge.content.pojo.model.ContentNode contentNode, String propertyName, String value)
      Return true if the property (by the given propertyName) in the contentNode has the same string value as value.
      Parameters:
      contentNode - content node
      propertyName - property name
      value - string value
      Returns:
      true if the property (by the given propertyName) in the contentNode has the same string value as value