Class ResourceHelper


  • public class ResourceHelper
    extends Object
    Resource helper for creating and validating nodes of type hippo:resource
    • 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 - the Node on which to set the properties
        mimeType - 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 - the Node on which to set the properties
        mimeType - 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 - the Node on which to set the properties
        mimeType - 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 be null 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 the InputStream 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 - the Node on which to set the '"hippo:text"' property
        inputStream - data stream
      • getValueFactory

        public static javax.jcr.ValueFactory getValueFactory​(javax.jcr.Node node)
                                                      throws javax.jcr.RepositoryException
        Gets the ValueFactory from the Session
        Parameters:
        node - the Node from which to get the Session
        Returns:
        a ValueFactory
        Throws:
        javax.jcr.RepositoryException - In case something goes wrong while trying to get the Session or ValueFactory