jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r511801 [1/2] - in /jackrabbit/trunk/contrib/spi: client/ client/src/test/config/ client/src/test/java/org/apache/jackrabbit/jcr2spi/ spi2jcr/ spi2jcr/src/ spi2jcr/src/main/ spi2jcr/src/main/java/ spi2jcr/src/main/java/org/ spi2jcr/src/main...
Date Mon, 26 Feb 2007 13:36:58 GMT
Author: mreutegg
Date: Mon Feb 26 05:36:57 2007
New Revision: 511801

URL: http://svn.apache.org/viewvc?view=rev&rev=511801
Log:
Initial commit of a SPI2JCR implementation.
- missing feature: observation

Added:
    jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/JCR2SPI2JCRRepositoryStub.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/maven.xml   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/project.xml   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ItemInfoImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IteratorHelper.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QItemDefinitionImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeDefinitionImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeTypeDefinitionImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryResultRowImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java   (with props)
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java   (with props)
Modified:
    jackrabbit/trunk/contrib/spi/client/project.xml
    jackrabbit/trunk/contrib/spi/client/src/test/config/repositoryStubImpl.properties

Modified: jackrabbit/trunk/contrib/spi/client/project.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/project.xml?view=diff&rev=511801&r1=511800&r2=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/project.xml (original)
+++ jackrabbit/trunk/contrib/spi/client/project.xml Mon Feb 26 05:36:57 2007
@@ -48,6 +48,11 @@
             <artifactId>jackrabbit-spi-spi2dav</artifactId>
             <version>${jackrabbit.build.version.spi}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi-spi2jcr</artifactId>
+            <version>${jackrabbit.build.version.spi}</version>
+        </dependency>
         <!-- jackrabbit dependencies -->
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
@@ -140,6 +145,72 @@
             <groupId>concurrent</groupId>
             <artifactId>concurrent</artifactId>
             <version>1.3.4</version>
+            <properties>
+                <scope>test</scope>
+            </properties>
+        </dependency>
+        
+        <!-- for testing with spi2jcr -->
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-api</artifactId>
+            <version>${jackrabbit.build.version.jackrabbit}</version>
+            <properties>
+                <scope>test</scope>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-api</artifactId>
+            <version>${jackrabbit.build.version.jackrabbit}</version>
+            <properties>
+                <scope>test</scope>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-core</artifactId>
+            <version>${jackrabbit.build.version.jackrabbit}</version>
+            <properties>
+                <scope>test</scope>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-text-extractors</artifactId>
+            <version>${jackrabbit.build.version.jackrabbit}</version>
+            <properties>
+                <scope>test</scope>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-text-extractors</artifactId>
+            <version>${jackrabbit.build.version.jackrabbit}</version>
+            <properties>
+                <scope>test</scope>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-jta</artifactId>
+            <version>1.0-M1</version>
+            <properties>
+                <scope>test</scope>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.lucene</groupId>
+            <artifactId>lucene-core</artifactId>
+            <version>2.0.0</version>
+            <properties>
+                <scope>test</scope>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>10.2.1.6</version>
             <properties>
                 <scope>test</scope>
             </properties>

Modified: jackrabbit/trunk/contrib/spi/client/src/test/config/repositoryStubImpl.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/config/repositoryStubImpl.properties?view=diff&rev=511801&r1=511800&r2=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/config/repositoryStubImpl.properties (original)
+++ jackrabbit/trunk/contrib/spi/client/src/test/config/repositoryStubImpl.properties Mon Feb 26 05:36:57 2007
@@ -5,10 +5,18 @@
 # Stub implementation class
 javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.jcr2spi.JCR2SPIRepositoryStub
 
+# Use this stub implementation instead for testing SPI2JCR on Jackrabbit
+#javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.jcr2spi.JCR2SPI2JCRRepositoryStub
+
 # repository specific configuration
 org.apache.jackrabbit.jcr2spi.repository.url=http://localhost:5502/jackrabbit/server/
 org.apache.jackrabbit.jcr2spi.workspace.name=default
 
