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 ValueFactory
getValueFactory(Node node)
Gets theValueFactory
from theSession
static void
handlePdfAndSetHippoTextProperty(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(Node node, String mimeType, InputStream inputStream)
Set the default 'hippo:resource' properties: jcr:mimeType jcr:data jcr:lastModifiedstatic void
setDefaultResourceProperties(Node node, String mimeType, InputStream inputStream, String filename)
Set the default 'hippo:resource' properties: jcr:mimeType jcr:data jcr:lastModified hippo:filenamestatic void
setDefaultResourceProperties(Node node, String mimeType, 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(Node node, String mimeType, InputStream inputStream) throws 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:
RepositoryException
- exception thrown when one of the properties or values could not be set
-
setDefaultResourceProperties
public static void setDefaultResourceProperties(Node node, String mimeType, InputStream inputStream, String filename) throws 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:
RepositoryException
- exception thrown when one of the properties or values could not be set
-
setDefaultResourceProperties
public static void setDefaultResourceProperties(Node node, String mimeType, Binary binary, String filename) throws 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:
RepositoryException
- exception thrown when one of the properties or values could not be set
-
handlePdfAndSetHippoTextProperty
public static void handlePdfAndSetHippoTextProperty(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 ValueFactory getValueFactory(Node node) throws RepositoryException
Gets theValueFactory
from theSession
- Parameters:
node
- theNode
from which to get theSession
- Returns:
- a
ValueFactory
- Throws:
RepositoryException
- In case something goes wrong while trying to get theSession
orValueFactory
-
-