--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.argeo.commons</groupId>
+ <version>0.1.2-SNAPSHOT</version>
+ <artifactId>argeo-commons</artifactId>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>sandbox</artifactId>
+ <name>Commons Sandbox</name>
+ <packaging>pom</packaging>
+ <modules>
+ <module>runtime</module>
+ </modules>
+</project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.sandbox.jackrabbit</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+#Wed Nov 18 14:52:46 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
--- /dev/null
+#Wed Nov 18 14:52:42 CET 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.argeo.commons.sandbox</groupId>
+ <version>0.1.2-SNAPSHOT</version>
+ <artifactId>runtime</artifactId>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>org.argeo.sandbox.jackrabbit</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.argeo.dep.osgi</groupId>
+ <artifactId>org.argeo.dep.osgi.jackrabbit</artifactId>
+ <version>1.6.0.0001</version>
+ </dependency>
+ <dependency>
+ <groupId>org.argeo.commons.basic</groupId>
+ <artifactId>org.argeo.basic.dep.log4j</artifactId>
+ <version>0.1.2-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>com.springsource.org.apache.derby</artifactId>
+ <version>10.5.1000001.764942</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
--- /dev/null
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import org.apache.jackrabbit.core.TransientRepository;
+
+/**
+ * First hop example. Logs in to a content repository and prints a
+ * status message.
+ */
+public class FirstHop {
+
+ /**
+ * The main entry point of the example application.
+ *
+ * @param args command line arguments (ignored)
+ * @throws Exception if an error occurs
+ */
+ public static void main(String[] args) throws Exception {
+ Repository repository = new TransientRepository();
+ Session session = repository.login();
+ try {
+ String user = session.getUserID();
+ String name = repository.getDescriptor(Repository.REP_NAME_DESC);
+ System.out.println(
+ "Logged in as " + user + " to a " + name + " repository.");
+ } finally {
+ session.logout();
+ }
+ }
+
+}
--- /dev/null
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Node;
+import org.apache.jackrabbit.core.TransientRepository;
+
+/**
+ * Second hop example. Stores, retrieves, and removes example content.
+ */
+public class SecondHop {
+
+ /**
+ * The main entry point of the example application.
+ *
+ * @param args command line arguments (ignored)
+ * @throws Exception if an error occurs
+ */
+ public static void main(String[] args) throws Exception {
+ Repository repository = new TransientRepository();
+ Session session = repository.login(
+ new SimpleCredentials("username", "password".toCharArray()));
+ try {
+ Node root = session.getRootNode();
+
+ // Store content
+ Node hello = root.addNode("hello");
+ Node world = hello.addNode("world");
+ world.setProperty("message", "Hello, World!");
+ session.save();
+
+ // Retrieve content
+ Node node = root.getNode("hello/world");
+ System.out.println(node.getPath());
+ System.out.println(node.getProperty("message").getString());
+
+ // Remove content
+ root.getNode("hello").remove();
+ session.save();
+ } finally {
+ session.logout();
+ }
+ }
+
+}
--- /dev/null
+import javax.jcr.*;
+import org.apache.jackrabbit.core.TransientRepository;
+import java.io.FileInputStream;
+
+/**
+ * Third Jackrabbit example application. Imports an example XML file
+ * and outputs the contents of the entire workspace.
+ */
+public class ThirdHop {
+
+ /** Runs the ThirdHop example. */
+ public static void main(String[] args) throws Exception {
+ // Set up a Jackrabbit repository with the specified
+ // configuration file and repository directory
+ Repository repository = new TransientRepository();
+
+ // Login to the default workspace as a dummy user
+ Session session = repository.login(
+ new SimpleCredentials("username", "password".toCharArray()));
+ try {
+ // Use the root node as a starting point
+ Node root = session.getRootNode();
+
+ // Import the XML file unless already imported
+ if (!root.hasNode("importxml")) {
+ System.out.print("Importing xml... ");
+ // Create an unstructured node under which to import the XML
+ Node node = root.addNode("importxml", "nt:unstructured");
+ // Import the file "test.xml" under the created node
+ FileInputStream xml = new FileInputStream("test.xml");
+ session.importXML(
+ "/importxml", xml, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+ xml.close();
+ // Save the changes to the repository
+ session.save();
+ System.out.println("done.");
+ }
+
+ dump(root);
+ } finally {
+ session.logout();
+ }
+ }
+
+ /** Recursively outputs the contents of the given node. */
+ private static void dump(Node node) throws RepositoryException {
+ // First output the node path
+ System.out.println(node.getPath());
+ // Skip the virtual (and large!) jcr:system subtree
+ if (node.getName().equals("jcr:system")) {
+ return;
+ }
+
+ // Then output the properties
+ PropertyIterator properties = node.getProperties();
+ while (properties.hasNext()) {
+ Property property = properties.nextProperty();
+ if (property.getDefinition().isMultiple()) {
+ // A multi-valued property, print all values
+ Value[] values = property.getValues();
+ for (int i = 0; i < values.length; i++) {
+ System.out.println(
+ property.getPath() + " = " + values[i].getString());
+ }
+ } else {
+ // A single-valued property
+ System.out.println(
+ property.getPath() + " = " + property.getString());
+ }
+ }
+
+ // Finally output all the child nodes recursively
+ NodeIterator nodes = node.getNodes();
+ while (nodes.hasNext()) {
+ dump(nodes.nextNode());
+ }
+ }
+
+}
--- /dev/null
+package jcr;
+
+import org.apache.jackrabbit.core.TransientRepository;
+
+import javax.jcr.*;
+import java.io.IOException;
+
+public abstract class Base {
+ public Repository getRepository() throws IOException {
+ return new TransientRepository();
+ }
+
+ public Session getReadonlySession(Repository repository) throws RepositoryException {
+ return repository.login();
+ }
+
+ public Session getSession(Repository repository) throws RepositoryException {
+ return repository.login(new SimpleCredentials("username", "password".toCharArray()));
+ }
+
+ public void logout(Session session) {
+ session.logout();
+ }
+}
--- /dev/null
+package jcr;
+
+import javax.jcr.*;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+public class CommandLineQuery extends Base {
+ public CommandLineQuery() {
+ }
+
+ public static void main(String[] args) throws IOException, RepositoryException {
+ CommandLineQuery clq=new CommandLineQuery();
+ clq.run();
+ }
+
+ private void run() throws IOException, RepositoryException {
+ Repository repository=getRepository();
+ Session session=getReadonlySession(repository);
+ Workspace workspace=session.getWorkspace();
+ QueryManager qm=workspace.getQueryManager();
+ BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
+ for(;;) {
+ System.out.print("JCRQL> ");
+ String queryString=reader.readLine();
+ if(queryString.equals("quit")) {
+ break;
+ }
+ if(queryString.length()==0 || queryString.startsWith("#")) {
+ continue;
+ }
+
+ int resultCounter=0;
+ try {
+ Query query=qm.createQuery(queryString, Query.XPATH);
+ QueryResult queryResult=query.execute();
+ NodeIterator nodeIterator=queryResult.getNodes();
+ while(nodeIterator.hasNext()) {
+ Node node=nodeIterator.nextNode();
+ dump(node);
+ resultCounter++;
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("result count: "+resultCounter);
+ }
+ logout(session);
+ }
+
+ private void dump(Node node) throws RepositoryException {
+ StringBuilder sb=new StringBuilder();
+ String sep=",";
+ sb.append(node.getName());
+ sb.append("["+node.getPath());
+ PropertyIterator propIterator=node.getProperties();
+ while(propIterator.hasNext()) {
+ Property prop=propIterator.nextProperty();
+ sb.append(sep);
+ sb.append("@"+prop.getName()+"=\""+prop.getString()+"\"");
+ }
+ sb.append("]");
+ System.out.println(sb.toString());
+ }
+}
--- /dev/null
+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);
+ }
+}
--- /dev/null
+package jcr;
+
+import javax.jcr.*;
+import java.io.IOException;
+
+public class RemoveData extends Base {
+ public RemoveData() {
+ }
+
+ public static void main(String[] args) throws IOException, RepositoryException {
+ RemoveData sd = new RemoveData();
+ sd.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");
+ childnode.remove();
+ session.save();
+ } catch (PathNotFoundException pnfe) {
+ System.out.println("/foo not found; not removed.");
+ }
+
+ logout(session);
+ }
+}
--- /dev/null
+package jcr;
+
+import javax.jcr.*;
+import java.io.IOException;
+
+public class StoreData extends Base {
+ public StoreData() {
+ }
+
+ public static void main(String[] args) throws IOException, RepositoryException {
+ StoreData sd=new StoreData();
+ sd.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");
+ } catch(PathNotFoundException pnfe) {
+ childnode=rootnode.addNode("foo");
+ childnode.setProperty("bar", "this is some data");
+ session.save();
+ }
+
+ logout(session);
+ }
+}
--- /dev/null
+package webdav;
+
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
+import org.apache.jackrabbit.webdav.client.methods.PutMethod;
+
+public class WebDavTest {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ try {
+ HostConfiguration hostConfig = new HostConfiguration();
+ hostConfig.setHost("localhost", 8082);
+ // hostConfig.
+ HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
+ HttpConnectionManagerParams params = new HttpConnectionManagerParams();
+ int maxHostConnections = 20;
+ params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
+ connectionManager.setParams(params);
+ HttpClient client = new HttpClient(connectionManager);
+ Credentials creds = new UsernamePasswordCredentials("scanner1",
+ "scanner1");
+ client.getState().setCredentials(AuthScope.ANY, creds);
+ client.setHostConfiguration(hostConfig);
+ // return client;
+
+ PutMethod pm = new PutMethod(
+ "http://localhost:8082/webdav/scanner1_queque/uploader/image_"
+ + ".txt");
+ String text = "this is the document content";
+ pm.setRequestBody(text);
+ client.executeMethod(pm);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
--- /dev/null
+# ***** Set root logger level to DEBUG and its only appender to A.
+log4j.rootLogger=WARN, A
+
+# ***** A is set to be a ConsoleAppender.
+log4j.appender.A=org.apache.log4j.ConsoleAppender
+# ***** A uses PatternLayout.
+log4j.appender.A.layout=org.apache.log4j.PatternLayout
+log4j.appender.A.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
--- /dev/null
+<xhtml:html xmlns="svg" xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns:mathml="http://www.w3.org/1998/Math/MathML">
+ <xhtml:head>
+ <xhtml:title>Three Namespaces</xhtml:title>
+ </xhtml:head>
+ <xhtml:body>
+ <xhtml:h1 align="center">An Ellipse and a Rectangle</xhtml:h1>
+ <svg:svg xmlns:svg="http://www.w3.org/2000/svg" width="12cm"
+ height="10cm">
+ <svg:ellipse rx="110" ry="130" />
+ <svg:rect x="4cm" y="1cm" width="3cm" height="6cm" />
+ </svg:svg>
+ <xhtml:p>The equation for ellipses</xhtml:p>
+ <mathml:math>
+ <mathml:apply>
+ <mathml:eq />
+ <mathml:cn> 1 </mathml:cn>
+ <mathml:apply>
+ <mathml:plus />
+ <mathml:apply>
+ <mathml:divide />
+ <mathml:apply>
+ <mathml:power />
+ <mathml:ci> x </mathml:ci>
+ <mathml:cn> 2 </mathml:cn>
+ </mathml:apply>
+ <mathml:apply>
+ <mathml:power />
+ <mathml:ci> a </mathml:ci>
+ <mathml:cn> 2 </mathml:cn>
+ </mathml:apply>
+ </mathml:apply>
+ <mathml:apply>
+ <mathml:divide />
+ <mathml:apply>
+ <mathml:power />
+ <mathml:ci> y </mathml:ci>
+ <mathml:cn> 2 </mathml:cn>
+ </mathml:apply>
+ <mathml:apply>
+ <mathml:power />
+ <mathml:ci> b </mathml:ci>
+ <mathml:cn> 2 </mathml:cn>
+ </mathml:apply>
+ </mathml:apply>
+ </mathml:apply>
+ </mathml:apply>
+ </mathml:math>
+ <xhtml:hr />
+ <xhtml:p>Last Modified January 10, 2002</xhtml:p>
+ </xhtml:body>
+</xhtml:html>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.argeo.commons</groupId>
+ <version>0.1.2-SNAPSHOT</version>
+ <artifactId>sandbox</artifactId>
+ <relativePath>..</relativePath>
+ </parent>
+ <groupId>org.argeo.commons.sandbox</groupId>
+ <artifactId>runtime</artifactId>
+ <name>Commons Sandbox Runtime</name>
+ <packaging>pom</packaging>
+ <modules>
+ <module>org.argeo.sandbox.jackrabbit</module>
+ </modules>
+</project>
\ No newline at end of file