Class ResourceHelper
- java.lang.Object
-
- org.hippoecm.frontend.editor.plugins.resource.ResourceHelper
-
public class ResourceHelper extends Object
Resource helper for creating and validating nodes of typehippo:resource
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.jcr.ValueFactory
getValueFactory(javax.jcr.Node node)
Gets theValueFactory
from theSession
static void
handlePdfAndSetHippoTextProperty(javax.jcr.Node node, InputStream inputStream)
Handles theInputStream
and extract text content from the PDF and sets it as a binary type property on the resource node.static void
setDefaultResourceProperties(javax.jcr.Node node, String mimeType, InputStream inputStream)
Set the default 'hippo:resource' properties: jcr:mimeType jcr:data jcr:lastModifiedstatic void
setDefaultResourceProperties(javax.jcr.Node node, String mimeType, InputStream inputStream, String filename)
Set the default 'hippo:resource' properties: jcr:mimeType jcr:data jcr:lastModified hippo:filenamestatic void
setDefaultResourceProperties(javax.jcr.Node node, String mimeType, javax.jcr.Binary binary, String filename)
Set the default 'hippo:resource' properties: jcr:mimeType jcr:data jcr:lastModified hippo:filename
-
-
-
Method Detail
-
setDefaultResourceProperties
public static void setDefaultResourceProperties(javax.jcr.Node node, String mimeType, InputStream inputStream) throws javax.jcr.RepositoryException
Set the default 'hippo:resource' properties:- jcr:mimeType
- jcr:data
- jcr:lastModified
- Parameters:
node
- theNode
on which to set the propertiesmimeType
- the mime-type of the binary data (e.g. application/pdf, image/jpeg)inputStream
- the data stream. Once the properties have been set the input stream will be closed.- Throws:
javax.jcr.RepositoryException
- exception thrown when one of the properties or values could not be set
-
setDefaultResourceProperties
public static void setDefaultResourceProperties(javax.jcr.Node node, String mimeType, InputStream inputStream, String filename) throws javax.jcr.RepositoryException
Set the default 'hippo:resource' properties:- jcr:mimeType
- jcr:data
- jcr:lastModified
- hippo:filename
- Parameters:
node
- theNode
on which to set the propertiesmimeType
- the mime-type of the binary data (e.g. application/pdf, image/jpeg)inputStream
- the data stream. Once the properties have been set the input stream will be closed.- Throws:
javax.jcr.RepositoryException
- exception thrown when one of the properties or values could not be set
-
setDefaultResourceProperties
public static void setDefaultResourceProperties(javax.jcr.Node node, String mimeType, javax.jcr.Binary binary, String filename) throws javax.jcr.RepositoryException
Set the default 'hippo:resource' properties:- jcr:mimeType
- jcr:data
- jcr:lastModified
- hippo:filename
- Parameters:
node
- theNode
on which to set the propertiesmimeType
- the mime-type of the binary data (e.g. application/pdf, image/jpeg)binary
- the binary data.filename
- the name of the resource file, should not benull
or "".- Throws:
javax.jcr.RepositoryException
- exception thrown when one of the properties or values could not be set
-
handlePdfAndSetHippoTextProperty
public static void handlePdfAndSetHippoTextProperty(javax.jcr.Node node, InputStream inputStream)
Handles theInputStream
and extract text content from the PDF and sets it as a binary type property on the resource node. Once the property has been set the input stream will be closed.- Parameters:
node
- theNode
on which to set the '"hippo:text"' propertyinputStream
- data stream
-
getValueFactory
public static javax.jcr.ValueFactory getValueFactory(javax.jcr.Node node) throws javax.jcr.RepositoryException
Gets theValueFactory
from theSession
- Parameters:
node
- theNode
from which to get theSession
- Returns:
- a
ValueFactory
- Throws:
javax.jcr.RepositoryException
- In case something goes wrong while trying to get theSession
orValueFactory
-
-