Class HippoNodeUtils
- java.lang.Object
-
- org.onehippo.forge.content.exim.core.util.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 givenabsPath
and creates folders if not existing.static javax.jcr.Node
getChildNodeOfType(javax.jcr.Node baseNode, String childNodeName, String... childNodeTypes)
Finds a child node bychildNodeName
andchildNodeTypes
under thebaseNode
.static org.hippoecm.repository.api.StringCodec
getDefaultUriEncoding()
Return the defaultStringCodec
used in folder and document node name generation.static javax.jcr.Node
getDocumentVariantByHippoStdState(javax.jcr.Node handle, String hippoStdState)
Finds a variant node by theHippoStdNodeType.HIPPOSTD_STATE
property value such asHippoStdNodeType.PUBLISHED
orHippoStdNodeType.UNPUBLISHED
.static Map<String,javax.jcr.Node>
getDocumentVariantsMap(javax.jcr.Node handle)
Returns a map of variant nodes, keyed by variant states such asHippoStdNodeType.PUBLISHED
orHippoStdNodeType.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)
Returnsnode
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)
ReturnsWorkflow
instance by thecategory
for thenode
.static boolean
isAssetPath(String path)
Return true if thepath
reflects a asset path in Hippo.static boolean
isBinaryPath(String path)
Return true if thepath
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 thepath
reflects a document path in Hippo.static boolean
isGalleryPath(String path)
Return true if thepath
reflects a gallery path in Hippo.
-
-
-
Method Detail
-
getDefaultUriEncoding
public static org.hippoecm.repository.api.StringCodec getDefaultUriEncoding()
Return the defaultStringCodec
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 bychildNodeName
andchildNodeTypes
under thebaseNode
.- Parameters:
baseNode
- base nodechildNodeName
- child node namechildNodeTypes
- child node type names- Returns:
- a child node by
childNodeName
andchildNodeTypes
under thebaseNode
- 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
ReturnsWorkflow
instance by thecategory
for thenode
.- Parameters:
session
- JCR sessioncategory
- workflow categorynode
- folder or document node- Returns:
Workflow
instance for thenode
and thecategory
- 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 asHippoStdNodeType.PUBLISHED
orHippoStdNodeType.UNPUBLISHED
.- Parameters:
handle
- document handle node- Returns:
- a map of variant nodes, keyed by variant states such as
HippoStdNodeType.PUBLISHED
orHippoStdNodeType.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 theHippoStdNodeType.HIPPOSTD_STATE
property value such asHippoStdNodeType.PUBLISHED
orHippoStdNodeType.UNPUBLISHED
.- Parameters:
handle
- document handle nodehippoStdState
-HippoStdNodeType.HIPPOSTD_STATE
property value such asHippoStdNodeType.PUBLISHED
orHippoStdNodeType.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 givenabsPath
and creates folders if not existing.- Parameters:
session
- JCR sessionabsPath
- absolute folder node path- Returns:
- the final folder node if successful
- Throws:
javax.jcr.RepositoryException
- if any repository exception occursorg.hippoecm.repository.api.WorkflowException
- if any workflow exception occurs
-
getHippoDocumentHandle
public static javax.jcr.Node getHippoDocumentHandle(javax.jcr.Node node) throws javax.jcr.RepositoryException
Returnsnode
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 thepath
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 thepath
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 thepath
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 thepath
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
-
-