Class JcrSession
- java.lang.Object
-
- ch.colabproject.colab.api.persistence.jcr.JcrSession
-
- All Implemented Interfaces:
Serializable
public class JcrSession extends Object implements Serializable
- Author:
- maxence
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JcrSession(javax.jcr.Repository repository, Project project)
Open a JCR session to the repository
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.jcr.Binary
createBinary(InputStream content)
creates a new binary object to be storedjavax.jcr.Node
getNode(String relativePath)
Get a nodejavax.jcr.Session
getSession()
Get JCR sessionjavax.jcr.Node
getWorkspaceRoot()
Get the workspace root nodeboolean
nodeExists(String relativePath)
Does a node exist ?void
prepareForCommit()
make sure to flush all pending operationsvoid
removeNode(String relativePath)
void
rollback()
Close the session without saving any changesvoid
saveAndClose()
Save and close
-
-
-
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 inproject
- 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
-
-