Class JcrSession

    • Constructor Detail

      • JcrSession

        public JcrSession​(javax.jcr.Repository repository,
                          Project project)
                   throws javax.jcr.RepositoryException
        Open a JCR session to the repository
        Parameters:
        repository - the repository to log in
        project - project
        Throws:
        javax.jcr.RepositoryException - in case of JCR issue
    • Method Detail

      • getWorkspaceRoot

        public javax.jcr.Node getWorkspaceRoot()
        Get the workspace root node
        Returns:
        workspace root
      • nodeExists

        public boolean nodeExists​(String relativePath)
        Does a node exist ?
        Parameters:
        relativePath - relativePath path relative to the workspace root. May starts with a / or not
        Returns:
        the node or null if it does not exist
      • getNode

        public javax.jcr.Node getNode​(String relativePath)
        Get a node
        Parameters:
        relativePath - relativePath relative to the workspace root. May starts with a / or not
        Returns:
        the node or null if it does not exist
      • removeNode

        public void removeNode​(String relativePath)
        Parameters:
        relativePath - relative path from workspace root
      • getSession

        public javax.jcr.Session getSession()
        Get JCR session
        Returns:
        the session
      • prepareForCommit

        public void prepareForCommit()
                              throws javax.jcr.RepositoryException
        make sure to flush all pending operations
        Throws:
        javax.jcr.RepositoryException - something went wrong
      • createBinary

        public javax.jcr.Binary createBinary​(InputStream content)
                                      throws javax.jcr.RepositoryException
        creates a new binary object to be stored
        Parameters:
        content - content to be stored in the binary
        Returns:
        The created binary
        Throws:
        javax.jcr.RepositoryException - JCR issue
      • saveAndClose

        public void saveAndClose()
        Save and close
      • rollback

        public void rollback()
        Close the session without saving any changes