Class JcrSession
java.lang.Object
ch.colabproject.colab.api.persistence.jcr.JcrSession
- All Implemented Interfaces:
Serializable
- Author:
- maxence
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJcrSession(javax.jcr.Repository repository, Project project) Open a JCR session to the repository -
Method Summary
Modifier and TypeMethodDescriptionjavax.jcr.BinarycreateBinary(InputStream content) creates a new binary object to be storedjavax.jcr.NodeGet a nodejavax.jcr.SessionGet JCR sessionjavax.jcr.NodeGet the workspace root nodebooleannodeExists(String relativePath) Does a node exist ?voidmake sure to flush all pending operationsvoidremoveNode(String relativePath) voidrollback()Close the session without saving any changesvoidSave and close
-
Constructor Details
-
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 Details
-
getWorkspaceRoot
public javax.jcr.Node getWorkspaceRoot()Get the workspace root node- Returns:
- workspace root
-
nodeExists
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
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
- 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.RepositoryExceptionmake sure to flush all pending operations- Throws:
javax.jcr.RepositoryException- something went wrong
-
createBinary
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
-