org.silverpeas.util.jcr
Class AbstractJcrConverter

java.lang.Object
  extended by org.silverpeas.util.jcr.AbstractJcrConverter
Direct Known Subclasses:
SimpleAttachmentConverter

public abstract class AbstractJcrConverter
extends Object

Author:
ehugonnet

Constructor Summary
AbstractJcrConverter()
           
 
Method Summary
 void addCalendarProperty(javax.jcr.Node node, String propertyName, Calendar value)
          Defines the Calendar value of a JCR Node's property.
 void addDateProperty(javax.jcr.Node node, String propertyName, Date value)
          Defines the Calendar value of a JCR Node's property.
 void addStringProperty(javax.jcr.Node node, String propertyName, String value)
          Defines the value of a JCR Node's property.
protected  String computeUniqueName(String prefix, String tableName)
          Compute a unique node name if a node with the same name already exists under the same parent node.
 javax.jcr.Binary getBinaryContent(javax.jcr.Node fileNode)
           
protected  boolean getBooleanProperty(javax.jcr.Node node, String propertyName)
          Return the property value as a boolean for a JCR Node.
protected  Calendar getCalendarProperty(javax.jcr.Node node, String propertyName)
          Return the property value as Calendar for a JCR Node.
protected  String getComponentId(javax.jcr.Node node)
          Compute the componentId corresponding to the specified node by checking the name of the first Ancestor.
 byte[] getContent(javax.jcr.Node fileNode)
           
 void getContent(javax.jcr.Node fileNode, OutputStream out)
           
 String getContentMimeType(javax.jcr.Node fileNode)
          Returns the mime-type of the jcr:content node stored in the fileNode.
 long getContentSize(javax.jcr.Node fileNode)
          Return the size of the file in the jcr:content node which is a child node of the specified node.
protected  Date getDateProperty(javax.jcr.Node node, String propertyName)
          Return the property value as java.util.Date for a JCR Node.
 javax.jcr.Node getFolder(javax.jcr.Node parent, String name)
          Return the node whith the specified parent and name.
protected  int getIntProperty(javax.jcr.Node node, String propertyName)
          Return the property value as an int for a JCR Node.
protected  long getLongProperty(javax.jcr.Node node, String propertyName)
          Return the property value as an long for a JCR Node.
protected  String getStringProperty(javax.jcr.Node node, String propertyName)
          Return the property value as String for a JCR Node.
 boolean isMixinApplied(javax.jcr.Node node, String mixin)
          Return true if the specified mixin type is explicitly assigned to the node.
