jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r498217 [1/2] - in /jackrabbit/trunk/contrib/jackrabbit-spi-xml: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/spi/ src/main/java/org/a...
Date Sun, 21 Jan 2007 00:26:55 GMT
Author: jukka
Date: Sat Jan 20 16:26:53 2007
New Revision: 498217

URL: http://svn.apache.org/viewvc?view=rev&rev=498217
Log:
contrib: Added an early in-memory level 1 XML content repository implementation based on the SPI.

Added:
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/   (with props)
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/pom.xml
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLIdFactory.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLItemInfo.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeId.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeIdIterator.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeInfo.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPrimaryTypeId.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPrimaryTypeInfo.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPropertyIdIterator.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPropertyInfo.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryConfig.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryFactory.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryService.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLSessionInfo.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQItemDefinition.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeDefinition.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeTypeDefinition.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeTypeDefinitionIterator.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQPropertyDefinition.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/org/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/org/apache/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/org/apache/jackrabbit/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/org/apache/jackrabbit/spi/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/org/apache/jackrabbit/spi/xml/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/org/apache/jackrabbit/spi/xml/types.cnd
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/java/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/java/org/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/java/org/apache/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/java/org/apache/jackrabbit/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/java/org/apache/jackrabbit/spi/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/java/org/apache/jackrabbit/spi/xml/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/java/org/apache/jackrabbit/spi/xml/TestAll.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/java/org/apache/jackrabbit/spi/xml/XMLRepositoryStub.java
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/resources/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/resources/org/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/resources/org/apache/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/resources/org/apache/jackrabbit/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/resources/org/apache/jackrabbit/spi/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/resources/org/apache/jackrabbit/spi/xml/
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/resources/org/apache/jackrabbit/spi/xml/repository.xml
    jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/test/resources/repositoryStubImpl.properties

