Class Document

  • All Implemented Interfaces:
    Serializable

    public class Document
    extends Object
    implements Serializable
    A Plain Old Java Object (POJO) representing a document in a JCR repository. Instances of this object can be returned by workflow calls to indicate to the callee which document has been created or otherwise affected.
    See Also:
    Serialized Form
    • Constructor Detail

      • Document

        public Document()
        Constructor that should be considered to have a protected signature rather than public and may be used for extending classes to create a new Document.
      • Document

        public Document​(String identity)
        Lightweight constructor of a Document only providing a identity.
        Parameters:
        identity - the identifier of a backing Node in the repository that this document instance represents.
      • Document

        public Document​(Document document)
        Copy constructor which allows to pass on a lightweight Document using its internal backing Node
        Parameters:
        document - source document to copy the identity and possible the internal backing Node from
      • Document

        public Document​(javax.jcr.Node node)
                 throws javax.jcr.RepositoryException
        Extended classes must honor this constructor!
        Parameters:
        node - the backing Node in the repository that this document instance represents.
        Throws:
        javax.jcr.RepositoryException
    • Method Detail

      • getNode

        public javax.jcr.Node getNode​(javax.jcr.Session session)
                               throws javax.jcr.RepositoryException
        Returns the backing Node of this Document, either directly if available and already tied to the provided Session or else retrieved from the provided Session based on its getIdentity().
        Parameters:
        session - The session for which to return the backing Node
        Returns:
        the backing Node of this Document or null if this Document doesn't contain a identity
        Throws:
        javax.jcr.RepositoryException
      • getCheckedOutNode

        public javax.jcr.Node getCheckedOutNode​(javax.jcr.Session session)
                                         throws javax.jcr.RepositoryException
        Returns the ensured to be checked out backing Node of this Document, either directly if available and already tied to the provided Session or else retrieved from the provided Session based on its getIdentity().
        Parameters:
        session - The session for which to return the backing Node
        Returns:
        the ensured to be checked out backing Node of this Document or null if this Document doesn't contain a identity
        Throws:
        javax.jcr.RepositoryException
      • hasNode

        public boolean hasNode()
        Returns:
        true if this document has a backing Node
      • getIdentity

        public final String getIdentity()
        Obtain the identity, if known at this point, of a document. The identity of a Document is the identity of the primary Node used in persisting the data of the document.

        A Document returned for example by a workflow step can be accessed using:
        Node node = session.getNodeByIdentifier(document.getIdentity());
        or even easier and possibly more efficient:
        Node node = document.getNode(session);
        Returns:
        a string containing the UUID of the Node representing the Document. or null if not available.
      • getNode

        protected javax.jcr.Node getNode()
      • getCheckedOutNode

        protected javax.jcr.Node getCheckedOutNode()
                                            throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • initialize

        protected final void initialize​(javax.jcr.Node node)
                                 throws javax.jcr.RepositoryException
        Extended classes which need custom/extra initialization based on the backing Node should use the initialized() method to get wired into the initialization chain.
        Parameters:
        node - the backing Node in the repository that this document instance represents.
        Throws:
        javax.jcr.RepositoryException
      • initialized

        protected void initialized()
        Extended classes which need custom/extra initialization based on the backing Node can use this method which will get called after initialize(javax.jcr.Node) has been called.
      • getStringProperty

        protected String getStringProperty​(String relPath)
                                    throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • setStringProperty

        protected void setStringProperty​(String relPath,
                                         String value)
                                  throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getStringsProperty

        protected String[] getStringsProperty​(String relPath)
                                       throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • setStringsProperty

        protected void setStringsProperty​(String relPath,
                                          String[] values)
                                   throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getNodeProperty

        protected javax.jcr.Node getNodeProperty​(String relPath)
                                          throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • setNodeProperty

        protected void setNodeProperty​(String relPath,
                                       javax.jcr.Node nodeValue)
                                throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getDateProperty

        protected Date getDateProperty​(String relPath)
                                throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • setDateProperty

        protected void setDateProperty​(String relPath,
                                       Date date)
                                throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getLongProperty

        protected Long getLongProperty​(String relPath)
                                throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • setLongProperty

        protected void setLongProperty​(String relPath,
                                       Long newValue)
                                throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getBooleanProperty

        protected Boolean getBooleanProperty​(String relPath)
                                      throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • setBooleanProperty

        protected void setBooleanProperty​(String relPath,
                                          Boolean newValue)
                                   throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException