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 type hippo:resource
  • Method Details

    • 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 - 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:
      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 - 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:
      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 - 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:
      RepositoryException - exception thrown when one of the properties or values could not be set
    • handlePdfAndSetHippoTextProperty

      public static void handlePdfAndSetHippoTextProperty(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 ValueFactory getValueFactory(Node node) throws RepositoryException
      Gets the ValueFactory from the Session
      Parameters:
      node - the Node from which to get the Session
      Returns:
      a ValueFactory
      Throws:
      RepositoryException - In case something goes wrong while trying to get the Session or ValueFactory