Class ContentNodeUtils


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

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

      All Methods Static Methods Concrete Methods 
      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​(javax.jcr.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​(javax.jcr.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​(javax.jcr.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​(javax.jcr.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.
    • Field Detail

      • MIRROR_DOCBASES_XPATH

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

      • replaceDocbasesByPaths

        public static void replaceDocbasesByPaths​(javax.jcr.Session session,
                                                  org.onehippo.forge.content.pojo.model.ContentNode baseContentNode)
                                           throws javax.jcr.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:
        javax.jcr.RepositoryException - if fails to find a JCR node associated by the UUID value
      • replaceDocbasesByPaths

        public static void replaceDocbasesByPaths​(javax.jcr.Session session,
                                                  org.onehippo.forge.content.pojo.model.ContentNode baseContentNode,
                                                  String jxpath)
                                           throws javax.jcr.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:
        javax.jcr.RepositoryException - if fails to find a JCR node associated by the UUID value
      • replaceDocbasesByPaths

        public static void replaceDocbasesByPaths​(javax.jcr.Session session,
                                                  org.onehippo.forge.content.pojo.model.ContentNode baseContentNode,
                                                  String jxpath,
                                                  Collection<String> paths)
                                           throws javax.jcr.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:
        javax.jcr.RepositoryException - if fails to find a JCR node associated by the UUID value
      • replaceDocbasePropertiesByPaths

        public static void replaceDocbasePropertiesByPaths​(javax.jcr.Session session,
                                                           org.onehippo.forge.content.pojo.model.ContentNode baseContentNode,
                                                           String jxpath)
                                                    throws javax.jcr.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:
        javax.jcr.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