protected  javax.jcr.Value[] removeReference(javax.jcr.Value[] values, String uuid)
          Remove a reference from an array of javax.jcr.Value.
 void setContent(javax.jcr.Node fileNode, byte[] content, String mimeType)
          Add binary content to the specified node.
 void setContent(javax.jcr.Node fileNode, File file, String mimeType)
           
 void setContent(javax.jcr.Node fileNode, InputStream content, String mimeType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJcrConverter

public AbstractJcrConverter()
Method Detail

getStringProperty

protected String getStringProperty(javax.jcr.Node node,
                                   String propertyName)
                            throws javax.jcr.ValueFormatException,
                                   javax.jcr.RepositoryException
Return the property value as String for a JCR Node. If the property doesn't exist return null.

Parameters:
node - the node whose property is required.
propertyName - the name of the property required.
Returns:
the String value of the property - null if the property doesn't exist.
Throws:
javax.jcr.RepositoryException
javax.jcr.ValueFormatException

getComponentId

protected String getComponentId(javax.jcr.Node node)
                         throws javax.jcr.ItemNotFoundException,
                                javax.jcr.AccessDeniedException,
                                javax.jcr.RepositoryException
Compute the componentId corresponding to the specified node by checking the name of the first Ancestor.

Parameters:
node - the node whose componentId is required.
Returns:
the componentId of the specified node.
Throws:
javax.jcr.ItemNotFoundException
javax.jcr.AccessDeniedException
javax.jcr.RepositoryException

addStringProperty

public void addStringProperty(javax.jcr.Node node,
                              String propertyName,
                              String value)
                       throws javax.jcr.version.VersionException,
                              javax.jcr.lock.LockException,
                              javax.jcr.nodetype.ConstraintViolationException,
                              javax.jcr.RepositoryException
Defines the value of a JCR Node's property. If the specified value is null then the corresponding property is removed from the Node.

Parameters:
node - the node whose property is being set.
propertyName - the name of the property being set.
value - the value being set. If it is null then the property is removed.
Throws:
javax.jcr.version.VersionException
javax.jcr.lock.LockException
javax.jcr.nodetype.ConstraintViolationException
javax.jcr.RepositoryException

addDateProperty

public void addDateProperty(javax.jcr.Node node,
                            String propertyName,
                            Date value)
                     throws javax.jcr.version.VersionException,
                            javax.jcr.lock.LockException,
                            javax.jcr.nodetype.ConstraintViolationException,
                            javax.jcr.RepositoryException
Defines the Calendar value of a JCR Node's property. If the specified value is null then the corresponding property is removed from the Node.

Parameters:
node - the node whose property is being set.
propertyName - the name of the property being set.
value - the value being set. If it is null then the property is removed.
Throws:
javax.jcr.version.VersionException
javax.jcr.lock.LockException
javax.jcr.nodetype.ConstraintViolationException
javax.jcr.RepositoryException

addCalendarProperty

public void addCalendarProperty(javax.jcr.Node node,
                                String propertyName,
                                Calendar value)
                         throws javax.jcr.version.VersionException,
                                javax.jcr.lock.LockException,
                                javax.jcr.nodetype.ConstraintViolationException,
                                javax.jcr.RepositoryException
Defines the Calendar value of a JCR Node's property. If the specified value is null then the corresponding property is removed from the Node.

Parameters:
node - the node whose property is being set.
propertyName - the name of the property being set.
value - the value being set. If it is null then the property is removed.
Throws:
javax.jcr.version.VersionException
javax.jcr.lock.LockException
javax.jcr.nodetype.ConstraintViolationException
javax.jcr.RepositoryException

getCalendarProperty

protected Calendar getCalendarProperty(javax.jcr.Node node,
                                       String propertyName)
                                throws javax.jcr.ValueFormatException,
                                       javax.jcr.RepositoryException
Return the property value as Calendar for a JCR Node. If the property doesn't exist return null.

Parameters:
node - the node whose property is required.
propertyName - the name of the property required.
Returns:
the Calendar value of the property - null if the property doesn't exist.
Throws:
javax.jcr.RepositoryException
javax.jcr.ValueFormatException

getDateProperty

protected Date getDateProperty(javax.jcr.Node node,
                               String propertyName)
                        throws javax.jcr.ValueFormatException,
                               javax.jcr.RepositoryException
Return the property value as java.util.Date for a JCR Node. If the property doesn't exist return null.

Parameters:
node - the node whose property is required.
propertyName - the name of the property required.
Returns:
the java.util.Date value of the property - null if the property doesn't exist.
Throws:
javax.jcr.RepositoryException
javax.jcr.ValueFormatException

getIntProperty

protected int getIntProperty(javax.jcr.Node node,
                             String propertyName)
                      throws javax.jcr.ValueFormatException,
                             javax.jcr.RepositoryException
Return the property value as an int for a JCR Node. If the property doesn't exist return 0.

Parameters:
node - the node whose property is required.
propertyName - the name of the property required.
Returns:
the int value of the property - 0 if the property doesn't exist.
Throws:
javax.jcr.RepositoryException
javax.jcr.ValueFormatException

getBooleanProperty

protected boolean getBooleanProperty(javax.jcr.Node node,
                                     String propertyName)
                              throws javax.jcr.ValueFormatException,
                                     javax.jcr.RepositoryException
Return the property value as a boolean for a JCR Node. If the property doesn't exist return false.

Parameters:
node - the node whose property is required.
propertyName - the name of the property required.
Returns:
the boolean value of the property - false if the property doesn't exist.
Throws:
javax.jcr.RepositoryException
javax.jcr.ValueFormatException

getLongProperty

protected long getLongProperty(javax.jcr.Node node,
                               String propertyName)
                        throws javax.jcr.ValueFormatException,
                               javax.jcr.RepositoryException
Return the property value as an long for a JCR Node. If the property doesn't exist return 0.

Parameters:
node - the node whose property is required.
propertyName - the name of the property required.
Returns:
the long value of the property - 0 if the property doesn't exist.
Throws:
javax.jcr.RepositoryException
javax.jcr.ValueFormatException

removeReference

protected javax.jcr.Value[] removeReference(javax.jcr.Value[] values,
                                            String uuid)
                                     throws javax.jcr.ValueFormatException,
                                            IllegalStateException,
                                            javax.jcr.RepositoryException
Remove a reference from an array of javax.jcr.Value. If the reference is not found no change is done to the array.

Parameters:
values - the array of references
uuid - the reference to be removed
Returns:
the updated arry of references.
Throws:
javax.jcr.ValueFormatException
IllegalStateException
javax.jcr.RepositoryException

computeUniqueName

protected String computeUniqueName(String prefix,
                                   String tableName)
                            throws UtilException
Compute a unique node name if a node with the same name already exists under the same parent node.

Parameters:
prefix -
tableName - the name of the column used to stored the id.
Returns:
the name of the node.
Throws:
UtilException

setContent

public void setContent(javax.jcr.Node fileNode,
                       InputStream content,
                       String mimeType)
                throws javax.jcr.RepositoryException
Parameters:
fileNode -
content -
mimeType -
Throws:
javax.jcr.RepositoryException

getContentMimeType

public String getContentMimeType(javax.jcr.Node fileNode)
                          throws javax.jcr.RepositoryException
Returns the mime-type of the jcr:content node stored in the fileNode.

Parameters:
fileNode -
Returns:
the mime-type of the jcr:content node stored in the fileNode.
Throws:
javax.jcr.RepositoryException

getContentSize

public long getContentSize(javax.jcr.Node fileNode)
                    throws javax.jcr.RepositoryException
Return the size of the file in the jcr:content node which is a child node of the specified node.

Parameters:
fileNode -
Returns:
the size of the content.
Throws:
javax.jcr.RepositoryException

setContent

public void setContent(javax.jcr.Node fileNode,
                       File file,
                       String mimeType)
                throws javax.jcr.RepositoryException
Parameters:
fileNode -
file -
mimeType -
Throws:
javax.jcr.RepositoryException

setContent

public void setContent(javax.jcr.Node fileNode,
                       byte[] content,
                       String mimeType)
                throws javax.jcr.RepositoryException
Add binary content to the specified node.

Parameters:
fileNode - the node.
content - the binary content.
mimeType - the mime type of the content.
Throws:
javax.jcr.RepositoryException

getContent

public byte[] getContent(javax.jcr.Node fileNode)
                  throws javax.jcr.RepositoryException
Parameters:
fileNode -
Returns:
Throws:
javax.jcr.RepositoryException

getBinaryContent

public javax.jcr.Binary getBinaryContent(javax.jcr.Node fileNode)
                                  throws javax.jcr.RepositoryException
Parameters:
fileNode -
Returns:
Throws:
javax.jcr.RepositoryException

getContent

public void getContent(javax.jcr.Node fileNode,
                       OutputStream out)
                throws javax.jcr.RepositoryException,
                       IOException
Parameters:
fileNode -
out -
Throws:
javax.jcr.RepositoryException
IOException

getFolder

public javax.jcr.Node getFolder(javax.jcr.Node parent,
                                String name)
                         throws javax.jcr.RepositoryException
Return the node whith the specified parent and name. Create a nt:folder with the specified parent and name if the node doesn't exist.

Parameters:
parent - parent node of the folder.
name - name of the folder.
Returns:
the node whith the specified parent and name.
Throws:
javax.jcr.RepositoryException

isMixinApplied

public boolean isMixinApplied(javax.jcr.Node node,
                              String mixin)
                       throws javax.jcr.RepositoryException
Return true if the specified mixin type is explicitly assigned to the node. It does not include mixin types inherited through the addition of supertypes to the primary type hierarchy or through the addition of supertypes to the type hierarchy of any of the declared mixin types.

Parameters:
node - the node on which we are looking for the specified mixin.
mixin - the name of the mixin.
Returns:
rue if the specified mixin type is explicitly assigned to the node false otherwise.
Throws:
javax.jcr.RepositoryException


Copyright © 2016 Silverpeas. All Rights Reserved.