Refactor JCR exceptions.
[lgpl/argeo-commons.git] / org.argeo.jcr / src / org / argeo / jcr / Jcr.java
index 0f6059c7f36d09dee42d6c0f85feeb55d622512e..fb6f610131842bf546196eeaa7eb3302f029586a 100644 (file)
@@ -36,7 +36,6 @@ import javax.jcr.version.VersionManager;
  * exceptions. Loosely inspired by Java's <code>Files</code> singleton.
  */
 public class Jcr {
-
        /**
         * @see Node#isNodeType(String)
         * @throws IllegalStateException caused by {@link RepositoryException}
@@ -385,6 +384,15 @@ public class Jcr {
                }
        }
 
+       /** Retrieves the root node related to this session. */
+       public static Node getRootNode(Session session) {
+               try {
+                       return session.getRootNode();
+               } catch (RepositoryException e) {
+                       throw new IllegalStateException("Cannot get root node for " + session, e);
+               }
+       }
+
        /**
         * Saves the {@link Session} related to this node. Note that all other unrelated
         * modifications in this session will also be saved.