Propchange: jackrabbit/trunk/contrib/jackrabbit-spi-xml/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Jan 20 16:26:53 2007
@@ -0,0 +1,5 @@
+target
+.project
+.classpath
+.checkstyle
+.settings

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/pom.xml?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/pom.xml (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/pom.xml Sat Jan 20 16:26:53 2007
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  -->
+
+<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>
+
+<!-- ====================================================================== -->
+<!-- P R O J E C T  D E S C R I P T I O N                                   -->
+<!-- ====================================================================== -->
+  <parent>
+    <groupId>org.apache.jackrabbit</groupId>
+    <artifactId>jackrabbit</artifactId>
+    <version>1.3-SNAPSHOT</version>
+    <relativePath>../..</relativePath>
+  </parent>
+  <artifactId>jackrabbit-spi-xml</artifactId>
+  <name>Jackrabbit SPI XML</name>
+  <description>SPI based XML content repository</description>
+
+  <scm>
+    <connection>
+      scm:svn:http://svn.apache.org/repos/asf/jackrabbit/trunk/contrib/jackrabbit-spi-xml
+    </connection>
+    <developerConnection>
+      scm:svn:https://svn.apache.org/repos/asf/jackrabbit/contrib/jackrabbit-spi-xml
+    </developerConnection>
+    <url>http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml</url>
+  </scm>
+
+  <dependencies>
+    <dependency>
+      <groupId>javax.jcr</groupId>
+      <artifactId>jcr</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-spi-jcr2spi</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-core</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr-tests</artifactId>
+      <version>${pom.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLIdFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLIdFactory.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLIdFactory.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLIdFactory.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PropertyId;
+
+public class XMLIdFactory implements IdFactory {
+
+    private final XMLNodeId root;
+
+    public XMLIdFactory(XMLNodeId root) {
+        this.root = root;
+    }
+
+    //------------------------------------------------------------< IdFactory>
+
+    public NodeId createNodeId(String id) {
+        return null;
+    }
+
+    public NodeId createNodeId(NodeId id, Path path) {
+        try {
+            return ((XMLNodeId) id).getNodeId(path);
+        } catch (ClassCastException e) {
+            throw new IllegalStateException("Invalid node identifier: " + id);
+        }
+    }
+
+    public NodeId createNodeId(String id, Path path) {
+        if (id == null) {
+            return createNodeId(root, path);
+        } else {
+            return null;
+        }
+    }
+
+    public PropertyId createPropertyId(NodeId id, QName name) {
+        try {
+            if (QName.JCR_PRIMARYTYPE.equals(name)) {
+                return new XMLPrimaryTypeId(id);
+            } else {
+                return ((XMLNodeId) id).getPropertyId(name);
+            }
+        } catch (ClassCastException e) {
+            throw new IllegalStateException("Invalid node identifier: " + id);
+        }
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLItemInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLItemInfo.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLItemInfo.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLItemInfo.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.ItemInfo;
+import org.apache.jackrabbit.spi.NodeId;
+
+public class XMLItemInfo implements ItemInfo {
+
+    protected final XMLNodeId id;
+
+    public XMLItemInfo(XMLNodeId id) {
+        this.id = id;
+    }
+
+    //-------------------------------------------------------------< ItemInfo>
+
+    public boolean denotesNode() {
+        return id.denotesNode();
+    }
+
+    public NodeId getParentId() {
+        return id.getParentId();
+    }
+
+    public QName getQName() {
+        return id.getName();
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeId.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeId.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeId.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeId.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import java.util.Iterator;
+
+import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.ChildInfo;
+import org.apache.jackrabbit.spi.IdIterator;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class XMLNodeId implements NodeId, PropertyId, ChildInfo {
+
+    private final Node node;
+
+    public XMLNodeId(Node node) {
+        this.node = node;
+    }
+
+    public NodeId getParentId() {
+        Node parent = node.getParentNode();
+        if (parent != null) {
+            return new XMLNodeId(parent);
+        } else {
+            return null;
+        }
+    }
+
+    public IdIterator getPropertyIds() {
+        return new XMLPropertyIdIterator(
+                new XMLPrimaryTypeId(this), node.getAttributes());
+    }
+
+    public Iterator getChildInfos() {
+        return new XMLNodeIdIterator(node.getChildNodes());
+    }
+
+    public XMLNodeId getNodeId(Path path) {
+        Node current = node;
+        Path.PathElement[] elements = path.getElements();
+        for (int i = 0; i < elements.length; i++) {
+            if (elements[i].denotesRoot()) {
+                current = node;
+            } else if (elements[i].denotesParent()) {
+                if (current.getParentNode() != null) {
+                    current = current.getParentNode();
+                } else {
+                    return null;
+                }
+            } else if (elements[i].denotesCurrent()) {
+                // do nothing
+            } else {
+                QName name = elements[i].getName();
+                int index = elements[i].getNormalizedIndex();
+                NodeList nodes = current.getChildNodes();
+                for (int j = 0; index > 0 && j < nodes.getLength(); j++) {
+                    Node child = nodes.item(j);
+                    if (name.equals(new XMLNodeId(child).getName())) {
+                        if (--index == 0) {
+                            current = child;
+                        }
+                    }
+                }
+                if (index > 0) {
+                    return null;
+                }
+            }
+        }
+        return new XMLNodeId(current);
+    }
+
+    public XMLNodeId getPropertyId(QName name) {
+        String uri = name.getNamespaceURI();
+        if (QName.NS_DEFAULT_URI.equals(uri)) {
+            uri = null;
+        }
+
+        NamedNodeMap attributes = node.getAttributes();
+        Node attribute = attributes.getNamedItemNS(uri, name.getLocalName());
+        if (attribute != null) {
+            return new XMLNodeId(attribute);
+        } else {
+            return null;
+        }
+    }
+
+    public String getValue() {
+        return node.getNodeValue();
+    }
+
+    //--------------------------------------------------------------< NodeId >
+
+    public boolean denotesNode() {
+        return node.getNodeType() == Node.ELEMENT_NODE
+            || node.getNodeType() == Node.DOCUMENT_NODE;
+    }
+
+    public Path getPath() {
+        try {
+            Node parent = node.getParentNode();
+            if (parent != null) {
+                Path parentPath = new XMLNodeId(parent).getPath();
+                int index = getIndex();
+                if (index > 0) {
+                    return Path.create(parentPath, getName(), index, false);
+                } else {
+                    return Path.create(parentPath, getName(), false);
+                }
+            } else {
+                return Path.ROOT;
+            }
+        } catch (MalformedPathException e) {
+            throw new IllegalStateException("Invalid path: " + e.getMessage());
+        }
+    }
+
+    /**
+     * Returns <code>null</code>.
+     *
+     * @return <code>null</code>
+     */
+    public String getUniqueID() {
+        return null;
+    }
+
+    public int getIndex() {
+        int index = 0;
+        int count = 0;
+
+        Node parent = node.getParentNode();
+        if (parent != null) {
+            NodeList nodes = parent.getChildNodes();
+            for (int i = 0; i < nodes.getLength(); i++) {
+                Node current = nodes.item(i);
+                if (current == node) {
+                    index = i + 1;
+                } else if (node.getNamespaceURI().equals(current.getNamespaceURI())
+                        && node.getLocalName().equals(current.getLocalName())) {
+                    count++;
+                }
+            }
+        }
+
+        if (count > 0) {
+            return index;
+        } else {
+            return 0;
+        }
+    }
+
+    public QName getName() {
+        if (node.getParentNode() == null) {
+            return new QName(QName.NS_DEFAULT_URI, "");
+        } else if (node.getNamespaceURI() == null) {
+            return new QName(QName.NS_DEFAULT_URI, node.getLocalName());
+        } else {
+            return new QName(node.getNamespaceURI(), node.getLocalName());
+        }
+    }
+
+    public QName getQName() {
+        return getName();
+    }
+
+    //--------------------------------------------------------------< Object >
+
+    public boolean equals(Object that) {
+        return that instanceof XMLNodeId
+            && node.equals(((XMLNodeId) that).node);
+    }
+
+    public int hashCode() {
+        return node.hashCode();
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeIdIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeIdIterator.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeIdIterator.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeIdIterator.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.w3c.dom.NodeList;
+
+public class XMLNodeIdIterator implements Iterator {
+
+    private final NodeList nodes;
+
+    private int index;
+
+    public XMLNodeIdIterator(NodeList nodes) {
+        this.nodes = nodes;
+        this.index = 0;
+    }
+
+    //------------------------------------------------------------< Iterator >
+
+    public boolean hasNext() {
+        return index < nodes.getLength();
+    }
+
+    public Object next() {
+        if (hasNext()) {
+            return new XMLNodeId(nodes.item(index++));
+        } else {
+            throw new NoSuchElementException();
+        }
+    }
+
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeInfo.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeInfo.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLNodeInfo.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.IdIterator;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.PropertyId;
+
+public class XMLNodeInfo extends XMLItemInfo implements NodeInfo {
+
+    public XMLNodeInfo(XMLNodeId id) {
+        super(id);
+    }
+
+    //-------------------------------------------------------------< NodeInfo>
+
+    public NodeId getId() {
+        return id;
+    }
+
+    public int getIndex() {
+        return id.getIndex();
+    }
+
+    public QName[] getMixins() {
+        return QName.EMPTY_ARRAY;
+    }
+
+    public QName getNodetype() {
+        return QName.NT_UNSTRUCTURED;
+    }
+
+    public IdIterator getPropertyIds() {
+        return id.getPropertyIds();
+    }
+
+    public PropertyId[] getReferences() {
+        return new PropertyId[0];
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPrimaryTypeId.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPrimaryTypeId.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPrimaryTypeId.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPrimaryTypeId.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PropertyId;
+
+public class XMLPrimaryTypeId implements PropertyId {
+
+    private final NodeId parent;
+
+    public XMLPrimaryTypeId(NodeId parent) {
+        this.parent = parent;
+    }
+
+    //----------------------------------------------------------< PropertyId >
+
+    public NodeId getParentId() {
+        return parent;
+    }
+
+    public QName getQName() {
+        return QName.JCR_PRIMARYTYPE;
+    }
+
+    public boolean denotesNode() {
+        return false;
+    }
+
+    public Path getPath() {
+        try {
+            return Path.create(parent.getPath(), getQName(), false);
+        } catch (MalformedPathException e) {
+            throw new IllegalStateException("Invalid path: " + this);
+        }
+    }
+
+    public String getUniqueID() {
+        return null;
+    }
+
+    //--------------------------------------------------------------< Object >
+
+    public boolean equals(Object that) {
+        return that instanceof XMLPrimaryTypeId
+            && parent.equals(((XMLPrimaryTypeId) that).parent);
+    }
+
+    public int hashCode() {
+        return parent.hashCode() * 17 + 37;
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPrimaryTypeInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPrimaryTypeInfo.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPrimaryTypeInfo.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPrimaryTypeInfo.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import javax.jcr.PropertyType;
+
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.value.QValueFactoryImpl;
+
+public class XMLPrimaryTypeInfo implements PropertyInfo {
+
+    private final PropertyId id;
+
+    public XMLPrimaryTypeInfo(PropertyId id) {
+        this.id = id;
+    }
+
+    //---------------------------------------------------------< PropertyInfo>
+
+    public boolean denotesNode() {
+        return false;
+    }
+
+    public PropertyId getId() {
+        return id;
+    }
+
+    public NodeId getParentId() {
+        return id.getParentId();
+    }
+
+    public QName getQName() {
+        return QName.JCR_PRIMARYTYPE;
+    }
+
+    public int getType() {
+        return PropertyType.NAME;
+    }
+
+    public QValue[] getValues() {
+        QValueFactory factory = QValueFactoryImpl.getInstance();
+        return new QValue[] { factory.create(QName.NT_UNSTRUCTURED) };
+    }
+
+    public boolean isMultiValued() {
+        return false;
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPropertyIdIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPropertyIdIterator.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPropertyIdIterator.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPropertyIdIterator.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import java.util.NoSuchElementException;
+
+import org.apache.jackrabbit.spi.IdIterator;
+import org.apache.jackrabbit.spi.ItemId;
+import org.w3c.dom.NamedNodeMap;
+
+public class XMLPropertyIdIterator implements IdIterator {
+
+    private final ItemId primary;
+
+    private final NamedNodeMap nodes;
+
+    private int index;
+
+    public XMLPropertyIdIterator(ItemId primary, NamedNodeMap nodes) {
+        this.primary = primary;
+        this.nodes = nodes;
+        this.index = -1;
+    }
+
+    //----------------------------------------------------------< IdIterator >
+
+    public ItemId nextId() {
+        if (hasNext()) {
+            if (++index == 0) {
+                return primary;
+            } else {
+                return new XMLNodeId(nodes.item(index));
+            }
+        } else {
+            throw new NoSuchElementException();
+        }
+    }
+
+    public long getPosition() {
+        return index + 1;
+    }
+
+    public long getSize() {
+        if (nodes != null) {
+            return nodes.getLength() + 1;
+        } else {
+            return 1;
+        }
+    }
+
+    public void skip(long n) {
+        while (n-- > 0) {
+            next();
+        }
+    }
+
+    public boolean hasNext() {
+        return getPosition() < getSize();
+    }
+
+    public Object next() {
+        return nextId();
+    }
+
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPropertyInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPropertyInfo.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPropertyInfo.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLPropertyInfo.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import javax.jcr.PropertyType;
+
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.value.QValueFactoryImpl;
+
+public class XMLPropertyInfo extends XMLItemInfo implements PropertyInfo {
+
+    public XMLPropertyInfo(XMLNodeId id) {
+        super(id);
+    }
+
+    //---------------------------------------------------------< PropertyInfo>
+
+    public PropertyId getId() {
+        return id;
+    }
+
+    public int getType() {
+        return PropertyType.STRING;
+    }
+
+    public QValue[] getValues() {
+        QValueFactory factory = QValueFactoryImpl.getInstance();
+        return new QValue[] { factory.create(id.getValue(), getType()) };
+    }
+
+    public boolean isMultiValued() {
+        return false;
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryConfig.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryConfig.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryConfig.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.value.ValueFactoryImpl;
+
+public class XMLRepositoryConfig implements RepositoryConfig {
+
+    private final RepositoryService service;
+
+    public XMLRepositoryConfig(XMLRepositoryService service) {
+        this.service = service;
+    }
+    
+    public RepositoryService getRepositoryService() throws RepositoryException {
+        return service;
+    }
+
+    public CacheBehaviour getCacheBehaviour() {
+        return null;
+    }
+
+    public String getDefaultWorkspaceName() {
+        return "xml";
+    }
+
+    public int getPollingInterval() {
+        return 1000;
+    }
+
+    public ValueFactory getValueFactory() {
+        return ValueFactoryImpl.getInstance();
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryFactory.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryFactory.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryFactory.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader;
+import org.apache.jackrabbit.core.nodetype.compact.ParseException;
+import org.apache.jackrabbit.jcr2spi.RepositoryImpl;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.xml.nodetype.XMLQNodeTypeDefinition;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class XMLRepositoryFactory {
+
+    private final QNodeTypeDefinition[] types;
+
+    public XMLRepositoryFactory() throws RepositoryException {
+        try {
+            InputStream cnd =
+                XMLRepositoryFactory.class.getResourceAsStream("types.cnd");
+            CompactNodeTypeDefReader reader = new CompactNodeTypeDefReader(
+                    new InputStreamReader(cnd, "UTF-8"), null);
+            NodeTypeDef[] defs = (NodeTypeDef[])
+                reader.getNodeTypeDefs().toArray(new NodeTypeDef[0]);
+            types = new QNodeTypeDefinition[defs.length];
+            for (int i = 0; i < defs.length; i++) {
+                types[i] = new XMLQNodeTypeDefinition(defs[i]);
+            }
+        } catch (ParseException e) {
+            throw new RepositoryException("Invalid node type definitions", e);
+        } catch (UnsupportedEncodingException e) {
+            throw new RepositoryException("UTF-8 not supported", e);
+        }
+    }
+
+    public Repository getRepository(Document xml) throws RepositoryException {
+        XMLRepositoryService service = new XMLRepositoryService(xml, types);
+        return RepositoryImpl.create(new XMLRepositoryConfig(service));
+    }
+
+    public Repository getRepository(InputSource xml)
+            throws RepositoryException, IOException, SAXException,
+            ParserConfigurationException {
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        DocumentBuilder builder = factory.newDocumentBuilder();
+        return getRepository(builder.parse(xml));
+    }
+
+    public Repository getRepository(InputStream xml)
+            throws RepositoryException, IOException, SAXException,
+            ParserConfigurationException {
+        return getRepository(new InputSource(xml));
+    }
+
+    public Repository getRepository(String xml)
+            throws RepositoryException, IOException, SAXException,
+            ParserConfigurationException {
+        return getRepository(new InputSource(new StringReader(xml)));
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryService.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryService.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLRepositoryService.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,597 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.LoginException;
+import javax.jcr.MergeException;
+import javax.jcr.NamespaceException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.version.VersionException;
+
+import org.apache.jackrabbit.core.nodetype.ItemDef;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.spi.EventBundle;
+import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.IdIterator;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.LockInfo;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinitionIterator;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.QueryInfo;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.xml.nodetype.XMLQNodeTypeDefinitionIterator;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+public class XMLRepositoryService implements RepositoryService {
+
+    private final Document document;
+
+    private final QNodeTypeDefinition[] types;
+
+    private final QNodeDefinition nodeDefinition;
+
+    private final QPropertyDefinition primaryTypeDefinition;
+
+    private final QPropertyDefinition propertyDefinition;
+    
+    public XMLRepositoryService(Document document, QNodeTypeDefinition[] types)
+            throws RepositoryException {
+        this.document = document;
+        this.types = types;
+        this.nodeDefinition =
+            getNodeDefinition(QName.NT_UNSTRUCTURED, ItemDef.ANY_NAME);
+        this.primaryTypeDefinition =
+            getPropertyDefinition(QName.NT_BASE, QName.JCR_PRIMARYTYPE);
+        this.propertyDefinition =
+            getPropertyDefinition(QName.NT_UNSTRUCTURED, ItemDef.ANY_NAME);
+    }
+
+    private QNodeTypeDefinition getNodeTypeDefinition(QName name)
+            throws RepositoryException {
+        for (int i = 0; i < types.length; i++) {
+            if (name.equals(types[i].getQName())) {
+                return types[i];
+            }
+        }
+        throw new IllegalStateException("Node type not found: " + name);
+    }
+
+    private QNodeDefinition getNodeDefinition(QName type, QName name)
+            throws RepositoryException {
+        QNodeDefinition[] nodes =
+            getNodeTypeDefinition(type).getChildNodeDefs();
+        for (int i = 0; i < nodes.length; i++) {
+            if (name.equals(nodes[i].getQName())) {
+                return nodes[i];
+            }
+        }
+        throw new RepositoryException("Node definition not found: " + name);
+    }
+
+    private QPropertyDefinition getPropertyDefinition(QName type, QName name)
+            throws RepositoryException {
+        QPropertyDefinition[] properties =
+            getNodeTypeDefinition(type).getPropertyDefs();
+        for (int i = 0; i < properties.length; i++) {
+            if (name.equals(properties[i].getQName())
+                    && !properties[i].isMultiple()) {
+                return properties[i];
+            }
+        }
+        throw new RepositoryException("Property definition not found: " + name);
+    }
+
+    //---------------------------------------------------< RepositoryService >
+
+    /**
+     * Returns the descriptors of the XML repository.
+     *
+     * @return repository descriptors
+     */
+    public Map getRepositoryDescriptors() {
+        Map descriptors = new HashMap();
+        descriptors.put(Repository.LEVEL_1_SUPPORTED, Boolean.TRUE.toString());
+        descriptors.put(Repository.LEVEL_2_SUPPORTED, Boolean.FALSE.toString());
+        descriptors.put(Repository.OPTION_LOCKING_SUPPORTED, Boolean.FALSE.toString());
+        descriptors.put(Repository.OPTION_OBSERVATION_SUPPORTED, Boolean.FALSE.toString());
+        descriptors.put(Repository.OPTION_QUERY_SQL_SUPPORTED, Boolean.FALSE.toString());
+        descriptors.put(Repository.OPTION_TRANSACTIONS_SUPPORTED, Boolean.FALSE.toString());
+        descriptors.put(Repository.OPTION_VERSIONING_SUPPORTED, Boolean.FALSE.toString());
+        descriptors.put(Repository.QUERY_XPATH_DOC_ORDER, Boolean.FALSE.toString());
+        descriptors.put(Repository.QUERY_XPATH_POS_INDEX, Boolean.FALSE.toString());
+        descriptors.put(Repository.REP_NAME_DESC, "Apache Jackrabbit SPI XML");
+        descriptors.put(Repository.REP_VENDOR_DESC, "Apache Software Foundation");
+        descriptors.put(Repository.REP_VENDOR_URL_DESC, "http://jackrabbit.apache.org/");
+        descriptors.put(Repository.REP_VERSION_DESC, "1.3-SNAPSHOT");
+        descriptors.put(Repository.SPEC_NAME_DESC, "Content Repository for Java Technology API");
+        descriptors.put(Repository.SPEC_VERSION_DESC, "1.0");
+        return descriptors;
+    }
+
+    /**
+     * Obtains session info for the XML workspace.
+     *
+     * @param credentials ignored
+     * @param workspace workspace name, should be <code>null</code> or "xml"
+     * @return session info
+     * @throws NoSuchWorkspaceException if the workspace name is not known
+     */
+    public SessionInfo obtain(Credentials credentials, String workspace)
+            throws NoSuchWorkspaceException {
+        if (workspace == null || workspace.equals("xml")) {
+            if (credentials instanceof SimpleCredentials) {
+                return new XMLSessionInfo(
+                        ((SimpleCredentials) credentials).getUserID());
+            } else {
+                return new XMLSessionInfo("");
+            }
+        } else {
+            throw new NoSuchWorkspaceException(
+                    "Unknown workspace: " + workspace);
+        }
+    }
+
+    /**
+     * Returns the default namespace mappings and any extra mappings
+     * available as xmlns:prefix="uri" attributes on the document element.
+     *
+     * @param session ignored
+     * @return namespace mappings
+     */
+    public Map getRegisteredNamespaces(SessionInfo session) {
+        Map namespaces = new HashMap();
+        namespaces.put(QName.NS_EMPTY_PREFIX, QName.NS_DEFAULT_URI);
+        namespaces.put(QName.NS_JCR_PREFIX, QName.NS_JCR_URI);
+        namespaces.put(QName.NS_MIX_PREFIX, QName.NS_MIX_URI);
+        namespaces.put(QName.NS_NT_PREFIX, QName.NS_NT_URI);
+        namespaces.put(QName.NS_SV_PREFIX, QName.NS_SV_URI);
+        namespaces.put(QName.NS_XML_PREFIX, QName.NS_XML_URI);
+        Set uris = new HashSet(namespaces.values());
+
+        Element root = document.getDocumentElement();
+        NamedNodeMap attributes = root.getAttributes();
+        for (int i = 0; i < attributes.getLength(); i++) {
+            Node attribute = attributes.item(i);
+            if (QName.NS_XMLNS_URI.equals(attribute.getNamespaceURI())
+                    && !uris.contains(attribute.getNodeValue())) {
+                String prefix = attribute.getLocalName();
+                for (int j = 2; namespaces.containsKey(prefix); j++) {
+                    prefix = attribute.getLocalName() + j;
+                }
+                namespaces.put(prefix, attribute.getNodeValue());
+                uris.add(attribute.getNodeValue());
+            }
+        }
+
+        return namespaces;
+    }
+
+    public QNodeTypeDefinitionIterator getNodeTypeDefinitions(
+            SessionInfo session) {
+        return new XMLQNodeTypeDefinitionIterator(types);
+    }
+
+    public NodeId getRootId(SessionInfo session) {
+        return new XMLNodeId(document);
+    }
+
+    public QNodeDefinition getNodeDefinition(SessionInfo session, NodeId id) {
+        return nodeDefinition;
+    }
+
+    public NodeInfo getNodeInfo(SessionInfo session, NodeId id)
+            throws RepositoryException {
+        try {
+            return new XMLNodeInfo((XMLNodeId) id);
+        } catch (ClassCastException e) {
+            throw new RepositoryException("Invalid node identifier: " + id);
+        }
+    }
+
+    public Iterator getChildInfos(SessionInfo session, NodeId id)
+            throws RepositoryException {
+        try {
+            return ((XMLNodeId) id).getChildInfos();
+        } catch (ClassCastException e) {
+            throw new RepositoryException("Invalid node identifier: " + id);
+        }
+    }
+
+    public IdFactory getIdFactory() {
+        return new XMLIdFactory(new XMLNodeId(document));
+    }
+
+    public PropertyInfo getPropertyInfo(SessionInfo session, PropertyId id)
+            throws RepositoryException {
+        try {
+            if (id instanceof XMLPrimaryTypeId) {
+                return new XMLPrimaryTypeInfo(id);
+            } else {
+                return new XMLPropertyInfo((XMLNodeId) id);
+            }
+        } catch (ClassCastException e) {
+            throw new RepositoryException("Invalid property identifier: " + id);
+        }
+    }
+
+    public QPropertyDefinition getPropertyDefinition(
+            SessionInfo session, PropertyId id) throws RepositoryException {
+        if (id instanceof XMLPrimaryTypeId) {
+            return primaryTypeDefinition;
+        } else {
+            return propertyDefinition;
+        }
+    }
+
+    public boolean isGranted(SessionInfo session, ItemId id, String[] actions) {
+        return true;
+    }
+
+    public String[] getWorkspaceNames(SessionInfo session) {
+        return new String[] { "xml" };
+    }
+
+    public Batch createBatch(ItemId itemId, SessionInfo sessionInfo)
+            throws RepositoryException {
+        return null;
+    }
+
+    public void submit(Batch batch) throws RepositoryException {
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#addVersionLabel(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName, boolean)
+     */
+    public void addVersionLabel(SessionInfo sessionInfo,
+            NodeId versionHistoryId, NodeId versionId, QName label,
+            boolean moveLabel) throws VersionException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#checkQueryStatement(org.apache.jackrabbit.spi.SessionInfo, java.lang.String, java.lang.String, java.util.Map)
+     */
+    public void checkQueryStatement(SessionInfo sessionInfo, String statement,
+            String language, Map namespaces) throws InvalidQueryException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#checkin(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void checkin(SessionInfo sessionInfo, NodeId nodeId)
+            throws VersionException, UnsupportedRepositoryOperationException,
+            InvalidItemStateException, LockException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#checkout(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void checkout(SessionInfo sessionInfo, NodeId nodeId)
+            throws UnsupportedRepositoryOperationException, LockException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#clone(org.apache.jackrabbit.spi.SessionInfo, java.lang.String, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName, boolean)
+     */
+    public void clone(SessionInfo sessionInfo, String srcWorkspaceName,
+            NodeId srcNodeId, NodeId destParentNodeId, QName destName,
+            boolean removeExisting) throws NoSuchWorkspaceException,
+            ConstraintViolationException, VersionException,
+            AccessDeniedException, PathNotFoundException, ItemExistsException,
+            LockException, UnsupportedRepositoryOperationException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#copy(org.apache.jackrabbit.spi.SessionInfo, java.lang.String, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName)
+     */
+    public void copy(SessionInfo sessionInfo, String srcWorkspaceName,
+            NodeId srcNodeId, NodeId destParentNodeId, QName destName)
+            throws NoSuchWorkspaceException, ConstraintViolationException,
+            VersionException, AccessDeniedException, PathNotFoundException,
+            ItemExistsException, LockException,
+            UnsupportedRepositoryOperationException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#createEventFilter(org.apache.jackrabbit.spi.SessionInfo, int, org.apache.jackrabbit.name.Path, boolean, java.lang.String[], org.apache.jackrabbit.name.QName[], boolean)
+     */
+    public EventFilter createEventFilter(SessionInfo sessionInfo,
+            int eventTypes, Path absPath, boolean isDeep, String[] uuid,
+            QName[] nodeTypeName, boolean noLocal)
+            throws UnsupportedRepositoryOperationException, RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#dispose(org.apache.jackrabbit.spi.SessionInfo)
+     */
+    public void dispose(SessionInfo sessionInfo) throws RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#executeQuery(org.apache.jackrabbit.spi.SessionInfo, java.lang.String, java.lang.String, java.util.Map)
+     */
+    public QueryInfo executeQuery(SessionInfo sessionInfo, String statement,
+            String language, Map namespaces) throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#exists(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.ItemId)
+     */
+    public boolean exists(SessionInfo sessionInfo, ItemId itemId)
+            throws RepositoryException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#getEvents(org.apache.jackrabbit.spi.SessionInfo, long, org.apache.jackrabbit.spi.EventFilter[])
+     */
+    public EventBundle[] getEvents(SessionInfo sessionInfo, long timeout,
+            EventFilter[] filters) throws RepositoryException,
+            UnsupportedRepositoryOperationException, InterruptedException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#getLockInfo(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public LockInfo getLockInfo(SessionInfo sessionInfo, NodeId nodeId)
+            throws LockException, RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#getQValueFactory()
+     */
+    public QValueFactory getQValueFactory() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#getSupportedQueryLanguages(org.apache.jackrabbit.spi.SessionInfo)
+     */
+    public String[] getSupportedQueryLanguages(SessionInfo sessionInfo)
+            throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#importXml(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, java.io.InputStream, int)
+     */
+    public void importXml(SessionInfo sessionInfo, NodeId parentId,
+            InputStream xmlStream, int uuidBehaviour)
+            throws ItemExistsException, PathNotFoundException,
+            VersionException, ConstraintViolationException, LockException,
+            AccessDeniedException, UnsupportedRepositoryOperationException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#lock(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, boolean, boolean)
+     */
+    public LockInfo lock(SessionInfo sessionInfo, NodeId nodeId, boolean deep,
+            boolean sessionScoped)
+            throws UnsupportedRepositoryOperationException, LockException,
+            AccessDeniedException, InvalidItemStateException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#merge(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, java.lang.String, boolean)
+     */
+    public IdIterator merge(SessionInfo sessionInfo, NodeId nodeId,
+            String srcWorkspaceName, boolean bestEffort)
+            throws NoSuchWorkspaceException, AccessDeniedException,
+            MergeException, LockException, InvalidItemStateException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#move(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName)
+     */
+    public void move(SessionInfo sessionInfo, NodeId srcNodeId,
+            NodeId destParentNodeId, QName destName)
+            throws ItemExistsException, PathNotFoundException,
+            VersionException, ConstraintViolationException, LockException,
+            AccessDeniedException, UnsupportedRepositoryOperationException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#obtain(org.apache.jackrabbit.spi.SessionInfo, java.lang.String)
+     */
+    public SessionInfo obtain(SessionInfo sessionInfo, String workspaceName)
+            throws LoginException, NoSuchWorkspaceException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#refreshLock(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void refreshLock(SessionInfo sessionInfo, NodeId nodeId)
+            throws LockException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#registerNamespace(org.apache.jackrabbit.spi.SessionInfo, java.lang.String, java.lang.String)
+     */
+    public void registerNamespace(SessionInfo sessionInfo, String prefix,
+            String uri) throws NamespaceException,
+            UnsupportedRepositoryOperationException, AccessDeniedException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#removeVersion(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void removeVersion(SessionInfo sessionInfo, NodeId versionHistoryId,
+            NodeId versionId) throws ReferentialIntegrityException,
+            AccessDeniedException, UnsupportedRepositoryOperationException,
+            VersionException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#removeVersionLabel(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName)
+     */
+    public void removeVersionLabel(SessionInfo sessionInfo,
+            NodeId versionHistoryId, NodeId versionId, QName label)
+            throws VersionException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#resolveMergeConflict(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId[], org.apache.jackrabbit.spi.NodeId[])
+     */
+    public void resolveMergeConflict(SessionInfo sessionInfo, NodeId nodeId,
+            NodeId[] mergeFailedIds, NodeId[] predecessorIds)
+            throws VersionException, InvalidItemStateException,
+            UnsupportedRepositoryOperationException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#restore(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId[], boolean)
+     */
+    public void restore(SessionInfo sessionInfo, NodeId[] versionIds,
+            boolean removeExisting) throws ItemExistsException,
+            UnsupportedRepositoryOperationException, VersionException,
+            LockException, InvalidItemStateException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#restore(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, boolean)
+     */
+    public void restore(SessionInfo sessionInfo, NodeId nodeId,
+            NodeId versionId, boolean removeExisting) throws VersionException,
+            PathNotFoundException, ItemExistsException,
+            UnsupportedRepositoryOperationException, LockException,
+            InvalidItemStateException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#unlock(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void unlock(SessionInfo sessionInfo, NodeId nodeId)
+            throws UnsupportedRepositoryOperationException, LockException,
+            AccessDeniedException, InvalidItemStateException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#unregisterNamespace(org.apache.jackrabbit.spi.SessionInfo, java.lang.String)
+     */
+    public void unregisterNamespace(SessionInfo sessionInfo, String uri)
+            throws NamespaceException, UnsupportedRepositoryOperationException,
+            AccessDeniedException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.RepositoryService#update(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, java.lang.String)
+     */
+    public void update(SessionInfo sessionInfo, NodeId nodeId,
+            String srcWorkspaceName) throws NoSuchWorkspaceException,
+            AccessDeniedException, LockException, InvalidItemStateException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLSessionInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLSessionInfo.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLSessionInfo.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/XMLSessionInfo.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml;
+
+import org.apache.jackrabbit.spi.SessionInfo;
+
+public class XMLSessionInfo implements SessionInfo {
+
+    private final String user;
+
+    public XMLSessionInfo(String user) {
+        this.user = user;
+    }
+
+    //----------------------------------------------------------< SessionInfo>
+
+    public String getWorkspaceName() {
+        return "xml";
+    }
+
+    public String getUserID() {
+        return user;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.SessionInfo#addLockToken(java.lang.String)
+     */
+    public void addLockToken(String lockToken) {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.SessionInfo#getLastEventBundleId()
+     */
+    public String getLastEventBundleId() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.SessionInfo#getLockTokens()
+     */
+    public String[] getLockTokens() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.SessionInfo#removeLockToken(java.lang.String)
+     */
+    public void removeLockToken(String lockToken) {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.SessionInfo#setLastEventBundleId(java.lang.String)
+     */
+    public void setLastEventBundleId(String eventBundleId) {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQItemDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQItemDefinition.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQItemDefinition.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQItemDefinition.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml.nodetype;
+
+import org.apache.jackrabbit.core.nodetype.ItemDef;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.QItemDefinition;
+
+public class XMLQItemDefinition implements QItemDefinition {
+
+    private final ItemDef def;
+
+    public XMLQItemDefinition(ItemDef def) {
+        this.def = def;
+    }
+
+    //-----------------------------------------------------< QItemDefinition >
+
+    public boolean definesNode() {
+        return def.definesNode();
+    }
+
+    public boolean definesResidual() {
+        return def.definesResidual();
+    }
+
+    public QName getDeclaringNodeType() {
+        return def.getDeclaringNodeType();
+    }
+
+    public int getOnParentVersion() {
+        return def.getOnParentVersion();
+    }
+
+    public QName getQName() {
+        return def.getName();
+    }
+
+    public boolean isAutoCreated() {
+        return def.isAutoCreated();
+    }
+
+    public boolean isMandatory() {
+        return def.isMandatory();
+    }
+
+    public boolean isProtected() {
+        return def.isProtected();
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeDefinition.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeDefinition.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeDefinition.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml.nodetype;
+
+import org.apache.jackrabbit.core.nodetype.NodeDef;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+
+public class XMLQNodeDefinition extends XMLQItemDefinition
+        implements QNodeDefinition {
+
+    private final NodeDef def;
+
+    public XMLQNodeDefinition(NodeDef def) {
+        super(def);
+        this.def = def;
+    }
+
+    //-----------------------------------------------------< QNodeDefinition >
+
+    public boolean allowsSameNameSiblings() {
+        return def.allowsSameNameSiblings();
+    }
+
+    public QName getDefaultPrimaryType() {
+        return def.getDefaultPrimaryType();
+    }
+
+    public QName[] getRequiredPrimaryTypes() {
+        return def.getRequiredPrimaryTypes();
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeTypeDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeTypeDefinition.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeTypeDefinition.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeTypeDefinition.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml.nodetype;
+
+import java.util.Collection;
+
+import org.apache.jackrabbit.core.nodetype.NodeDef;
+import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.core.nodetype.PropDef;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+
+public class XMLQNodeTypeDefinition implements QNodeTypeDefinition {
+
+    private final NodeTypeDef def;
+
+    public XMLQNodeTypeDefinition(NodeTypeDef definition) {
+        this.def = definition;
+    }
+
+    //-------------------------------------------------< QNodeTypeDefinition >
+
+    public QNodeDefinition[] getChildNodeDefs() {
+        NodeDef[] defs = def.getChildNodeDefs();
+        QNodeDefinition[] definitions = new QNodeDefinition[defs.length];
+        for (int i = 0; i < defs.length; i++) {
+            definitions[i] = new XMLQNodeDefinition(defs[i]);
+        }
+        return definitions;
+    }
+
+    public Collection getDependencies() {
+        return def.getDependencies();
+    }
+
+    public QName getPrimaryItemName() {
+        return def.getPrimaryItemName();
+    }
+
+    public QPropertyDefinition[] getPropertyDefs() {
+        PropDef[] defs = def.getPropertyDefs();
+        QPropertyDefinition[] definitions = new QPropertyDefinition[defs.length];
+        for (int i = 0; i < defs.length; i++) {
+            definitions[i] = new XMLQPropertyDefinition(defs[i]);
+        }
+        return definitions;
+    }
+
+    public QName getQName() {
+        return def.getName();
+    }
+
+    public QName[] getSupertypes() {
+        return def.getSupertypes();
+    }
+
+    public boolean hasOrderableChildNodes() {
+        return def.hasOrderableChildNodes();
+    }
+
+    public boolean isMixin() {
+        return def.isMixin();
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeTypeDefinitionIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeTypeDefinitionIterator.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeTypeDefinitionIterator.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQNodeTypeDefinitionIterator.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml.nodetype;
+
+import java.util.NoSuchElementException;
+
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinitionIterator;
+
+public class XMLQNodeTypeDefinitionIterator
+        implements QNodeTypeDefinitionIterator {
+
+    private final QNodeTypeDefinition[] types;
+
+    private int position;
+
+    public XMLQNodeTypeDefinitionIterator(QNodeTypeDefinition[] types) {
+        this.types = types;
+        this.position = 0;
+    }
+
+    //-----------------------------------------< QNodeTypeDefinitionIterator >
+
+    public QNodeTypeDefinition nextDefinition() {
+        if (hasNext()) {
+            return types[position++];
+        } else {
+            throw new NoSuchElementException();
+        }
+    }
+
+    public long getPosition() {
+        return position;
+    }
+
+    public long getSize() {
+        return types.length;
+    }
+
+    public void skip(long n) {
+        while (n > 0) {
+            next();
+            n--;
+        }
+    }
+
+    public boolean hasNext() {
+        return getPosition() < getSize();
+    }
+
+    public Object next() {
+        return nextDefinition();
+    }
+
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQPropertyDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQPropertyDefinition.java?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQPropertyDefinition.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/java/org/apache/jackrabbit/spi/xml/nodetype/XMLQPropertyDefinition.java Sat Jan 20 16:26:53 2007
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.xml.nodetype;
+
+import java.util.Calendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.core.nodetype.PropDef;
+import org.apache.jackrabbit.core.nodetype.ValueConstraint;
+import org.apache.jackrabbit.core.value.BLOBFileValue;
+import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.value.QValueFactoryImpl;
+
+public class XMLQPropertyDefinition extends XMLQItemDefinition
+        implements QPropertyDefinition {
+
+    private final PropDef def;
+
+    public XMLQPropertyDefinition(PropDef def) {
+        super(def);
+        this.def = def;
+    }
+
+    private QValue getQValue(InternalValue value) throws RepositoryException {
+        QValueFactory factory = QValueFactoryImpl.getInstance();
+        Object object = value.internalValue();
+        switch (value.getType()) {
+        case PropertyType.BINARY:
+            return factory.create(
+                    ((BLOBFileValue) object).getString(), PropertyType.BINARY);
+        case PropertyType.DATE:
+            return factory.create((Calendar) object);
+        case PropertyType.NAME:
+            return factory.create((QName) object);
+        case PropertyType.PATH:
+            return factory.create((Path) object);
+        case PropertyType.REFERENCE:
+        case PropertyType.BOOLEAN:
+        case PropertyType.DOUBLE:
+        case PropertyType.LONG:
+        case PropertyType.STRING:
+            return factory.create(object.toString(), value.getType());
+        }
+        throw new RepositoryException("Unknown value type: " + value.getType());
+    }
+
+    //-------------------------------------------------< QPropertyDefinition >
+
+    public QValue[] getDefaultValues() {
+        try {
+            InternalValue[] values = def.getDefaultValues();
+            QValue[] qvalues = new QValue[values.length];
+            for (int i = 0; i < values.length; i++) {
+                qvalues[i] = getQValue(values[i]);
+            }
+            return qvalues;
+        } catch (RepositoryException e) {
+            throw new IllegalStateException(e.getMessage());
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jackrabbit.spi.QPropertyDefinition#getRequiredType()
+     */
+    public int getRequiredType() {
+        return def.getRequiredType();
+    }
+
+    public String[] getValueConstraints() {
+        ValueConstraint[] constraints = def.getValueConstraints();
+        String[] strings = new String[constraints.length];
+        for (int i = 0; i < constraints.length; i++) {
+            strings[i] = constraints[i].getDefinition();
+        }
+        return strings;
+    }
+
+    public boolean isMultiple() {
+        return def.isMultiple();
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/org/apache/jackrabbit/spi/xml/types.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/org/apache/jackrabbit/spi/xml/types.cnd?view=auto&rev=498217
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/org/apache/jackrabbit/spi/xml/types.cnd (added)
+++ jackrabbit/trunk/contrib/jackrabbit-spi-xml/src/main/resources/org/apache/jackrabbit/spi/xml/types.cnd Sat Jan 20 16:26:53 2007
@@ -0,0 +1,11 @@
+<jcr = 'http://www.jcp.org/jcr/1.0'>
+<nt = 'http://www.jcp.org/jcr/nt/1.0'>
+
+[nt:base]
+- jcr:primaryType (NAME) autocreated mandatory protected COMPUTE
+- jcr:mixinTypes (NAME) protected multiple COMPUTE
+
+[nt:unstructured] > nt:base orderable
+- * (UNDEFINED) COPY
+- * (UNDEFINED) multiple COPY
++ * (nt:base) = nt:unstructured multiple VERSION



Mime
View raw message