+# config for jackrabbit repository implementation when testing SPI2JCR
+org.apache.jackrabbit.repository.config=../../../jackrabbit-core/applications/test/repository.xml
+org.apache.jackrabbit.repository.name=repo
+org.apache.jackrabbit.repository.home=../../../jackrabbit-core/applications/test
+org.apache.jackrabbit.repository.jaas.config=../../../jackrabbit-core/applications/test/jaas.config
 
 # credential configuration
 javax.jcr.tck.superuser.name=admin

Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/JCR2SPI2JCRRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/JCR2SPI2JCRRepositoryStub.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/JCR2SPI2JCRRepositoryStub.java (added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/JCR2SPI2JCRRepositoryStub.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,89 @@
+/*
+ * 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.jcr2spi;
+
+import org.apache.jackrabbit.test.RepositoryStubException;
+import org.apache.jackrabbit.core.JackrabbitRepositoryStub;
+import org.apache.jackrabbit.spi2jcr.RepositoryServiceImpl;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
+import org.apache.jackrabbit.value.ValueFactoryImpl;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFactory;
+import java.util.Properties;
+
+/**
+ * <code>JCR2SPI2JCRRepositoryStub</code> implements a repository stub that
+ * initializes a Jackrabbit repository and wraps it with a SPI2JCR layer and
+ * a JCR2SPI layer.
+ */
+public class JCR2SPI2JCRRepositoryStub extends JackrabbitRepositoryStub {
+
+    /**
+     * The Jackrabbit repository.
+     */
+    private Repository repo;
+
+    /**
+     * Constructor required by TCK.
+     *
+     * @param env the environment.
+     */
+    public JCR2SPI2JCRRepositoryStub(Properties env) {
+        super(env);
+    }
+
+    /**
+     * @return the repository instance to test.
+     * @throws RepositoryStubException if an error occurs while starting up the
+     *                                 repository.
+     */
+    public Repository getRepository() throws RepositoryStubException {
+        if (repo == null) {
+            Repository jackrabbitRepo = super.getRepository();
+            final RepositoryService repoService = new RepositoryServiceImpl(jackrabbitRepo);
+            try {
+                repo = RepositoryImpl.create(new RepositoryConfig() {
+                    public RepositoryService getRepositoryService() {
+                        return repoService;
+                    }
+
+                    public ValueFactory getValueFactory() {
+                        return ValueFactoryImpl.getInstance();
+                    }
+
+                    public String getDefaultWorkspaceName() {
+                        // not needed for SPI2JCR
+                        return null;
+                    }
+
+                    public CacheBehaviour getCacheBehaviour() {
+                        return CacheBehaviour.INVALIDATE;
+                    }
+                });
+            } catch (RepositoryException e) {
+                RepositoryStubException ex = new RepositoryStubException(e.getMessage());
+                ex.initCause(e);
+                throw ex;
+            }
+        }
+        return repo;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/JCR2SPI2JCRRepositoryStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Feb 26 05:36:57 2007
@@ -0,0 +1,2 @@
+*.iml
+target

Added: jackrabbit/trunk/contrib/spi/spi2jcr/maven.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/maven.xml?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/maven.xml (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/maven.xml Mon Feb 26 05:36:57 2007
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+   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 default="jar">
+    <!--
+        the 'clean' goal is already redefined in the maven.xml
+        of the parent project. we need to redefine it here
+        again to 'maven clean' works.
+    -->
+    <goal name="clean">
+        <attainGoal name="clean:clean"/>
+    </goal>
+</project>

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/maven.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/project.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/project.xml?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/project.xml (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/project.xml Mon Feb 26 05:36:57 2007
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<!--
+   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>
+    <!-- ====================================================================== -->
+    <!-- P R O J E C T  D E S C R I P T I O N                                   -->
+    <!-- ====================================================================== -->
+    <extend>${basedir}/../project.xml</extend>
+    <artifactId>jackrabbit-spi-spi2jcr</artifactId>
+    <name>SPI to JCR</name>
+    <package>org.apache.jackrabbit.spi2jcr.*</package>
+
+    <!-- ====================================================================== -->
+    <!-- D E P E N D E N C I E S                                                -->
+    <!-- ====================================================================== -->
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi</artifactId>
+            <version>${jackrabbit.build.version.spi}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi-commons</artifactId>
+            <version>${jackrabbit.build.version.spi}</version>
+        </dependency>
+        <!-- jackrabbit dependencies -->
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr-commons</artifactId>
+            <version>${jackrabbit.build.version.jackrabbit}</version>
+        </dependency>
+
+        <!-- external dependencies -->
+        <dependency>
+            <groupId>jsr170</groupId>
+            <artifactId>jcr</artifactId>
+            <version>${jackrabbit.build.version.jcr}</version>
+            <url>http://jcp.org/en/jsr/detail?id=170</url>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.0</version>
+            <url>http://www.slf4j.org/download.html</url>
+        </dependency>
+    </dependencies>
+
+    <!-- ====================================================================== -->
+    <!-- B U I L D  D E S C R I P T I O N                                       -->
+    <!-- ====================================================================== -->
+    <build>
+        <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
+    </build>
+
+</project>

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/project.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,95 @@
+/*
+ * 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.spi2jcr;
+
+import org.apache.jackrabbit.spi.ChildInfo;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.name.NameException;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+/**
+ * <code>ChildInfoImpl</code> implements a <code>ChildInfo</code> and provides
+ * information about a child node.
+ */
+class ChildInfoImpl implements ChildInfo {
+
+    /**
+     * The name of this child info.
+     */
+    private final QName name;
+
+    /**
+     * The unique id for this child info or <code>null</code> if it does not
+     * have a unique id.
+     */
+    private final String uniqueId;
+
+    /**
+     * 1-based index of this child info.
+     */
+    private final int index;
+
+    /**
+     * Creates a new <code>ChildInfoImpl</code> for <code>node</code>.
+     *
+     * @param node       the JCR node.
+     * @param nsResolver the namespace resolver in use.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>node</code>.
+     */
+    public ChildInfoImpl(Node node, NamespaceResolver nsResolver) throws RepositoryException {
+        try {
+            this.name = NameFormat.parse(node.getName(), nsResolver);
+        } catch (NameException e) {
+            throw new RepositoryException(e.getMessage(), e);
+        }
+        String uuid = null;
+        try {
+            uuid = node.getUUID();
+        } catch (UnsupportedRepositoryOperationException e) {
+            // not referenceable
+        }
+        this.uniqueId = uuid;
+        this.index = node.getIndex();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getName() {
+        return name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getUniqueID() {
+        return uniqueId;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getIndex() {
+        return index;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,314 @@
+/*
+ * 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.spi2jcr;
+
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.name.NameException;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Property;
+
+/**
+ * <code>IdFactoryImpl</code>...
+ * TODO: copied from spi2dav, move common part to spi-commons.
+ */
+class IdFactoryImpl implements IdFactory {
+
+    private static final IdFactory idFactory = new IdFactoryImpl();
+
+    private IdFactoryImpl() {};
+
+    public static IdFactory getInstance() {
+        return idFactory;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public PropertyId createPropertyId(NodeId parentId, QName propertyName) {
+        try {
+            return new PropertyIdImpl(parentId, propertyName);
+        } catch (MalformedPathException e) {
+            throw new IllegalArgumentException(e.getMessage());
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId createNodeId(NodeId parentId, Path path) {
+        try {
+            return new NodeIdImpl(parentId, path);
+        } catch (MalformedPathException e) {
+            throw new IllegalArgumentException(e.getMessage());
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId createNodeId(String uniqueID, Path path) {
+        return new NodeIdImpl(uniqueID, path);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId createNodeId(String uniqueID) {
+        return new NodeIdImpl(uniqueID);
+    }
+
+    /**
+     * Creates a <code>NodeId</code> for the given <code>node</code>.
+     *
+     * @param node       the JCR Node.
+     * @param nsResolver the namespace resolver in use.
+     * @return the <code>NodeId</code> for <code>node</code>.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>node</code>.
+     */
+    public NodeId createNodeId(Node node, NamespaceResolver nsResolver)
+            throws RepositoryException {
+        Path.PathBuilder builder = new Path.PathBuilder();
+        int pathElements = 0;
+        String uniqueId = null;
+        while (uniqueId == null) {
+            try {
+                uniqueId = node.getUUID();
+            } catch (UnsupportedRepositoryOperationException e) {
+                // not referenceable
+                pathElements++;
+                String jcrName = node.getName();
+                if (jcrName.equals("")) {
+                    // root node
+                    builder.addFirst(QName.ROOT);
+                    break;
+                } else {
+                    QName name;
+                    try {
+                        name = NameFormat.parse(node.getName(), nsResolver);
+                    } catch (NameException ex) {
+                       throw new RepositoryException(ex.getMessage(), ex);
+                    }
+                    if (node.getIndex() == 1) {
+                        builder.addFirst(name);
+                    } else {
+                        builder.addFirst(name, node.getIndex());
+                    }
+                }
+                node = node.getParent();
+            }
+        }
+        if (pathElements > 0) {
+            try {
+                return new NodeIdImpl(uniqueId, builder.getPath());
+            } catch (MalformedPathException e) {
+                throw new RepositoryException(e.getMessage(), e);
+            }
+        } else {
+            return new NodeIdImpl(uniqueId);
+        }
+    }
+
+    /**
+     * Creates a <code>PropertyId</code> for the given <code>property</code>.
+     *
+     * @param property   the JCR Property.
+     * @param nsResolver the namespace resolver in use.
+     * @return the <code>PropertyId</code> for <code>property</code>.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>property</code>.
+     */
+    public PropertyId createPropertyId(Property property,
+                                       NamespaceResolver nsResolver)
+            throws RepositoryException {
+        Node parent = property.getParent();
+        NodeId nodeId = createNodeId(parent, nsResolver);
+        String jcrName = property.getName();
+        QName name;
+        try {
+            name = NameFormat.parse(jcrName, nsResolver);
+        } catch (NameException e) {
+            throw new RepositoryException(e.getMessage(), e);
+        }
+        return createPropertyId(nodeId, name);
+    }
+
+    //------------------------------------------------------< Inner classes >---
+    private static abstract class ItemIdImpl implements ItemId {
+
+        private final String uniqueID;
+        private final Path path;
+
+        private int hashCode = 0;
+
+        private ItemIdImpl(String uniqueID, Path path) {
+            if (uniqueID == null && path == null) {
+                throw new IllegalArgumentException("Only uniqueID or relative path might be null.");
+            }
+            this.uniqueID = uniqueID;
+            this.path = path;
+        }
+
+        private ItemIdImpl(NodeId parentId, QName name) throws MalformedPathException {
+            if (parentId == null || name == null) {
+                throw new IllegalArgumentException("Invalid ItemIdImpl: parentId and name must not be null.");
+            }
+            this.uniqueID = parentId.getUniqueID();
+            Path parentPath = parentId.getPath();
+            if (parentPath != null) {
+                this.path = Path.create(parentPath, name, true);
+            } else {
+                this.path = Path.create(name, Path.INDEX_UNDEFINED);
+            }
+        }
+
+        public abstract boolean denotesNode();
+
+        public String getUniqueID() {
+            return uniqueID;
+        }
+
+        public Path getPath() {
+            return path;
+        }
+
+        /**
+         * ItemIdImpl objects are equal if the have the same uuid and relative path.
+         *
+         * @param obj
+         * @return
+         */
+        public boolean equals(Object obj) {
+            if (obj == this) {
+                return true;
+            }
+            if (obj instanceof ItemId) {
+                ItemId other = (ItemId) obj;
+                return equals(other);
+            }
+            return false;
+        }
+
+        boolean equals(ItemId other) {
+            return (uniqueID == null ? other.getUniqueID() == null : uniqueID.equals(other.getUniqueID()))
+                && (path == null ? other.getPath() == null : path.equals(other.getPath()));
+        }
+
+        /**
+         * Returns the hash code of the uuid and the path. The computed hash code
+         * is memorized for better performance.
+         *
+         * @return hash code
+         * @see Object#hashCode()
+         */
+        public int hashCode() {
+            // since the ItemIdImpl is immutable, store the computed hash code value
+            if (hashCode == 0) {
+                hashCode = toString().hashCode();
+            }
+            return hashCode;
+        }
+
+        /**
+         * Combination of uuid and relative path
+         *
+         * @return
+         */
+        public String toString() {
+            StringBuffer b = new StringBuffer();
+            if (uniqueID != null) {
+                b.append(uniqueID);
+            }
+            if (path != null) {
+                b.append(path.toString());
+            }
+            return b.toString();
+        }
+    }
+
+    private static class NodeIdImpl extends ItemIdImpl implements NodeId {
+
+        public NodeIdImpl(String uniqueID) {
+            super(uniqueID, null);
+        }
+
+        public NodeIdImpl(String uniqueID, Path path) {
+            super(uniqueID, path);
+        }
+
+        public NodeIdImpl(NodeId parentId, Path path) throws MalformedPathException {
+            super(parentId.getUniqueID(), (parentId.getPath() != null) ? Path.create(parentId.getPath(), path, true) : path);
+        }
+
+        public boolean denotesNode() {
+            return true;
+        }
+
+        public boolean equals(Object obj) {
+            if (obj == this) {
+                return true;
+            }
+            if (obj instanceof NodeId) {
+                return super.equals((NodeId)obj);
+            }
+            return false;
+        }
+    }
+
+    private static class PropertyIdImpl extends ItemIdImpl implements PropertyId {
+
+        private final NodeId parentId;
+
+        private PropertyIdImpl(NodeId parentId, QName name) throws MalformedPathException {
+            super(parentId, name);
+            this.parentId = parentId;
+        }
+
+        public boolean denotesNode() {
+            return false;
+        }
+
+        public NodeId getParentId() {
+            return parentId;
+        }
+
+        public QName getQName() {
+            return getPath().getNameElement().getName();
+        }
+
+        public boolean equals(Object obj) {
+            if (obj == this) {
+                return true;
+            }
+            if (obj instanceof PropertyId) {
+                return super.equals((PropertyId)obj);
+            }
+            return false;
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ItemInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ItemInfoImpl.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ItemInfoImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ItemInfoImpl.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,135 @@
+/*
+ * 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.spi2jcr;
+
+import org.apache.jackrabbit.spi.ItemInfo;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.PathFormat;
+import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.name.NameException;
+
+import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Node;
+
+/**
+ * <code>ItemInfoImpl</code> is a base class for <code>ItemInfo</code>
+ * implementations.
+ */
+class ItemInfoImpl implements ItemInfo {
+
+    /**
+     * The underlying JCR item.
+     */
+    private final Item item;
+
+    /**
+     * The parent node id of this item or <code>null</code> if this item
+     * represents the root node info.
+     */
+    private final NodeId parentId;
+
+    /**
+     * The name of this item info.
+     */
+    private final QName name;
+
+    /**
+     * The path of this item info.
+     */
+    private final Path path;
+
+    /**
+     * Creates a new item info for the given JCR <code>item</code>.
+     *
+     * @param item       the JCR item.
+     * @param idFactory  the id factory.
+     * @param nsResolver the namespace resolver in use.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>item</code>.
+     */
+    public ItemInfoImpl(Item item,
+                        IdFactoryImpl idFactory,
+                        NamespaceResolver nsResolver)
+            throws RepositoryException {
+        this.item = item;
+        try {
+            if (item.getName().equals("")) {
+                this.name = QName.ROOT;
+            } else {
+                this.name = NameFormat.parse(item.getName(), nsResolver);
+            }
+        } catch (NameException e) {
+            throw new RepositoryException(e.getMessage(), e);
+        }
+        try {
+            this.path = PathFormat.parse(item.getPath(), nsResolver);
+        } catch (MalformedPathException e) {
+            throw new RepositoryException(e.getMessage(), e);
+        }
+        if (item.getName().equals("")) {
+            this.parentId = null;
+        } else {
+            Node parent = null;
+            try {
+                parent = item.getParent();
+            } catch (AccessDeniedException e) {
+                // cannot access parent
+            }
+            if (parent == null) {
+                // use plain path for parent
+                Path parentPath = path.getAncestor(1);
+                this.parentId = idFactory.createNodeId((String) null, parentPath);
+            } else {
+                this.parentId = idFactory.createNodeId(item.getParent(), nsResolver);
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId getParentId() {
+        return parentId;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getQName() {
+        return name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean denotesNode() {
+        return item.isNode();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Path getPath() {
+        return path;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ItemInfoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IteratorHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IteratorHelper.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IteratorHelper.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IteratorHelper.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,80 @@
+/*
+ * 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.spi2jcr;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.spi.IdIterator;
+import org.apache.jackrabbit.spi.QNodeTypeDefinitionIterator;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.Event;
+import org.apache.jackrabbit.spi.EventIterator;
+import org.apache.jackrabbit.spi.QueryResultRow;
+import org.apache.jackrabbit.spi.QueryResultRowIterator;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+/**
+ * <code>org.apache.jackrabbit.spi2dav.IteratorHelper</code>...
+ * TODO: move to spi-commons
+ */
+class IteratorHelper extends org.apache.jackrabbit.util.IteratorHelper
+    implements IdIterator, QueryResultRowIterator, QNodeTypeDefinitionIterator, EventIterator {
+
+    private static Logger log = LoggerFactory.getLogger(IteratorHelper.class);
+
+    public static final IteratorHelper EMPTY = new IteratorHelper(new ArrayList(0));
+
+    public IteratorHelper(Collection c) {
+        super(c);
+    }
+
+    public IteratorHelper(Iterator iter) {
+        super(iter);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ItemId nextId() {
+        return (ItemId) next();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QNodeTypeDefinition nextDefinition() {
+        return (QNodeTypeDefinition) next();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QueryResultRow nextQueryResultRow() {
+        return (QueryResultRow)super.next();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Event nextEvent() {
+        return (Event) next();
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IteratorHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,114 @@
+/*
+ * 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.spi2jcr;
+
+import org.apache.jackrabbit.spi.LockInfo;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.name.NamespaceResolver;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.lock.Lock;
+
+/**
+ * <code>LockInfoImpl</code> implements a <code>LockInfo</code> on top of a
+ * JCR repository.
+ */
+class LockInfoImpl implements LockInfo {
+
+    /**
+     * The lock token for this lock info.
+     */
+    private final String lockToken;
+
+    /**
+     * The owner of the lock.
+     */
+    private final String lockOwner;
+
+    /**
+     * The isDeep flag.
+     */
+    private final boolean isDeep;
+
+    /**
+     * The isSessionScoped flag.
+     */
+    private final boolean isSessionScoped;
+
+    /**
+     * The <code>NodeId</code> of the locked node.
+     */
+    private final NodeId nodeId;
+
+    /**
+     * Creates a new lock info for the given locked <code>node</code>.
+     *
+     * @param node       the locked node.
+     * @param idFactory  the id factory.
+     * @param nsResolver the namespace resolver in use.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>node</code> or if <code>node</code> is
+     *                             not locked.
+     */
+    public LockInfoImpl(Node node,
+                        IdFactoryImpl idFactory,
+                        NamespaceResolver nsResolver)
+            throws RepositoryException {
+        Lock lock = node.getLock();
+        this.lockToken = lock.getLockToken();
+        this.lockOwner = lock.getLockOwner();
+        this.isDeep = lock.isDeep();
+        this.isSessionScoped = lock.isSessionScoped();
+        this.nodeId = idFactory.createNodeId(node, nsResolver);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getLockToken() {
+        return lockToken;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getOwner() {
+        return lockOwner;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isDeep() {
+        return isDeep;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isSessionScoped() {
+        return isSessionScoped;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId getNodeId() {
+        return nodeId;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,152 @@
+/*
+ * 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.spi2jcr;
+
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.IdIterator;
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.name.NameException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.PropertyIterator;
+import javax.jcr.nodetype.NodeType;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * <code>NodeInfoImpl</code> implements a <code>NodeInfo</code> on top of a JCR
+ * repository.
+ */
+class NodeInfoImpl extends ItemInfoImpl implements NodeInfo {
+
+    /**
+     * The node id of the underlying node.
+     */
+    private final NodeId id;
+
+    /**
+     * 1-based index of the underlying node.
+     */
+    private final int index;
+
+    /**
+     * The name of the primary node type.
+     */
+    private final QName primaryTypeName;
+
+    /**
+     * The names of assigned mixins.
+     */
+    private final QName[] mixinNames;
+
+    /**
+     * The list of {@link PropertyId}s that reference this node info.
+     */
+    private final List references;
+
+    /**
+     * The list of {@link PropertyId}s of this node info.
+     */
+    private final List propertyIds;
+
+    /**
+     * Creates a new node info for the given <code>node</code>.
+     *
+     * @param node       the JCR node.
+     * @param idFactory  the id factory.
+     * @param nsResolver the namespace resolver in use.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>node</code>.
+     */
+    public NodeInfoImpl(Node node,
+                        IdFactoryImpl idFactory,
+                        NamespaceResolver nsResolver)
+            throws RepositoryException {
+        super(node, idFactory, nsResolver);
+        try {
+            this.id = idFactory.createNodeId(node, nsResolver);
+            this.index = node.getIndex();
+            this.primaryTypeName = NameFormat.parse(node.getPrimaryNodeType().getName(), nsResolver);
+            NodeType[] mixins = node.getMixinNodeTypes();
+            this.mixinNames = new QName[mixins.length];
+            for (int i = 0; i < mixins.length; i++) {
+                mixinNames[i] = NameFormat.parse(mixins[i].getName(), nsResolver);
+            }
+            this.references = new ArrayList();
+            for (PropertyIterator it = node.getReferences(); it.hasNext(); ) {
+                references.add(idFactory.createPropertyId(it.nextProperty(), nsResolver));
+            }
+            this.propertyIds = new ArrayList();
+            for (PropertyIterator it = node.getProperties(); it.hasNext(); ) {
+                propertyIds.add(idFactory.createPropertyId(it.nextProperty(), nsResolver));
+            }
+        } catch (NameException e) {
+            throw new RepositoryException(e.getMessage(), e);
+        }
+    }
+
+    //-------------------------------< NodeInfo >-------------------------------
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId getId() {
+        return id;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getIndex() {
+        return index;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getNodetype() {
+        return primaryTypeName;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName[] getMixins() {
+        QName[] ret = new QName[mixinNames.length];
+        System.arraycopy(mixinNames, 0, ret, 0, mixinNames.length);
+        return ret;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public PropertyId[] getReferences() {
+        return (PropertyId[]) references.toArray(new PropertyId[references.size()]);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public IdIterator getPropertyIds() {
+        return new IteratorHelper(propertyIds);
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,116 @@
+/*
+ * 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.spi2jcr;
+
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.value.ValueFormat;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Property;
+import javax.jcr.Value;
+
+/**
+ * <code>PropertyInfoImpl</code> implements a <code>PropertyInfo</code> on top
+ * of a JCR repository.
+ */
+class PropertyInfoImpl extends ItemInfoImpl implements PropertyInfo {
+
+    /**
+     * The property info of the underlying property.
+     */
+    private final PropertyId propertyId;
+
+    /**
+     * The type of the property.
+     */
+    private final int type;
+
+    /**
+     * The multiValued flag.
+     */
+    private final boolean isMultiValued;
+
+    /**
+     * The values of this property info.
+     */
+    private final QValue[] values;
+
+    /**
+     * Creates a new property info for the given <code>property</code>.
+     *
+     * @param property      the JCR property.
+     * @param idFactory     the id factory.
+     * @param nsResolver    the namespace resolver in use.
+     * @param qValueFactory the QValue factory.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>property</code>.
+     */
+    public PropertyInfoImpl(Property property,
+                            IdFactoryImpl idFactory,
+                            NamespaceResolver nsResolver,
+                            QValueFactory qValueFactory) throws RepositoryException {
+        super(property, idFactory, nsResolver);
+        this.propertyId = idFactory.createPropertyId(property, nsResolver);
+        this.type = property.getType();
+        this.isMultiValued = property.getDefinition().isMultiple();
+        if (isMultiValued) {
+            Value[] jcrValues = property.getValues();
+            this.values = new QValue[jcrValues.length];
+            for (int i = 0; i < jcrValues.length; i++) {
+                this.values[i] = ValueFormat.getQValue(jcrValues[i],
+                        nsResolver, qValueFactory);
+            }
+        } else {
+            this.values = new QValue[]{
+                ValueFormat.getQValue(property.getValue(), nsResolver, qValueFactory)};
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public PropertyId getId() {
+        return propertyId;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getType() {
+        return type;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMultiValued() {
+        return isMultiValued;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QValue[] getValues() {
+        QValue[] vals = new QValue[values.length];
+        System.arraycopy(values, 0, vals, 0, values.length);
+        return vals;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QItemDefinitionImpl.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QItemDefinitionImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QItemDefinitionImpl.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,184 @@
+/*
+ * 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.spi2jcr;
+
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.NameException;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ItemDefinition;
+
+/**
+ * This abstract class implements the <code>QItemDefinition</code>
+ * interface and additionally provides setter methods for the
+ * various item definition attributes.
+ * TODO: mostly copied from spi2dav, move common parts to spi-commons.
+ */
+abstract class QItemDefinitionImpl implements QItemDefinition {
+
+    /**
+     * The special wildcard name used as the name of residual item definitions.
+     */
+    public static final QName ANY_NAME = new QName("", "*");
+
+    /**
+     * The name of the child item.
+     */
+    private final QName name;
+
+    /**
+     * The name of the declaring node type.
+     */
+    private final QName declaringNodeType;
+
+    /**
+     * The 'autoCreated' flag.
+     */
+    private final boolean autoCreated;
+
+    /**
+     * The 'onParentVersion' attribute.
+     */
+    private final int onParentVersion;
+
+    /**
+     * The 'protected' flag.
+     */
+    private final boolean writeProtected;
+
+    /**
+     * The 'mandatory' flag.
+     */
+    private final boolean mandatory;
+
+    /**
+     * HashCode of this object
+     */
+    protected int hashCode = 0;
+
+    /**
+     *
+     * @param itemDef
+     * @param nsResolver
+     * @throws RepositoryException
+     */
+    QItemDefinitionImpl(ItemDefinition itemDef,
+                        NamespaceResolver nsResolver)
+        throws RepositoryException {
+        try {
+            this.autoCreated = itemDef.isAutoCreated();
+            this.declaringNodeType = NameFormat.parse(itemDef.getDeclaringNodeType().getName(), nsResolver);
+            this.mandatory = itemDef.isMandatory();
+            this.name = itemDef.getName().equals(ANY_NAME.getLocalName()) ? ANY_NAME : NameFormat.parse(itemDef.getName(), nsResolver);
+            this.onParentVersion = itemDef.getOnParentVersion();
+            this.writeProtected = itemDef.isProtected();
+        } catch (NameException e) {
+            throw new RepositoryException(e.getMessage());
+        }
+    }
+
+    //--------------------------------------------------------------< QItemDefinition >
+    /**
+     * {@inheritDoc}
+     */
+    public QName getDeclaringNodeType() {
+        return declaringNodeType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getQName() {
+        return name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isAutoCreated() {
+        return autoCreated;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getOnParentVersion() {
+        return onParentVersion;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isProtected() {
+        return writeProtected;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMandatory() {
+        return mandatory;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean definesResidual() {
+        return name.equals(ANY_NAME);
+    }
+
+    //-------------------------------------------< java.lang.Object overrides >
+    /**
+     * Compares two item definitions for equality. Returns <code>true</code>
+     * if the given object is an item defintion and has the same attributes
+     * as this item definition.
+     *
+     * @param obj the object to compare this item definition with
+     * @return <code>true</code> if the object is equal to this item definition,
+     *         <code>false</code> otherwise
+     * @see Object#equals(Object)
+     */
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof QItemDefinition) {
+            QItemDefinition other = (QItemDefinition) obj;
+            return (declaringNodeType == null
+                    ? other.getDeclaringNodeType() == null
+                    : declaringNodeType.equals(other.getDeclaringNodeType()))
+                    && (name == null ? other.getQName() == null : name.equals(other.getQName()))
+                    && autoCreated == other.isAutoCreated()
+                    && onParentVersion == other.getOnParentVersion()
+                    && writeProtected == other.isProtected()
+                    && mandatory == other.isMandatory();
+        }
+        return false;
+    }
+
+    /**
+     * See {@link QNodeDefinition#hashCode()} and {@link QPropertyDefinition#hashCode()}.
+     *
+     * @return
+     */
+    public abstract int hashCode();
+}

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QItemDefinitionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeDefinitionImpl.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeDefinitionImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeDefinitionImpl.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,172 @@
+/*
+ * 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.spi2jcr;
+
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.name.NameException;
+
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.RepositoryException;
+import java.util.Arrays;
+import java.util.TreeSet;
+
+/**
+ * <code>QNodeDefinitionImpl</code> implements a <code>QNodeDefinition</code>.
+ * TODO: mostly copied from spi2dav, move common parts to spi-commons.
+ */
+class QNodeDefinitionImpl extends QItemDefinitionImpl implements QNodeDefinition {
+
+    /**
+     * The name of the default primary type.
+     */
+    private final QName defaultPrimaryType;
+
+    /**
+     * The names of the required primary types.
+     */
+    private final QName[] requiredPrimaryTypes;
+
+    /**
+     * The 'allowsSameNameSiblings' flag.
+     */
+    private final boolean allowsSameNameSiblings;
+
+    /**
+     * Creates a new qualified node definition based on a JCR NodeDefinition.
+     *
+     * @param nodeDef    the node definition.
+     * @param nsResolver the namespace resolver in use.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>nodeDef</code>.
+     */
+    QNodeDefinitionImpl(NodeDefinition nodeDef,
+                        NamespaceResolver nsResolver) throws RepositoryException {
+        super(nodeDef, nsResolver);
+        try {
+            this.allowsSameNameSiblings = nodeDef.allowsSameNameSiblings();
+            NodeType defPrimaryType = nodeDef.getDefaultPrimaryType();
+            if (defPrimaryType == null) {
+                this.defaultPrimaryType = null;
+            } else {
+                this.defaultPrimaryType = NameFormat.parse(nodeDef.getDefaultPrimaryType().getName(), nsResolver);
+            }
+            NodeType[] reqPrimaryTypes = nodeDef.getRequiredPrimaryTypes();
+            this.requiredPrimaryTypes = new QName[reqPrimaryTypes.length];
+            for (int i = 0; i < reqPrimaryTypes.length; i++) {
+                QName ntName = NameFormat.parse(reqPrimaryTypes[i].getName(), nsResolver);
+                this.requiredPrimaryTypes[i] = ntName;
+            }
+        } catch (NameException e) {
+            throw new RepositoryException(e.getMessage());
+        }
+    }
+
+    //-------------------------------------------------------< QNodeDefinition >
+    /**
+     * {@inheritDoc}
+     */
+    public QName getDefaultPrimaryType() {
+        return defaultPrimaryType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName[] getRequiredPrimaryTypes() {
+        return requiredPrimaryTypes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean allowsSameNameSiblings() {
+        return allowsSameNameSiblings;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return always <code>true</code>
+     */
+    public boolean definesNode() {
+        return true;
+    }
+
+    //-------------------------------------------< java.lang.Object overrides >
+    /**
+     * Compares two node definitions for equality. Returns <code>true</code>
+     * if the given object is a node defintion and has the same attributes
+     * as this node definition.
+     *
+     * @param obj the object to compare this node definition with
+     * @return <code>true</code> if the object is equal to this node definition,
+     *         <code>false</code> otherwise
+     * @see Object#equals(Object)
+     */
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof QNodeDefinition) {
+            QNodeDefinition other = (QNodeDefinition) obj;
+            return super.equals(obj)
+                    && Arrays.equals(requiredPrimaryTypes, other.getRequiredPrimaryTypes())
+                    && (defaultPrimaryType == null
+                            ? other.getDefaultPrimaryType() == null
+                            : defaultPrimaryType.equals(other.getDefaultPrimaryType()))
+                    && allowsSameNameSiblings == other.allowsSameNameSiblings();
+        }
+        return false;
+    }
+
+    /**
+     * Overwrites {@link QItemDefinitionImpl#hashCode()}.
+     *
+     * @return
+     */
+    public int hashCode() {
+        if (hashCode == 0) {
+            // build hashCode (format: <declaringNodeType>/<name>/<requiredPrimaryTypes>)
+            StringBuffer sb = new StringBuffer();
+
+            if (getDeclaringNodeType() != null) {
+                sb.append(getDeclaringNodeType().toString());
+                sb.append('/');
+            }
+            if (definesResidual()) {
+                sb.append('*');
+            } else {
+                sb.append(getQName().toString());
+            }
+            sb.append('/');
+            // set of required node type names, sorted in ascending order
+            TreeSet set = new TreeSet();
+            QName[] names = getRequiredPrimaryTypes();
+            for (int i = 0; i < names.length; i++) {
+                set.add(names[i]);
+            }
+            sb.append(set.toString());
+
+            hashCode = sb.toString().hashCode();
+        }
+        return hashCode;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeDefinitionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeTypeDefinitionImpl.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeTypeDefinitionImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeTypeDefinitionImpl.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,228 @@
+/*
+ * 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.spi2jcr;
+
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.name.NameException;
+
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.RepositoryException;
+import javax.jcr.PropertyType;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Collections;
+
+/**
+ * <code>QNodeTypeDefinitionImpl</code> implements a qualified node type
+ * definition based on a JCR {@link NodeType}.
+ */
+class QNodeTypeDefinitionImpl implements QNodeTypeDefinition {
+
+    /**
+     * The name of the node definition.
+     */
+    private final QName name;
+
+    /**
+     * The names of the declared super types of this node type definition.
+     */
+    private final QName[] supertypes;
+
+    /**
+     * Indicates whether this is a mixin node type definition.
+     */
+    private final boolean isMixin;
+
+    /**
+     * Indicates whether this node type definition has orderable child nodes.
+     */
+    private final boolean hasOrderableChildNodes;
+
+    /**
+     * The name of the primary item or <code>null</code> if none is defined.
+     */
+    private final QName primaryItemName;
+
+    /**
+     * The list of property definitions.
+     */
+    private final QPropertyDefinition[] propertyDefs;
+
+    /**
+     * The list of child node definitions.
+     */
+    private final QNodeDefinition[] childNodeDefs;
+
+    /**
+     * Unmodifiable collection of dependent node type <code>QName</code>s.
+     * @see #getDependencies()
+     */
+    private Collection dependencies;
+
+    /**
+     * Creates a new qualified node type definition based on a JCR
+     * <code>NodeType</code>.
+     *
+     * @param nt            the JCR node type.
+     * @param nsResolver    the namespace resolver in use.
+     * @param qValueFactory the QValue factory.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>nt</code>.
+     */
+    public QNodeTypeDefinitionImpl(NodeType nt,
+                                   NamespaceResolver nsResolver,
+                                   QValueFactory qValueFactory)
+            throws RepositoryException {
+        try {
+            this.name = NameFormat.parse(nt.getName(), nsResolver);
+            NodeType[] superNts = nt.getDeclaredSupertypes();
+            this.supertypes = new QName[superNts.length];
+            for (int i = 0; i < superNts.length; i++) {
+                supertypes[i] = NameFormat.parse(superNts[i].getName(), nsResolver);
+            }
+            this.isMixin = nt.isMixin();
+            this.hasOrderableChildNodes = nt.hasOrderableChildNodes();
+            String primaryItemJcrName = nt.getPrimaryItemName();
+            if (primaryItemJcrName == null) {
+                this.primaryItemName = null;
+            } else {
+                this.primaryItemName = NameFormat.parse(primaryItemJcrName, nsResolver);
+            }
+        } catch (NameException e) {
+            throw new RepositoryException(e.getMessage(), e);
+        }
+        PropertyDefinition[] propDefs = nt.getDeclaredPropertyDefinitions();
+        this.propertyDefs = new QPropertyDefinition[propDefs.length];
+        for (int i = 0; i < propDefs.length; i++) {
+            this.propertyDefs[i] = new QPropertyDefinitionImpl(
+                    propDefs[i], nsResolver, qValueFactory);
+        }
+        NodeDefinition[] nodeDefs = nt.getDeclaredChildNodeDefinitions();
+        this.childNodeDefs = new QNodeDefinition[nodeDefs.length];
+        for (int i = 0; i < nodeDefs.length; i++) {
+            this.childNodeDefs[i] = new QNodeDefinitionImpl(nodeDefs[i], nsResolver);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getQName() {
+        return name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName[] getSupertypes() {
+        QName[] sTypes = new QName[supertypes.length];
+        System.arraycopy(supertypes, 0, sTypes, 0, supertypes.length);
+        return sTypes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMixin() {
+        return isMixin;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean hasOrderableChildNodes() {
+        return hasOrderableChildNodes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getPrimaryItemName() {
+        return primaryItemName;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QPropertyDefinition[] getPropertyDefs() {
+        QPropertyDefinition[] pDefs = new QPropertyDefinition[propertyDefs.length];
+        System.arraycopy(propertyDefs, 0, pDefs, 0, propertyDefs.length);
+        return pDefs;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QNodeDefinition[] getChildNodeDefs() {
+        QNodeDefinition[] cnDefs = new QNodeDefinition[childNodeDefs.length];
+        System.arraycopy(childNodeDefs, 0, cnDefs, 0, childNodeDefs.length);
+        return cnDefs;
+    }
+
+    /**
+     * TODO: generalize (this method is copied from spi2dav)
+     */
+    public Collection getDependencies() {
+        if (dependencies == null) {
+            Collection deps = new HashSet();
+            // supertypes
+            for (int i = 0; i < supertypes.length; i++) {
+                deps.add(supertypes[i]);
+            }
+            // child node definitions
+            for (int i = 0; i < childNodeDefs.length; i++) {
+                // default primary type
+                QName ntName = childNodeDefs[i].getDefaultPrimaryType();
+                if (ntName != null && !name.equals(ntName)) {
+                    deps.add(ntName);
+                }
+                // required primary type
+                QName[] ntNames = childNodeDefs[i].getRequiredPrimaryTypes();
+                for (int j = 0; j < ntNames.length; j++) {
+                    if (ntNames[j] != null && !name.equals(ntNames[j])) {
+                        deps.add(ntNames[j]);
+                    }
+                }
+            }
+            // property definitions
+            for (int i = 0; i < propertyDefs.length; i++) {
+                // REFERENCE value constraints
+                if (propertyDefs[i].getRequiredType() == PropertyType.REFERENCE) {
+                    String[] ca = propertyDefs[i].getValueConstraints();
+                    if (ca != null) {
+                        for (int j = 0; j < ca.length; j++) {
+                            QName ntName = QName.valueOf(ca[j]);
+                            if (!name.equals(ntName)) {
+                                deps.add(ntName);
+                            }
+                        }
+                    }
+                }
+            }
+            dependencies = Collections.unmodifiableCollection(deps);
+        }
+        return dependencies;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeTypeDefinitionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java?view=auto&rev=511801
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java Mon Feb 26 05:36:57 2007
@@ -0,0 +1,185 @@
+/*
+ * 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.spi2jcr;
+
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.value.ValueFormat;
+
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.PropertyType;
+import java.util.Arrays;
+
+/**
+ * <code>QPropertyDefinitionImpl</code> implements a qualified property
+ * definition based on a JCR {@link javax.jcr.nodetype.PropertyDefinition}.
+ * TODO: mostly copied from spi2dav, move common parts to spi-commons.
+ */
+class QPropertyDefinitionImpl extends QItemDefinitionImpl implements QPropertyDefinition {
+
+    /**
+     * The required type.
+     */
+    private final int requiredType;
+
+    /**
+     * The value constraints.
+     */
+    private final String[] valueConstraints;
+
+    /**
+     * The default values.
+     */
+    private final QValue[] defaultValues;
+
+    /**
+     * The 'multiple' flag
+     */
+    private final boolean multiple;
+
+    /**
+     * Creates a new qualified property definition based on
+     * <code>propDef</code>.
+     *
+     * @param propDef       the JCR property definition.
+     * @param nsResolver    the namespace resolver in use.
+     * @param qValueFactory the QValue factory.
+     * @throws RepositoryException if an error occurs while reading from
+     *                             <code>propDef</code>.
+     */
+    QPropertyDefinitionImpl(PropertyDefinition propDef,
+                            NamespaceResolver nsResolver,
+                            QValueFactory qValueFactory) throws RepositoryException {
+        super(propDef, nsResolver);
+        Value[] defValues = propDef.getDefaultValues();
+        if (defValues != null) {
+            defaultValues = new QValue[defValues.length];
+            for (int i = 0; i < defValues.length; i++) {
+                defaultValues[i] = ValueFormat.getQValue(defValues[i], nsResolver, qValueFactory);
+            }
+        } else {
+            defaultValues = null;
+        }
+        this.multiple = propDef.isMultiple();
+        this.requiredType = propDef.getRequiredType();
+        this.valueConstraints = propDef.getValueConstraints();
+        if (requiredType == PropertyType.REFERENCE
+                || requiredType == PropertyType.NAME
+                || requiredType == PropertyType.PATH) {
+            for (int i = 0; i < valueConstraints.length; i++) {
+                int type = requiredType == PropertyType.REFERENCE ? PropertyType.NAME : requiredType;
+                this.valueConstraints[i] = ValueFormat.getQValue(
+                        valueConstraints[i], type, nsResolver, qValueFactory).getString();
+            }
+        }
+    }
+
+    //------------------------------------------------< QPropertyDefinition >---
+    /**
+     * {@inheritDoc}
+     */
+    public int getRequiredType() {
+        return requiredType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getValueConstraints() {
+        return valueConstraints;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QValue[] getDefaultValues() {
+        return defaultValues;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMultiple() {
+        return multiple;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return always <code>false</code>
+     */
+    public boolean definesNode() {
+        return false;
+    }
+
+    //-------------------------------------------< java.lang.Object overrides >
+    /**
+     * Compares two property definitions for equality. Returns <code>true</code>
+     * if the given object is a property defintion and has the same attributes
+     * as this property definition.
+     *
+     * @param obj the object to compare this property definition with
+     * @return <code>true</code> if the object is equal to this property definition,
+     *         <code>false</code> otherwise
+     * @see Object#equals(Object)
+     */
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof QPropertyDefinition) {
+            QPropertyDefinition other = (QPropertyDefinition) obj;
+            return super.equals(obj)
+                    && requiredType == other.getRequiredType()
+                    && Arrays.equals(valueConstraints, other.getValueConstraints())
+                    && Arrays.equals(defaultValues, other.getDefaultValues())
+                    && multiple == other.isMultiple();
+        }
+        return false;
+    }
+
+    /**
+     * Overwrites {@link QItemDefinitionImpl#hashCode()}.
+     *
+     * @return
+     */
+    public int hashCode() {
+        if (hashCode == 0) {
+            // build hashCode (format: <declaringNodeType>/<name>/<requiredType>/<multiple>)
+            StringBuffer sb = new StringBuffer();
+
+            sb.append(getDeclaringNodeType().toString());
+            sb.append('/');
+            if (definesResidual()) {
+                sb.append('*');
+            } else {
+                sb.append(getQName().toString());
+            }
+            sb.append('/');
+            sb.append(getRequiredType());
+            sb.append('/');
+            sb.append(isMultiple() ? 1 : 0);
+
+            hashCode = sb.toString().hashCode();
+        }
+        return hashCode;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message