Introduce Jackrabbit sandbox
[lgpl/argeo-commons.git] / sandbox / runtime / org.argeo.sandbox.jackrabbit / src / main / java / jcr / ReadData.java
diff --git a/sandbox/runtime/org.argeo.sandbox.jackrabbit/src/main/java/jcr/ReadData.java b/sandbox/runtime/org.argeo.sandbox.jackrabbit/src/main/java/jcr/ReadData.java
new file mode 100644 (file)
index 0000000..7c8164e
--- /dev/null
@@ -0,0 +1,37 @@
+package jcr;
+
+import javax.jcr.*;
+import java.io.IOException;
+
+public class ReadData extends Base {
+    public ReadData() {
+    }
+
+    public static void main(String[] args) throws IOException, RepositoryException {
+        ReadData readdata = new ReadData();
+        readdata.run();
+    }
+
+    private void run() throws IOException, RepositoryException {
+        Repository repository = getRepository();
+
+        Session session = getSession(repository);
+
+        Node rootnode = session.getRootNode();
+
+        Node childnode = null;
+        try {
+            childnode = rootnode.getNode("foo");
+            try {
+                Property prop = childnode.getProperty("bar");
+                System.out.println("value of /foo@bar: " + prop.getString());
+            } catch (PathNotFoundException pnfe) {
+                System.out.println("/foo@bar not found.");
+            }
+        } catch (PathNotFoundException pnfe) {
+            System.out.println("/foo not found.");
+        }
+
+        logout(session);
+    }
+}