Class AbstractJcrConverter


  • public abstract class AbstractJcrConverter
    extends Object
    Author:
    ehugonnet
    • Constructor Detail

      • AbstractJcrConverter

        public AbstractJcrConverter()
    • Method Detail

      • getStringProperty

        protected String getStringProperty​(javax.jcr.Node node,
                                           String propertyName)
                                    throws 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 - on error
      • getComponentId

        protected String getComponentId​(javax.jcr.Node node)
                                 throws 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.RepositoryException - on error
      • addStringProperty

        public void addStringProperty​(javax.jcr.Node node,
                                      String propertyName,
                                      String value)
                               throws 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.RepositoryException - on error
      • addDateProperty

        public void addDateProperty​(javax.jcr.Node node,
                                    String propertyName,
                                    Date value)
                             throws 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.RepositoryException - on error
      • addCalendarProperty

        public void addCalendarProperty​(javax.jcr.Node node,
                                        String propertyName,
                                        Calendar value)
                                 throws 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.RepositoryException - on error
      • getCalendarProperty

        protected Calendar getCalendarProperty​(javax.jcr.Node node,
                                               String propertyName)
                                        throws 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 - on error
      • getDateProperty

        protected Date getDateProperty​(javax.jcr.Node node,
                                       String propertyName)
                                throws 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 - on error
      • getIntProperty

        protected int getIntProperty​(javax.jcr.Node node,
                                     String propertyName)
                              throws 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 - on error
      • getBooleanProperty

        protected Boolean getBooleanProperty​(javax.jcr.Node node,
                                             String propertyName,
                                             Boolean defaultValueIfNull)
                                      throws 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.
        defaultValueIfNull - the default value of the value does not exist
        Returns:
        the boolean value of the property - false if the property doesn't exist.
        Throws:
        javax.jcr.RepositoryException - on error
      • getLongProperty

        protected long getLongProperty​(javax.jcr.Node node,
                                       String propertyName)
                                throws 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 - on error
      • removeReference

        protected javax.jcr.Value[] removeReference​(javax.jcr.Value[] values,
                                                    String uuid)
                                             throws 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.RepositoryException - on error
      • computeUniqueName

        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.
        Parameters:
        prefix - a prefix to add to the node name
        tableName - the name of the column used to stored the id.
        Returns:
        the name of the node.
      • setContent

        public void setContent​(javax.jcr.Node fileNode,
                               InputStream content,
                               String mimeType)
                        throws javax.jcr.RepositoryException
        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 - the file node
        Returns:
        the mime-type of the jcr:content node stored in the fileNode.
        Throws:
        javax.jcr.RepositoryException - on error
      • 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 - the file node
        Returns:
        the size of the content.
        Throws:
        javax.jcr.RepositoryException - on error
      • setContent

        public void setContent​(javax.jcr.Node fileNode,
                               File file,
                               String mimeType)
                        throws javax.jcr.RepositoryException
        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 - on error
      • getContent

        public byte[] getContent​(javax.jcr.Node fileNode)
                          throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getBinaryContent

        public javax.jcr.Binary getBinaryContent​(javax.jcr.Node fileNode)
                                          throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getContent

        public void getContent​(javax.jcr.Node fileNode,
                               OutputStream out)
                        throws javax.jcr.RepositoryException,
                               IOException
        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 - on error
      • 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 - on error