public class ResourceHelper extends Object
hippo:resource
Modifier and Type | Field and Description |
---|---|
static String |
MIME_TYPE_CITRIX_GIF |
static String |
MIME_TYPE_CITRIX_JPEG |
static String |
MIME_TYPE_GIF |
static String |
MIME_TYPE_JPEG |
static String |
MIME_TYPE_PDF |
static String |
MIME_TYPE_PJPEG |
static String |
MIME_TYPE_PNG |
static String |
MIME_TYPE_X_PNG |
Modifier and Type | Method and Description |
---|---|
static javax.jcr.ValueFactory |
getValueFactory(javax.jcr.Node node)
Gets the
ValueFactory from the Session |
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. |
static String |
sanitizeMimeType(String mimeType)
Mimetypes can be a tricky thing as browsers and/or environments tend to alter them without good reason.
|
static void |
setDefaultResourceProperties(javax.jcr.Node node,
String mimeType,
javax.jcr.Binary binary)
Set the default 'hippo:resource' properties:
jcr:mimeType
jcr:data
jcr:lastModified
|
static 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
|
static void |
setDefaultResourceProperties(javax.jcr.Node node,
String mimeType,
InputStream inputStream)
Set the default 'hippo:resource' properties:
jcr:mimeType
jcr:data
jcr:lastModified
|
static 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:filename
|
static void |
validateResource(javax.jcr.Node resource,
String filename) |
public static final String MIME_TYPE_JPEG
public static final String MIME_TYPE_PJPEG
public static final String MIME_TYPE_CITRIX_JPEG
public static final String MIME_TYPE_GIF
public static final String MIME_TYPE_CITRIX_GIF
public static final String MIME_TYPE_PNG
public static final String MIME_TYPE_X_PNG
public static final String MIME_TYPE_PDF
public static String sanitizeMimeType(String mimeType)
mimeType
- The mimetype that needs to be sanitized.public static void validateResource(javax.jcr.Node resource, String filename) throws ResourceException, javax.jcr.RepositoryException
ResourceException
javax.jcr.RepositoryException
public static void setDefaultResourceProperties(javax.jcr.Node node, String mimeType, InputStream inputStream) throws javax.jcr.RepositoryException
node
- the Node
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.javax.jcr.RepositoryException
- exception thrown when one of the properties or values could not be setpublic static void setDefaultResourceProperties(javax.jcr.Node node, String mimeType, InputStream inputStream, String filename) throws javax.jcr.RepositoryException
node
- the Node
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.javax.jcr.RepositoryException
- exception thrown when one of the properties or values could not be setpublic static void setDefaultResourceProperties(javax.jcr.Node node, String mimeType, javax.jcr.Binary binary) throws javax.jcr.RepositoryException
node
- the Node
on which to set the propertiesmimeType
- the mime-type of the binary data (e.g. application/pdf, image/jpeg)binary
- the binary data.javax.jcr.RepositoryException
- exception thrown when one of the properties or values could not be setpublic static void setDefaultResourceProperties(javax.jcr.Node node, String mimeType, javax.jcr.Binary binary, String filename) throws javax.jcr.RepositoryException
node
- the Node
on which to set the propertiesmimeType
- the mime-type of the binary data (e.g. application/pdf, image/jpeg)binary
- the binary data.javax.jcr.RepositoryException
- exception thrown when one of the properties or values could not be setpublic static void handlePdfAndSetHippoTextProperty(javax.jcr.Node node, InputStream inputStream)
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.node
- the Node
on which to set the '"hippo:text"' propertyinputStream
- data streampublic static javax.jcr.ValueFactory getValueFactory(javax.jcr.Node node) throws javax.jcr.RepositoryException
ValueFactory
from the Session
node
- the Node
from which to get the Session
ValueFactory
javax.jcr.RepositoryException
- In case something goes wrong while trying to get the Session
or ValueFactory
Copyright © 2007-2013 Hippo B.V. (http://www.onehippo.com). All Rights Reserved.