jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r928437 [1/3] - in /jackrabbit/sandbox/jackrabbit-j3: ./ src/main/java/org/apache/jackrabbit/j3/ src/main/java/org/apache/jackrabbit/j3/lock/ src/main/java/org/apache/jackrabbit/j3/mc/ src/main/java/org/apache/jackrabbit/j3/mc/jdbc/ src/mai...
Date Sun, 28 Mar 2010 15:43:20 GMT
Author: thomasm
Date: Sun Mar 28 15:43:18 2010
New Revision: 928437

URL: http://svn.apache.org/viewvc?rev=928437&view=rev
Log:
Some code for a Jackrabbit 3 prototype

Added:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeList.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/DelegatingAdapterManager.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NamespaceRegistryImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueFactoryImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/WorkspaceImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockManagerImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockSystem.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/ItemDefinitionImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionTemplateImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeDefinitionImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeManagerImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeRegistry.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeTemplateImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionTemplateImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventConsumer.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/ObservationManagerImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/PrivilegeImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/site/
    jackrabbit/sandbox/jackrabbit-j3/src/site/resources/
    jackrabbit/sandbox/jackrabbit-j3/src/site/resources/images/
    jackrabbit/sandbox/jackrabbit-j3/src/site/resources/images/drawing.png   (with props)
    jackrabbit/sandbox/jackrabbit-j3/src/site/resources/images/drawing.svg
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/Profiler.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestLock.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestNamespaceRegistry.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestNodeTypeRegistry.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestObservation.java
Removed:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventImpl.java
Modified:
    jackrabbit/sandbox/jackrabbit-j3/   (props changed)
    jackrabbit/sandbox/jackrabbit-j3/pom.xml
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Cache.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Change.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Constants.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ExceptionFactory.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeIteratorImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeState.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryFactoryImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/SessionImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/McException.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/NodeData.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Storage.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/StorageSession.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorage.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorageSession.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorage.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorageSession.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBase.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBundle.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestConcurrentWrite.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestNextConfiguration.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestSimple.java

Propchange: jackrabbit/sandbox/jackrabbit-j3/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Mar 28 15:43:18 2010
@@ -2,3 +2,4 @@
 .classpath
 .project
 target
+.checkstyle

Modified: jackrabbit/sandbox/jackrabbit-j3/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/pom.xml?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/pom.xml (original)
+++ jackrabbit/sandbox/jackrabbit-j3/pom.xml Sun Mar 28 15:43:18 2010
@@ -35,15 +35,15 @@
   </description>
 
  <dependencies>
-    <dependency>
-      <groupId>javax.jcr</groupId>
-      <artifactId>jcr</artifactId>
-      <version>2.0</version>
-    </dependency>
+  <dependency>
+   <groupId>javax.jcr</groupId>
+   <artifactId>jcr</artifactId>
+   <version>2.0</version>
+  </dependency>
   <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
-   <version>3.8.1</version>   
+   <version>3.8.1</version>
    <scope>test</scope>
   </dependency>
   <dependency>
@@ -52,6 +52,24 @@
    <version>1.2.131</version>
    <scope>test</scope>
   </dependency>
+  <dependency>
+   <groupId>commons-io</groupId>
+   <artifactId>commons-io</artifactId>
+   <version>1.4</version>
+   <scope>test</scope>
+  </dependency>
  </dependencies>
-
+ 
+   <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <target>1.5</target>
+          <source>1.5</source>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+ 
 </project>

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Cache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Cache.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Cache.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Cache.java Sun Mar 28 15:43:18 2010
@@ -19,6 +19,12 @@ package org.apache.jackrabbit.j3;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+/**
+ * A simple cache implementation.
+ *
+ * @param <K> the key
+ * @param <V> the value
+ */
 public class Cache<K, V> extends LinkedHashMap<K, V> {
 
     private final int maxSize;

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Change.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Change.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Change.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Change.java Sun Mar 28 15:43:18 2010
@@ -1,41 +1,220 @@
+/*
+ * 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.j3;
 
+import java.util.Collections;
+import java.util.Map;
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
+import javax.jcr.observation.Event;
+import org.apache.jackrabbit.j3.lock.LockImpl;
 import org.apache.jackrabbit.j3.mc.Val;
 
-public interface Change {
+/**
+ * A change.
+ */
+public abstract class Change implements Event {
 
-    void apply(SessionImpl session);
+    private final ChangeList changeList;
+
+    Change(SessionImpl session) {
+        this.changeList = session.getChangeList();
+    }
+
+    abstract void apply() throws RepositoryException;
+
+    public String getUserData() {
+        return changeList.getUserData();
+    }
+
+    public String getUserID() {
+        return changeList.getUserID();
+    }
+
+    public long getDate() {
+        return changeList.getPersistedDate();
+    }
+
+    public Map<String, String> getInfo() {
+        return Collections.emptyMap();
+    }
+
+    public String getIdentifier() {
+        return null;
+    }
+
+    public String getPath() throws RepositoryException {
+        return null;
+    }
+
+    public void applyAndAddChange() throws RepositoryException {
+        apply();
+        changeList.add(this);
+    }
 
 }
 
-class ChangeAddNode implements Change {
+/**
+ * Add a node.
+ */
+class ChangeAddNode extends Change {
     NodeImpl newNode;
     Val childName;
+    private String path;
 
-    public void apply(SessionImpl session) {
+    ChangeAddNode(SessionImpl session) {
+        super(session);
+    }
+
+    public void apply() throws LockException {
         newNode.getParentNode().doAddNode(childName, newNode);
     }
 
+    public int getType() {
+        return Event.NODE_ADDED;
+    }
+
+    public String getPath() throws RepositoryException {
+        if (path == null) {
+            path = newNode.getPath();
+        }
+        return path;
+    }
+
 }
 
-class ChangeSetProperty implements Change {
+/**
+ * Add a property.
+ */
+class ChangeAddProperty extends Change {
     NodeImpl node;
     Val propertyName;
     Val value;
-    PropertyImpl property;
+    private String path;
+
+    ChangeAddProperty(SessionImpl session) {
+        super(session);
+    }
 
-    public void apply(SessionImpl session) {
+    public void apply() throws LockException {
         node.doSetProperty(propertyName, value);
     }
 
+    public int getType() {
+        return Event.PROPERTY_ADDED;
+    }
+
+    public String getPath() throws RepositoryException {
+        if (path == null) {
+            path = node.getPath() + "/" + node.getNodeState().nameToString(propertyName);
+        }
+        return path;
+    }
+
 }
 
-class ChangeRemoveNode implements Change {
+/**
+ * Change a property.
+ */
+class ChangeModifyProperty extends Change {
     NodeImpl node;
+    Val propertyName;
+    Val value;
+    private String path;
+
+    ChangeModifyProperty(SessionImpl session) {
+        super(session);
+    }
 
-    public void apply(SessionImpl session) {
+    public void apply() throws LockException {
+        node.doSetProperty(propertyName, value);
+    }
+
+    public int getType() {
+        return Event.PROPERTY_CHANGED;
+    }
+
+    public String getPath() throws RepositoryException {
+        if (path == null) {
+            path = node.getPath() + "/" + node.getNodeState().nameToString(propertyName);
+        }
+        return path;
+    }
+
+}
+
+/**
+ * Remove a node.
+ */
+class ChangeRemoveNode extends Change {
+    NodeImpl node;
+
+    ChangeRemoveNode(SessionImpl session) {
+        super(session);
+    }
+
+    public void apply() throws LockException {
         // TODO remove all child nodes as well (maybe as a background process)
         node.doRemove();
     }
 
+    public int getType() {
+        return Event.NODE_REMOVED;
+    }
+
+}
+
+/**
+ * Add a mixin.
+ */
+class ChangeAddMixin extends Change {
+    NodeImpl node;
+    Val mixin;
+
+    ChangeAddMixin(SessionImpl session) {
+        super(session);
+    }
+
+    public void apply() throws LockException {
+        node.doAddMixin(mixin);
+    }
+
+    public int getType() {
+        return Event.PROPERTY_CHANGED;
+    }
+
+}
+
+/**
+ * Add a lock.
+ */
+class ChangeAddLock extends Change {
+    LockImpl lock;
+
+    ChangeAddLock(SessionImpl session) {
+        super(session);
+    }
+
+    public void apply() throws RepositoryException {
+        lock.getNode().doAddLock(lock);
+    }
+
+    public int getType() {
+        return Event.PROPERTY_ADDED;
+    }
+
 }
\ No newline at end of file

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeList.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeList.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeList.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeList.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,78 @@
+/*
+ * 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.j3;
+
+import java.util.LinkedList;
+import javax.jcr.RepositoryException;
+
+/**
+ * A list of changes.
+ */
+public class ChangeList {
+
+    private final SessionImpl session;
+    private final LinkedList<Change> changes = new LinkedList<Change>();
+    private final String userID;
+    private long persistedDate;
+    private String userData;
+
+    ChangeList(SessionImpl session) {
+        this.session = session;
+        this.userID = session.getUserID();
+    }
+
+    public SessionImpl getSession() {
+        return session;
+    }
+
+    void persisted() {
+        persistedDate = System.currentTimeMillis();
+        userData = session.getObservationUserData();
+        session.getRepository().dispatchEvents(this);
+    }
+
+    public long getPersistedDate() {
+        return persistedDate;
+    }
+
+    public void apply() throws RepositoryException {
+        for (Change c : changes) {
+            c.apply();
+        }
+    }
+
+    public void add(Change change) {
+        changes.add(change);
+    }
+
+    public String toString() {
+        return "" + changes.size();
+    }
+
+    public LinkedList<Change> getChangeList() {
+        return changes;
+    }
+
+    public String getUserData() {
+        return userData;
+    }
+
+    public String getUserID() {
+        return userID;
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Constants.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Constants.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Constants.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Constants.java Sun Mar 28 15:43:18 2010
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.j3;
 
+/**
+ * Constants used in this project.
+ */
 public class Constants {
     public static final int VERSION_MAJOR = 3;
     public static final int VERSION_MINOR = 0;

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/DelegatingAdapterManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/DelegatingAdapterManager.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/DelegatingAdapterManager.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/DelegatingAdapterManager.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,51 @@
+/*
+ * 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.j3;
+
+import java.rmi.UnexpectedException;
+import javax.rmi.CORBA.PortableRemoteObjectDelegate;
+import org.omg.CORBA.UNKNOWN;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.PortableServer.POAPackage.WrongAdapter;
+
+/**
+ * The class that implements this abstract class recursively manages the
+ * abstract delegation of delegating an adapter. Get the concrete implementation
+ * using the DelegatingAdapterManagerFactory, which you get using the
+ * ...FactoryBuilder. Instantiation itself is delegated.
+ * <p>
+ * The buck passing pattern adds infinitely many layers of indirection, and
+ * therefore can solve any problem. To reduce complexity and help others
+ * understand the code, please ensure that each method only calls one other
+ * method. To keep things modular, reusable, and disaster safe, ensure that
+ * interfaces, implementation, exceptions, and tests are in distinct projects,
+ * in separate SCM systems.
+ * <p>
+ * It is preferred that the configuration is generated at at runtime, using XML
+ * and JNDI. Avoid determinism, and specially avoid keeping things simple; also
+ * avoid anything else written at http://en.wikipedia.org/wiki/KISS_principle
+ */
+public abstract class DelegatingAdapterManager {
+
+    /**
+     * Delegate.
+     *
+     * @param delegate the delegate
+     * @returns the wrong adapter
+     * @throws an unknown exception
+     */
+    abstract WrongAdapter delegate(PortableRemoteObjectDelegate delegate) throws
+            UnexpectedException, UnknownException, UnknownError, UNKNOWN;
+
+}

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ExceptionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ExceptionFactory.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ExceptionFactory.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ExceptionFactory.java Sun Mar 28 15:43:18 2010
@@ -20,11 +20,15 @@ import java.text.MessageFormat;
 import java.util.HashMap;
 import javax.jcr.RepositoryException;
 
+/**
+ * A exception factory.
+ */
 public class ExceptionFactory {
-    final static int CLOSED_0 = 1000;
+
+    static final int CLOSED_0 = 1000;
     static final int CONCURRENT_UPDATE_1 = 1001;
 
-    final static HashMap<Integer, String> MESSAGE_MAP = new HashMap<Integer, String>();
+    static final HashMap<Integer, String> MESSAGE_MAP = new HashMap<Integer, String>();
 
 
     static {

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NamespaceRegistryImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NamespaceRegistryImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NamespaceRegistryImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,113 @@
+/*
+ * 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.j3;
+
+import java.util.HashMap;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+/**
+ * A namespace registry implementation.
+ */
+public class NamespaceRegistryImpl implements NamespaceRegistry {
+
+    public static final NamespaceRegistryImpl BUILT_IN = new NamespaceRegistryImpl(null);
+
+    static {
+        NamespaceRegistryImpl registry = BUILT_IN;
+        registry.register(PREFIX_JCR, NAMESPACE_JCR);
+        registry.register(PREFIX_NT, NAMESPACE_NT);
+        registry.register(PREFIX_MIX, NAMESPACE_MIX);
+        registry.register(PREFIX_XML, NAMESPACE_XML);
+        registry.register(PREFIX_EMPTY, NAMESPACE_EMPTY);
+    }
+
+    private final NamespaceRegistryImpl parent;
+    private HashMap<String, String> prefixToUri = new HashMap<String, String>();
+    private HashMap<String, String> uriToPrefix = new HashMap<String, String>();
+    private boolean shareMapsWithParent;
+
+    private NamespaceRegistryImpl(NamespaceRegistryImpl parent) {
+        this.parent = parent;
+        if (parent != null) {
+            prefixToUri = parent.prefixToUri;
+            uriToPrefix = parent.uriToPrefix;
+            shareMapsWithParent = true;
+        }
+    }
+
+    public static NamespaceRegistryImpl createLocalInstance() {
+        return new NamespaceRegistryImpl(BUILT_IN);
+    }
+
+    public String getPrefix(String uri) {
+        return uriToPrefix.get(uri);
+    }
+
+    public synchronized String[] getPrefixes() throws RepositoryException {
+        String[] prefixes = new String[prefixToUri.size()];
+        prefixToUri.keySet().toArray(prefixes);
+        return prefixes;
+    }
+
+    public String getURI(String prefix) {
+        return prefixToUri.get(prefix);
+    }
+
+    public synchronized String[] getURIs() throws RepositoryException {
+        String[] uris = new String[uriToPrefix.size()];
+        uriToPrefix.keySet().toArray(uris);
+        return uris;
+    }
+
+    public void registerNamespace(String prefix, String uri) throws NamespaceException,
+            UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+        if (parent.prefixToUri.containsKey(prefix) || parent.uriToPrefix.containsKey(uri)) {
+            throw new NamespaceException("Can not redefine a built-in prefix");
+        }
+        if (prefix.equalsIgnoreCase("xml")) {
+            throw new NamespaceException("Can not redefine an xml variant");
+        }
+        register(prefix, uri);
+    }
+
+    private synchronized void register(String prefix, String uri) {
+        if (shareMapsWithParent) {
+            prefixToUri = new HashMap<String, String>(prefixToUri);
+            uriToPrefix = new HashMap<String, String>(uriToPrefix);
+            shareMapsWithParent = false;
+        }
+        prefixToUri.put(prefix, uri);
+        uriToPrefix.put(uri, prefix);
+    }
+
+    public synchronized void unregisterNamespace(String prefix) throws NamespaceException, UnsupportedRepositoryOperationException,
+            AccessDeniedException, RepositoryException {
+        if (parent.prefixToUri.containsKey(prefix)) {
+            throw new NamespaceException("Can not unregister a built-in prefix");
+        }
+        if (!prefixToUri.containsKey(prefix)) {
+            throw new NamespaceException("Not registered");
+        }
+        String uri = prefixToUri.remove(prefix);
+        uriToPrefix.remove(uri);
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeImpl.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeImpl.java Sun Mar 28 15:43:18 2010
@@ -16,7 +16,9 @@
  */
 package org.apache.jackrabbit.j3;
 
+import org.apache.jackrabbit.j3.lock.LockImpl;
 import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.security.PrivilegeImpl;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.Calendar;
@@ -52,6 +54,9 @@ import javax.jcr.version.Version;
 import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
 
+/**
+ * A node implementation.
+ */
 public class NodeImpl implements Node {
 
     private final NodeState state;
@@ -61,6 +66,7 @@ public class NodeImpl implements Node {
      * the main parent).
      */
     private NodeImpl parent;
+    private int privilegesChecked;
 
     NodeImpl(NodeImpl parent, NodeState state) {
         this.state = state;
@@ -69,42 +75,54 @@ public class NodeImpl implements Node {
 
     public NodeImpl addNode(String relPath, String primaryNodeTypeName) throws ItemExistsException, PathNotFoundException,
             NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException {
-        ChangeAddNode change = new ChangeAddNode();
+        // TODO primaryNodeTypeName is incorrect
+        return addNode(relPath, NodeState.NT_UNSTRUCTURED);
+    }
+
+    private NodeImpl addNode(String relPath, Val primaryNodeType) throws RepositoryException {
         SessionImpl s = state.getSession();
+        ChangeAddNode change = new ChangeAddNode(s);
+        change.childName = Val.get(relPath);
+        ChangeAddProperty changePrimaryType = new ChangeAddProperty(s);
+        changePrimaryType.propertyName = NodeState.PROPERTY_PRIMARY_TYPE;
+        changePrimaryType.value = primaryNodeType;
         synchronized (s) {
-            // TODO primaryNodeTypeName is ignored
-            change.newNode = s.createNode(this, state.getId());
-            change.childName = Val.get(relPath);
-            s.addChange(change);
+            NodeImpl node = s.createNode(this, state.getId());
+            change.newNode = node;
+            changePrimaryType.node = node;
+            changePrimaryType.applyAndAddChange();
+            change.applyAndAddChange();
             return change.newNode;
         }
     }
 
-    public void doAddNode(Val childName, NodeImpl newNode) {
+    public void doAddNode(Val childName, NodeImpl newNode) throws LockException {
+        checkAccess(PrivilegeImpl.ADD_CHILD_NODES | PrivilegeImpl.LOCK_OK);
         state.addChild(childName, newNode.state.getId());
     }
 
     public NodeImpl addNode(String relPath) throws ItemExistsException, PathNotFoundException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
-        // TODO primaryNodeTypeName is incorrect
-        return addNode(relPath, "");
+        // TODO primaryNodeTypeName may be incorrect
+        return addNode(relPath, NodeState.NT_UNSTRUCTURED);
     }
 
     public PropertyImpl setProperty(String name, String value) throws ValueFormatException, VersionException,
     LockException, ConstraintViolationException, RepositoryException {
-        ChangeSetProperty change = new ChangeSetProperty();
         SessionImpl s = state.getSession();
+        ChangeModifyProperty change = new ChangeModifyProperty(s);
         synchronized (s) {
             change.node = this;
             change.propertyName = Val.get(name);
             change.value = Val.get(value);
-            s.addChange(change);
+            change.applyAndAddChange();
             PropertyImpl prop = new PropertyImpl(this, change.propertyName);
             return prop;
         }
     }
 
-    public void doSetProperty(Val propertyName, Val value) {
+    public void doSetProperty(Val propertyName, Val value) throws LockException {
+        checkAccess(PrivilegeImpl.MODIFY_PROPERTIES | PrivilegeImpl.LOCK_OK);
         state.setPropertyValue(propertyName, value);
     }
 
@@ -135,7 +153,7 @@ public class NodeImpl implements Node {
     public String getPath() throws RepositoryException {
         SessionImpl s = state.getSession();
         synchronized (s) {
-            StringBuilder buff= new StringBuilder();
+            StringBuilder buff = new StringBuilder();
             addPath(buff, this);
             if (buff.length() == 0) {
                 buff.append('/');
@@ -149,7 +167,7 @@ public class NodeImpl implements Node {
             parent.addPath(buff, this);
             buff.append('/');
             Val name = state.getName(parent.state);
-            buff.append(name.getString());
+            buff.append(state.nameToString(name));
         }
     }
 
@@ -178,7 +196,7 @@ public class NodeImpl implements Node {
         if (parent == null) {
             return "/";
         }
-        return state.getName(parent.state).getString();
+        return state.nameToString(state.getName(parent.state));
     }
 
     public boolean hasNode(String relPath) throws RepositoryException {
@@ -189,25 +207,106 @@ public class NodeImpl implements Node {
 
     public void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException,
             RepositoryException {
-        ChangeRemoveNode change = new ChangeRemoveNode();
         SessionImpl s = state.getSession();
+        ChangeRemoveNode change = new ChangeRemoveNode(s);
         if (parent == null) {
             throw new RepositoryException("Can not remove the root node");
         }
         synchronized (s) {
             change.node = this;
-            s.addChange(change);
+            change.applyAndAddChange();
         }
     }
 
-    public void doRemove() {
+    public void doRemove() throws LockException {
+        checkAccess(PrivilegeImpl.REMOVE_NODE | PrivilegeImpl.LOCK_OK);
         Val name = state.getName(parent.state);
         getParentNode().state.removeChild(name);
     }
 
+    public Session getSession() {
+        return state.getSession();
+    }
+
+    private void checkAccess(int privilegeMask) throws LockException {
+        if ((privilegesChecked & privilegeMask) == privilegeMask) {
+            return;
+        }
+        // remove what was already checked
+        privilegeMask &= ~privilegesChecked;
+        if ((privilegeMask & PrivilegeImpl.LOCK_OK) != 0) {
+            checkLocked(true);
+        }
+        privilegesChecked |= privilegeMask;
+    }
+
+    private void checkLocked(boolean thisNode) throws LockException {
+        if ((privilegesChecked & PrivilegeImpl.LOCK_OK) != 0) {
+            return;
+        }
+        if (parent != null) {
+            parent.checkLocked(false);
+        }
+        state.checkLocked(thisNode);
+        if (thisNode) {
+            privilegesChecked |= PrivilegeImpl.LOCK_OK;
+        }
+    }
+
     public void addMixin(String mixinName) throws NoSuchNodeTypeException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
-        // TODO Auto-generated method stub
+        SessionImpl s = state.getSession();
+        ChangeAddMixin change = new ChangeAddMixin(s);
+        change.node = this;
+        change.mixin = Val.get(mixinName);
+        synchronized (s) {
+            change.applyAndAddChange();
+        }
+    }
+
+    public void doAddMixin(Val mixin) throws LockException {
+        checkAccess(PrivilegeImpl.MODIFY_PROPERTIES | PrivilegeImpl.LOCK_OK);
+        Val oldList = state.getPropertyValue(NodeState.PROPERTY_MIXIN_TYPES);
+        Val newList;
+        if (oldList == null) {
+            newList = Val.get(mixin);
+        } else {
+            newList = oldList.addOrdered(mixin);
+        }
+        state.setPropertyValue(NodeState.PROPERTY_MIXIN_TYPES, newList);
+    }
+
+    public LockImpl lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException,
+            LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
+        if (state.session.hasPendingChanges()) {
+            throw new InvalidItemStateException("Session has pending changes");
+        }
+        SessionImpl s = state.getSession();
+        ChangeAddLock change = new ChangeAddLock(s);
+        // TODO the lock token currently is the node id; this is not secure
+        Val lockToken = state.getId();
+        LockImpl lock = new LockImpl(this, lockToken, isDeep, isSessionScoped);
+        change.lock = lock;
+        synchronized (s) {
+            change.applyAndAddChange();
+        }
+        return lock;
+    }
+
+    public void doAddLock(LockImpl lock) throws RepositoryException {
+        checkAccess(PrivilegeImpl.LOCK_MANAGEMENT | PrivilegeImpl.MODIFY_PROPERTIES | PrivilegeImpl.LOCK_OK);
+        // TODO verify it is already locked?
+        state.setLockToken(lock.getInternalLockToken());
+        state.getSession().save();
+    }
+
+    public NodeState getNodeState() {
+        return state;
+    }
+
+    public NodeType getPrimaryNodeType() throws RepositoryException {
+        Val pt = state.getPropertyValue(NodeState.PROPERTY_PRIMARY_TYPE);
+        return state.getSession().getNodeTypeManager().getNodeType(pt);
     }
 
     public boolean canAddMixin(String mixinName) throws NoSuchNodeTypeException, RepositoryException {
@@ -303,11 +402,6 @@ public class NodeImpl implements Node {
         return null;
     }
 
-    public NodeType getPrimaryNodeType() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     public PropertyIterator getProperties() throws RepositoryException {
         // TODO Auto-generated method stub
         return null;
@@ -393,12 +487,6 @@ public class NodeImpl implements Node {
         return false;
     }
 
-    public Lock lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException,
-            LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     public NodeIterator merge(String srcWorkspace, boolean bestEffort) throws NoSuchWorkspaceException,
             AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
         // TODO Auto-generated method stub
@@ -578,11 +666,6 @@ public class NodeImpl implements Node {
         return 0;
     }
 
-    public Session getSession() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     public boolean isModified() {
         // TODO Auto-generated method stub
         return false;

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeIteratorImpl.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeIteratorImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeIteratorImpl.java Sun Mar 28 15:43:18 2010
@@ -19,6 +19,9 @@ package org.apache.jackrabbit.j3;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 
+/**
+ * A node iterator implementation.
+ */
 public class NodeIteratorImpl implements NodeIterator {
 
     public Node nextNode() {

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeState.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeState.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeState.java Sun Mar 28 15:43:18 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.j3;
 
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.lock.LockException;
 import org.apache.jackrabbit.j3.mc.NodeData;
 import org.apache.jackrabbit.j3.mc.Val;
 
@@ -25,9 +27,19 @@ import org.apache.jackrabbit.j3.mc.Val;
  */
 public class NodeState {
 
+    static final Val JCR = Val.get(NamespaceRegistry.NAMESPACE_JCR);
+    static final Val NT = Val.get(NamespaceRegistry.NAMESPACE_NT);
+    static final Val PROPERTY_MIXIN_TYPES = Val.get(JCR, Val.get("mixinTypes"));
+    static final Val PROPERTY_LOCK_IS_DEEP = Val.get(JCR, Val.get("lockIsDeep"));
+    static final Val PROPERTY_LOCK_OWNER = Val.get(JCR, Val.get("lockOwner"));
+    static final Val PROPERTY_PRIMARY_TYPE = Val.get(JCR, Val.get("primaryType"));
+    static final Val NT_UNSTRUCTURED = Val.get(NT, Val.get("unstructured"));
+    static final Val DEFAULT_PRIMARY_TYPE = NT_UNSTRUCTURED;
+
     final SessionImpl session;
     private NodeData data;
     private boolean modified;
+    private SessionImpl lockOwner;
 
     NodeState(SessionImpl session, NodeData data, boolean modified) {
         this.session = session;
@@ -37,7 +49,7 @@ public class NodeState {
 
     void modify() {
         if (!modified) {
-            data = data.clone();
+            data = data.createCopy();
             session.modify(this);
             modified = true;
         }
@@ -50,10 +62,22 @@ public class NodeState {
 
     void setPropertyValue(Val name, Val value) {
         modify();
-        data.setPropertyValue(name, value);
+        if (name.equals(NodeState.PROPERTY_PRIMARY_TYPE)) {
+            if (value.equals(DEFAULT_PRIMARY_TYPE)) {
+                data.setPrimaryType(null);
+            } else {
+                data.setPrimaryType(value);
+            }
+        } else {
+            data.setPropertyValue(name, value);
+        }
     }
 
     Val getPropertyValue(Val name) {
+        if (name.equals(NodeState.PROPERTY_PRIMARY_TYPE)) {
+            Val pt = data.getPrimaryType();
+            return pt == null ? DEFAULT_PRIMARY_TYPE : pt;
+        }
         return data.getPropertyValue(name);
     }
 
@@ -75,10 +99,19 @@ public class NodeState {
         data.removeChild(childName);
     }
 
+    void setLockToken(Val lockToken) {
+        modify();
+        data.setLockToken(lockToken);
+    }
+
     Val getName(NodeState parent) {
         return data.getName(parent.data);
     }
 
+    String nameToString(Val name) {
+        return session.nameToString(name);
+    }
+
     public String toString() {
         return (modified ? "(mod) " : "") + data;
     }
@@ -91,4 +124,26 @@ public class NodeState {
         return session.getStorageSession().convertNodeIdToIdentifier(data.getId());
     }
 
+    void checkLocked(boolean thisNode) throws LockException {
+        // in most cases, the node is not locked
+        Val lockToken = data.getLockToken();
+        if (lockToken == null) {
+            return;
+        }
+        if (lockOwner == session) {
+            return;
+        }
+        if (!thisNode) {
+            // when checking parent nodes, non-deep locks have no affect
+            Val isDeep = data.getPropertyValue(PROPERTY_LOCK_IS_DEEP);
+            if (isDeep == null || isDeep == Val.FALSE) {
+                return;
+            }
+        }
+        if (session.getLockManager().hasLockToken(lockToken)) {
+            lockOwner = session;
+        }
+        throw new LockException("Node is locked");
+    }
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyImpl.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyImpl.java Sun Mar 28 15:43:18 2010
@@ -40,6 +40,9 @@ import javax.jcr.nodetype.NoSuchNodeType
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.version.VersionException;
 
+/**
+ * The property implementation.
+ */
 public class PropertyImpl implements Property {
 
     private final NodeImpl node;

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryFactoryImpl.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryFactoryImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryFactoryImpl.java Sun Mar 28 15:43:18 2010
@@ -21,6 +21,9 @@ import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.RepositoryFactory;
 
+/**
+ * The repository factory implementation.
+ */
 public class RepositoryFactoryImpl implements RepositoryFactory {
 
     @SuppressWarnings("unchecked")

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryImpl.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryImpl.java Sun Mar 28 15:43:18 2010
@@ -16,37 +16,50 @@
  */
 package org.apache.jackrabbit.j3;
 
-import org.apache.jackrabbit.j3.mc.McException;
-import org.apache.jackrabbit.j3.mc.Val;
-import org.apache.jackrabbit.j3.mc.NodeData;
-import org.apache.jackrabbit.j3.mc.Storage;
-import org.apache.jackrabbit.j3.mc.StorageSession;
-import org.apache.jackrabbit.j3.mc.jdbc.JdbcStorage;
-import org.apache.jackrabbit.j3.mc.mem.MemStorage;
-import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.TreeSet;
 import javax.jcr.Credentials;
 import javax.jcr.LoginException;
 import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.PropertyType;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
+import org.apache.jackrabbit.j3.lock.LockSystem;
+import org.apache.jackrabbit.j3.mc.McException;
+import org.apache.jackrabbit.j3.mc.NodeData;
+import org.apache.jackrabbit.j3.mc.Storage;
+import org.apache.jackrabbit.j3.mc.StorageSession;
+import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.mc.jdbc.JdbcStorage;
+import org.apache.jackrabbit.j3.mc.mem.MemStorage;
 
+/**
+ * The repository implementation.
+ */
 public class RepositoryImpl implements Repository {
 
-    private final static int CACHE_SIZE = 1000;
-    private final static SimpleCredentials ANONYMOUS_CREDENTIALS = new SimpleCredentials("", new char[0]);
+    private static final int CACHE_SIZE = 1000;
+    private static final SimpleCredentials ANONYMOUS_CREDENTIALS = new SimpleCredentials("", new char[0]);
 
+    private final String url;
     private final Storage storage;
-    private final Collection<SessionImpl> sessions = new HashSet<SessionImpl>();
+    private final HashSet<SessionImpl> sessions = new HashSet<SessionImpl>();
     private final Cache<Val, NodeData> readOnlyCache = new Cache<Val, NodeData>(CACHE_SIZE);
     private boolean closed;
 
+    private final HashMap<String, ValueImpl> descriptors = new HashMap<String, ValueImpl>();
+    private static final HashMap<String, Object> STANDARD_DESCRIPTORS = new HashMap<String, Object>();
+
+    private final ValueFactoryImpl valFactory = new ValueFactoryImpl();
+    private LockSystem lockSystem;
+
     public RepositoryImpl(Map<String, String> parameters) {
-        String url = parameters.get("url");
+        this.url = parameters.get("url");
         if (url.startsWith("jdbc:")) {
             storage = new JdbcStorage(url);
         } else if (url.startsWith("mem:")) {
@@ -54,9 +67,12 @@ public class RepositoryImpl implements R
         } else {
             throw new McException("Unsupported url: " + url);
         }
+        descriptors.put("url", valFactory.createValue(url));
     }
 
-    public synchronized Session login(Credentials credentials) throws LoginException, RepositoryException {
+    public synchronized Session login(Credentials credentials, String workspaceName) throws LoginException,
+            NoSuchWorkspaceException, RepositoryException {
+        // TODO workspaceName is ignored
         checkClosed();
         if (credentials == null) {
             credentials = ANONYMOUS_CREDENTIALS;
@@ -87,55 +103,167 @@ public class RepositoryImpl implements R
         readOnlyCache.put(data.getId(), data);
     }
 
-    public Session login() throws LoginException, RepositoryException {
-        return login(null, null);
+    public ValueImpl getDescriptorValue(String key) {
+        Object o = getDescriptorObject(key);
+        if (o == null || o instanceof Value[]) {
+            return null;
+        }
+        return (ValueImpl) o;
     }
 
-    public String getDescriptor(String key) {
-        // TODO Auto-generated method stub
-        return null;
+    public Value[] getDescriptorValues(String key) {
+        Object o = getDescriptorObject(key);
+        if (o == null) {
+            return null;
+        } else if (o instanceof Value[]) {
+            return (Value[]) o;
+        }
+        return new Value[] { (Value) o };
     }
 
-    private void checkClosed() throws RepositoryException {
-        if (closed) {
-            throw ExceptionFactory.get(ExceptionFactory.CLOSED_0);
+    public boolean isSingleValueDescriptor(String key) {
+        Object o = getDescriptorObject(key);
+        return o != null && o instanceof Value;
+    }
+
+    public synchronized String getDescriptor(String key) {
+        ValueImpl v = getDescriptorValue(key);
+        return v == null ? null : v.getString();
+    }
+
+    public synchronized String[] getDescriptorKeys() {
+        TreeSet<String> set = new TreeSet<String>();
+        initStandardDescriptors(valFactory);
+        set.addAll(STANDARD_DESCRIPTORS.keySet());
+        set.addAll(descriptors.keySet());
+        String[] keys = set.toArray(new String[set.size()]);
+        return keys;
+    }
+
+    private synchronized Object getDescriptorObject(String key) {
+        Object o = descriptors.get(key);
+        if (o == null) {
+            initStandardDescriptors(valFactory);
+            o = STANDARD_DESCRIPTORS.get(key);
         }
+        return o;
     }
 
-    public String[] getDescriptorKeys() {
-        // TODO Auto-generated method stub
-        return null;
+    public synchronized boolean isStandardDescriptor(String key) {
+        initStandardDescriptors(valFactory);
+        return STANDARD_DESCRIPTORS.containsKey(key);
     }
 
-    public Value getDescriptorValue(String key) {
-        // TODO Auto-generated method stub
-        return null;
+    private void checkClosed() throws RepositoryException {
+        if (closed) {
+            throw ExceptionFactory.get(ExceptionFactory.CLOSED_0);
+        }
     }
 
-    public Value[] getDescriptorValues(String key) {
-        // TODO Auto-generated method stub
-        return null;
+    public synchronized Session login() throws RepositoryException {
+        return login(null, null);
     }
 
-    public boolean isSingleValueDescriptor(String key) {
-        // TODO Auto-generated method stub
-        return false;
+    public synchronized Session login(Credentials credentials) throws RepositoryException {
+        return login(credentials, null);
     }
 
-    public boolean isStandardDescriptor(String key) {
-        // TODO Auto-generated method stub
-        return false;
+    public synchronized Session login(String workspace) throws RepositoryException {
+        return login(null, workspace);
     }
 
-    public Session login(String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    @SuppressWarnings("deprecation")
+    private static synchronized void initStandardDescriptors(ValueFactoryImpl valFactory) {
+        HashMap<String, Object> desc = STANDARD_DESCRIPTORS;
+        if (desc.size() > 0) {
+            return;
+        }
+        ValueImpl valTrue = valFactory.createValue(true), valFalse = valFactory.createValue(false);
+        desc.put(IDENTIFIER_STABILITY, valFactory.createValue(IDENTIFIER_STABILITY_INDEFINITE_DURATION));
+        desc.put(LEVEL_1_SUPPORTED, valTrue);
+        desc.put(LEVEL_2_SUPPORTED, valTrue);
+        desc.put(NODE_TYPE_MANAGEMENT_AUTOCREATED_DEFINITIONS_SUPPORTED, valTrue);
+        desc.put(NODE_TYPE_MANAGEMENT_INHERITANCE, valFactory.createValue(NODE_TYPE_MANAGEMENT_INHERITANCE_MULTIPLE));
+        desc.put(NODE_TYPE_MANAGEMENT_MULTIPLE_BINARY_PROPERTIES_SUPPORTED, valTrue);
+        desc.put(NODE_TYPE_MANAGEMENT_MULTIVALUED_PROPERTIES_SUPPORTED, valTrue);
+        desc.put(NODE_TYPE_MANAGEMENT_ORDERABLE_CHILD_NODES_SUPPORTED, valTrue);
+        desc.put(NODE_TYPE_MANAGEMENT_OVERRIDES_SUPPORTED, valFalse);
+        desc.put(NODE_TYPE_MANAGEMENT_PRIMARY_ITEM_NAME_SUPPORTED, valTrue);
+        ValueImpl[] types = {
+                valFactory.createValue(PropertyType.STRING),
+                valFactory.createValue(PropertyType.BINARY),
+                valFactory.createValue(PropertyType.LONG),
+                valFactory.createValue(PropertyType.DOUBLE),
+                valFactory.createValue(PropertyType.DECIMAL),
+                valFactory.createValue(PropertyType.DATE),
+                valFactory.createValue(PropertyType.BOOLEAN),
+                valFactory.createValue(PropertyType.NAME),
+                valFactory.createValue(PropertyType.PATH),
+                valFactory.createValue(PropertyType.REFERENCE),
+                valFactory.createValue(PropertyType.WEAKREFERENCE),
+                valFactory.createValue(PropertyType.URI),
+                valFactory.createValue(PropertyType.UNDEFINED)
+        };
+        desc.put(NODE_TYPE_MANAGEMENT_PROPERTY_TYPES, types);
+        desc.put(NODE_TYPE_MANAGEMENT_RESIDUAL_DEFINITIONS_SUPPORTED, valTrue);
+        desc.put(NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED, valTrue);
+        desc.put(NODE_TYPE_MANAGEMENT_UPDATE_IN_USE_SUPORTED, valFalse);
+        desc.put(NODE_TYPE_MANAGEMENT_VALUE_CONSTRAINTS_SUPPORTED, valTrue);
+        desc.put(OPTION_ACCESS_CONTROL_SUPPORTED, valTrue);
+        desc.put(OPTION_ACTIVITIES_SUPPORTED, valTrue);
+        desc.put(OPTION_BASELINES_SUPPORTED, valTrue);
+        desc.put(OPTION_JOURNALED_OBSERVATION_SUPPORTED, valTrue);
+        desc.put(OPTION_LIFECYCLE_SUPPORTED, valTrue);
+        desc.put(OPTION_LOCKING_SUPPORTED, valTrue);
+        desc.put(OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED, valTrue);
+        desc.put(OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED, valTrue);
+        desc.put(OPTION_OBSERVATION_SUPPORTED, valTrue);
+        desc.put(OPTION_QUERY_SQL_SUPPORTED, valTrue);
+        desc.put(OPTION_RETENTION_SUPPORTED, valTrue);
+        desc.put(OPTION_SHAREABLE_NODES_SUPPORTED, valTrue);
+        desc.put(OPTION_SIMPLE_VERSIONING_SUPPORTED, valTrue);
+        desc.put(OPTION_TRANSACTIONS_SUPPORTED, valTrue);
+        desc.put(OPTION_UNFILED_CONTENT_SUPPORTED, valFalse);
+        desc.put(OPTION_UPDATE_MIXIN_NODE_TYPES_SUPPORTED, valTrue);
+        desc.put(OPTION_UPDATE_PRIMARY_NODE_TYPE_SUPPORTED, valTrue);
+        desc.put(OPTION_VERSIONING_SUPPORTED, valTrue);
+        desc.put(OPTION_WORKSPACE_MANAGEMENT_SUPPORTED, valTrue);
+        desc.put(OPTION_XML_EXPORT_SUPPORTED, valTrue);
+        desc.put(OPTION_XML_IMPORT_SUPPORTED, valTrue);
+        desc.put(QUERY_FULL_TEXT_SEARCH_SUPPORTED, valTrue);
+        desc.put(QUERY_JOINS, valFactory.createValue(QUERY_JOINS_INNER_OUTER));
+        ValueImpl[] languages = {
+                valFactory.createValue("javax.jcr.query.JCR-JQOM"),
+                valFactory.createValue("javax.jcr.query.JCR-SQL2")
+        };
+        desc.put(QUERY_LANGUAGES, languages);
+        desc.put(QUERY_STORED_QUERIES_SUPPORTED, valTrue);
+        desc.put(QUERY_XPATH_DOC_ORDER, valFalse);
+        desc.put(QUERY_XPATH_POS_INDEX, valTrue);
+        desc.put(REP_NAME_DESC, valFactory.createValue("Jackrabbit J3"));
+        desc.put(REP_VENDOR_DESC, valFactory.createValue("Apache Software Foundation"));
+        desc.put(REP_VENDOR_URL_DESC, valFactory.createValue("http://jackrabbit.apache.org/"));
+        desc.put(REP_VERSION_DESC, valFactory.createValue("3.0"));
+        desc.put(SPEC_NAME_DESC, valFactory.createValue("Content Repository API for Java(TM) Technology Specification"));
+        desc.put(SPEC_VERSION_DESC, valFactory.createValue("2.0"));
+        desc.put(WRITE_SUPPORTED, valTrue);
+    }
+
+    public String toString() {
+        return "RepositoryImpl:" + url + " cache: " + readOnlyCache.size();
+    }
+
+    public synchronized LockSystem getLockSystem() {
+        if (lockSystem == null) {
+            lockSystem = new LockSystem(this);
+        }
+        return lockSystem;
     }
 
-    public Session login(Credentials credentials, String workspaceName) throws LoginException,
-            NoSuchWorkspaceException, RepositoryException {
-        return login(credentials);
-        // TODO
+    public synchronized void dispatchEvents(ChangeList changeList) {
+        for (SessionImpl session : sessions) {
+            session.dispatchEvents(changeList);
+        }
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/SessionImpl.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/SessionImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/SessionImpl.java Sun Mar 28 15:43:18 2010
@@ -19,10 +19,10 @@ package org.apache.jackrabbit.j3;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.ref.WeakReference;
 import java.security.AccessControlException;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.WeakHashMap;
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Credentials;
@@ -37,33 +37,43 @@ import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
 import javax.jcr.ReferentialIntegrityException;
-import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.ValueFactory;
-import javax.jcr.Workspace;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.retention.RetentionManager;
 import javax.jcr.security.AccessControlManager;
 import javax.jcr.version.VersionException;
+import org.apache.jackrabbit.j3.lock.LockManagerImpl;
 import org.apache.jackrabbit.j3.mc.McException;
 import org.apache.jackrabbit.j3.mc.NodeData;
 import org.apache.jackrabbit.j3.mc.StorageSession;
 import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.j3.observation.ObservationManagerImpl;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
+/**
+ * The session implementation.
+ */
 public class SessionImpl implements Session {
 
-    private final static int MAX_RETRY = 3;
+    private static final int MAX_RETRY = 3;
     private final RepositoryImpl rep;
     private final StorageSession storageSession;
-    private final WeakHashMap<Val, NodeState> weakMap = new WeakHashMap<Val, NodeState>();
+    private final WeakHashMap<Val, WeakReference<NodeState>> weakMap = new WeakHashMap<Val, WeakReference<NodeState>>();
     private final HashMap<Val, NodeState> modified = new HashMap<Val, NodeState>();
-    private final LinkedList<Change> changes = new LinkedList<Change>();
+    private final NamespaceRegistryImpl namespaceRegistry = NamespaceRegistryImpl.createLocalInstance();
+    private ChangeList changeList = new ChangeList(this);
+    private LockManagerImpl lockManager;
+    private ObservationManagerImpl observationManager;
+    private NodeTypeManagerImpl nodeTypeManager;
+    private WorkspaceImpl workspace;
+    private String observationUserData;
 
     public SessionImpl(RepositoryImpl rep, StorageSession storageSession) {
         this.rep = rep;
@@ -78,7 +88,8 @@ public class SessionImpl implements Sess
     NodeImpl getNode(NodeImpl parent, Val nodeId) throws RepositoryException {
         NodeState state = modified.get(nodeId);
         if (state == null) {
-            state = weakMap.get(nodeId);
+            WeakReference<NodeState> ref = weakMap.get(nodeId);
+            state = ref == null ? null : ref.get();
         }
         if (state == null) {
             NodeData data = getPersistedNodeData(nodeId);
@@ -86,6 +97,7 @@ public class SessionImpl implements Sess
                 throw new RepositoryException("Node not found: " + nodeId);
             }
             state = new NodeState(this, data, false);
+            cacheNodeState(state);
         }
         if (parent == null) {
             Val parentNodeId = state.getNodeData().getPrimaryParentId();
@@ -117,21 +129,26 @@ public class SessionImpl implements Sess
         NodeData newData = new NodeData(nodeId, parentId, 0);
         NodeState state = new NodeState(this, newData, true);
         modify(state);
-        weakMap.put(nodeId, state);
+        cacheNodeState(state);
         NodeImpl newNode = new NodeImpl(parent, state);
         return newNode;
     }
 
+    private void cacheNodeState(NodeState state) {
+        Val nodeId = state.getId();
+        weakMap.put(nodeId, new WeakReference<NodeState>(state));
+    }
+
     synchronized void modify(NodeState state) {
         modified.put(state.getId(), state);
     }
 
     public synchronized void save() throws AccessDeniedException, ItemExistsException, ReferentialIntegrityException,
-    ConstraintViolationException, InvalidItemStateException, VersionException, LockException,
-    NoSuchNodeTypeException, RepositoryException {
-        for(int i=0; i<MAX_RETRY; i++) {
+            ConstraintViolationException, InvalidItemStateException, VersionException, LockException,
+            NoSuchNodeTypeException, RepositoryException {
+        for (int i = 0; i < MAX_RETRY; i++) {
             try {
-               trySave();
+                trySave();
                return;
             } catch (McException e) {
                 // concurrent update
@@ -144,7 +161,7 @@ public class SessionImpl implements Sess
     private void trySave() {
         NodeData[] changed = new NodeData[modified.size()];
         Iterator<NodeState> it = modified.values().iterator();
-        for (int i=0; i<modified.size(); i++) {
+        for (int i = 0; i < modified.size(); i++) {
             NodeState s = it.next();
             changed[i] = s.getNodeData();
         }
@@ -152,7 +169,14 @@ public class SessionImpl implements Sess
         for (NodeData n : changed) {
             rep.cacheNodeData(n);
         }
+        it = modified.values().iterator();
+        for (int i = 0; i < modified.size(); i++) {
+            NodeState s = it.next();
+            s.reset(s.getNodeData());
+        }
         modified.clear();
+        changeList.persisted();
+        changeList = new ChangeList(this);
     }
 
     public synchronized Node getNodeByIdentifier(String id) throws ItemNotFoundException, RepositoryException {
@@ -164,32 +188,27 @@ public class SessionImpl implements Sess
         return storageSession;
     }
 
-    void addChange(Change change) {
-        change.apply(this);
-        changes.add(change);
-    }
-
     public synchronized void refresh(boolean keepChanges) throws RepositoryException {
         Iterator<NodeState> it = modified.values().iterator();
-        for (int i=0; i<modified.size(); i++) {
+        for (int i = 0; i < modified.size(); i++) {
             NodeState s = it.next();
             NodeData data = getPersistedNodeData(s.getId());
             s.reset(data);
         }
         if (keepChanges) {
-            for (Change c : changes) {
-                c.apply(this);
-            }
+            changeList.apply();
+        } else {
+            changeList = new ChangeList(this);
         }
     }
 
-    public Node getNode(String absPath) throws PathNotFoundException, RepositoryException {
+    public NodeImpl getNode(String absPath) throws PathNotFoundException, RepositoryException {
         if (!absPath.startsWith("/")) {
             throw new RepositoryException("Path does not start with /:" + absPath);
         }
         int last = 1;
-        NodeImpl current = getNode(null, storageSession.getRootNodeId());;
-        for (int i=1; i<absPath.length(); i++) {
+        NodeImpl current = getNode(null, storageSession.getRootNodeId());
+        for (int i = 1; i < absPath.length(); i++) {
             char c = absPath.charAt(i);
             if (c == '/') {
                 String s = absPath.substring(last, i);
@@ -202,6 +221,106 @@ public class SessionImpl implements Sess
         return current;
     }
 
+    public RepositoryImpl getRepository() {
+        return rep;
+    }
+
+    public synchronized WorkspaceImpl getWorkspace() {
+        if (workspace == null) {
+            workspace = new WorkspaceImpl(this);
+        }
+        return workspace;
+    }
+
+    public synchronized LockManagerImpl getLockManager() {
+        if (lockManager == null) {
+            lockManager = new LockManagerImpl(this, rep.getLockSystem());
+        }
+        return lockManager;
+    }
+
+    public synchronized boolean hasPendingChanges() throws RepositoryException {
+        return modified.size() > 0;
+    }
+
+    public synchronized ObservationManagerImpl getObservationManager() {
+        if (observationManager == null) {
+            observationManager = new ObservationManagerImpl(this);
+        }
+        return observationManager;
+    }
+
+    public synchronized NodeTypeManagerImpl getNodeTypeManager() {
+        if (nodeTypeManager == null) {
+            nodeTypeManager = new NodeTypeManagerImpl(this);
+        }
+        return nodeTypeManager;
+    }
+
+    public void dispatchEvents(ChangeList events) {
+        if (observationManager == null) {
+            return;
+        }
+        observationManager.dispatchEvents(events);
+    }
+
+    public NamespaceRegistryImpl getNamespaceRegistry() {
+        return namespaceRegistry;
+    }
+
+    public void setObservationUserData(String userData) {
+        this.observationUserData = userData;
+    }
+
+    public String getObservationUserData() {
+        return observationUserData;
+    }
+
+    public ChangeList getChangeList() {
+        return changeList;
+    }
+
+    public String getNamespacePrefix(String uri) throws NamespaceException, RepositoryException {
+        return namespaceRegistry.getPrefix(uri);
+    }
+
+    public String[] getNamespacePrefixes() throws RepositoryException {
+        return namespaceRegistry.getPrefixes();
+    }
+
+    public String getNamespaceURI(String prefix) throws NamespaceException, RepositoryException {
+        return namespaceRegistry.getURI(prefix);
+    }
+
+    public String nameToString(Val name) {
+        if (name.getType() == Val.TYPE_MULTI_VALUE) {
+            Val[] namePair = name.getArray();
+            String uri = namespaceRegistry.getPrefix(namePair[0].getString());
+            String localName = namePair[1].getString();
+            StringBuilder buff = new StringBuilder(uri.length() + 1 + localName.length());
+            buff.append(uri).append(':').append(localName);
+            return buff.toString();
+        }
+        return name.getString();
+    }
+
+    public Val parseName(String name) {
+        if (name.indexOf(0) == '{') {
+            int index = name.indexOf('}');
+            Val namespace = Val.get(name.substring(1, index));
+            Val localName = Val.get(name.substring(index + 1));
+            return Val.get(namespace, localName);
+        }
+        int index = name.indexOf(':');
+        if (index < 0) {
+            return Val.get(name);
+        }
+        String prefix = name.substring(0, index);
+        Val namespace = Val.get(namespaceRegistry.getURI(prefix));
+        Val localName = Val.get(name.substring(index + 1));
+        return Val.get(namespace, localName);
+    }
+
     public void addLockToken(String lt) {
         // TODO Auto-generated method stub
 
@@ -268,21 +387,6 @@ public class SessionImpl implements Sess
         return null;
     }
 
-    public String getNamespacePrefix(String uri) throws NamespaceException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public String[] getNamespacePrefixes() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public String getNamespaceURI(String prefix) throws NamespaceException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     public Node getNodeByUUID(String uuid) throws ItemNotFoundException, RepositoryException {
         // TODO Auto-generated method stub
         return null;
@@ -293,11 +397,6 @@ public class SessionImpl implements Sess
         return null;
     }
 
-    public Repository getRepository() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     public RetentionManager getRetentionManager() throws UnsupportedRepositoryOperationException, RepositoryException {
         // TODO Auto-generated method stub
         return null;
@@ -313,21 +412,11 @@ public class SessionImpl implements Sess
         return null;
     }
 
-    public Workspace getWorkspace() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     public boolean hasCapability(String methodName, Object target, Object[] arguments) throws RepositoryException {
         // TODO Auto-generated method stub
         return false;
     }
 
-    public boolean hasPendingChanges() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
     public boolean hasPermission(String absPath, String actions) throws RepositoryException {
         // TODO Auto-generated method stub
         return false;
@@ -387,4 +476,8 @@ public class SessionImpl implements Sess
 
     }
 
+    public String toString() {
+        return rep + " changes: " + changeList + " modified nodes: " + modified.size() + " weak map: " + weakMap.size();
+    }
+
 }

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueFactoryImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueFactoryImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueFactoryImpl.java Sun Mar 28 15:43:18 2010
@@ -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.j3;
+
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.Calendar;
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.ValueFormatException;
+import org.apache.jackrabbit.j3.mc.Val;
+
+/**
+ * The value factory implementation.
+ */
+public class ValueFactoryImpl implements ValueFactory {
+
+    public Binary createBinary(InputStream stream) throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public ValueImpl createValue(String value) {
+        return new ValueImpl(Val.get(value));
+    }
+
+    public ValueImpl createValue(long value) {
+        return new ValueImpl(Val.get(value));
+    }
+
+    public ValueImpl createValue(double value) {
+        return new ValueImpl(Val.get(value));
+    }
+
+    public ValueImpl createValue(BigDecimal value) {
+        return new ValueImpl(Val.get(PropertyType.DECIMAL, value.toString()));
+    }
+
+    public ValueImpl createValue(boolean value) {
+        return new ValueImpl(value ? Val.TRUE : Val.FALSE);
+    }
+
+    public Value createValue(Calendar value) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Value createValue(InputStream value) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Value createValue(Binary value) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Value createValue(Node value) throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Value createValue(String value, int type) throws ValueFormatException {
+        return new ValueImpl(Val.get(type, value));
+    }
+
+    public Value createValue(Node value, boolean weak) throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueImpl.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueImpl.java Sun Mar 28 15:43:18 2010
@@ -25,6 +25,9 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
 
+/**
+ * The value implementation.
+ */
 public class ValueImpl implements Value {
 
     private final Val value;
@@ -33,7 +36,7 @@ public class ValueImpl implements Value 
         this.value = value;
     }
 
-    public String getString() throws ValueFormatException, IllegalStateException, RepositoryException {
+    public String getString() {
         return value.getString();
     }
 

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/WorkspaceImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/WorkspaceImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/WorkspaceImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,159 @@
+/*
+ * 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.j3;
+
+import java.io.IOException;
+import java.io.InputStream;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Workspace;
+import javax.jcr.lock.LockException;
+import javax.jcr.lock.LockManager;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.QueryManager;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionManager;
+import org.xml.sax.ContentHandler;
+
+/**
+ * A workspace implementation.
+ */
+public class WorkspaceImpl implements Workspace {
+
+    private final SessionImpl session;
+
+    WorkspaceImpl(SessionImpl session) {
+        this.session = session;
+    }
+
+    public LockManager getLockManager() throws UnsupportedRepositoryOperationException, RepositoryException {
+        return session.getLockManager();
+    }
+
+    public Session getSession() {
+        return session;
+    }
+
+    public ObservationManager getObservationManager() throws UnsupportedRepositoryOperationException,
+            RepositoryException {
+        return session.getObservationManager();
+    }
+
+    public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
+        return session.getNamespaceRegistry();
+    }
+
+    public String getName() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void clone(String srcWorkspace, String srcAbsPath, String destAbsPath, boolean removeExisting)
+            throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException,
+            PathNotFoundException, ItemExistsException, LockException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void copy(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException,
+            AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath) throws NoSuchWorkspaceException,
+            ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException,
+            ItemExistsException, LockException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void createWorkspace(String name) throws AccessDeniedException, UnsupportedRepositoryOperationException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void createWorkspace(String name, String srcWorkspace) throws AccessDeniedException,
+            UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void deleteWorkspace(String name) throws AccessDeniedException, UnsupportedRepositoryOperationException,
+            NoSuchWorkspaceException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public String[] getAccessibleWorkspaceNames() throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException,
+            ConstraintViolationException, VersionException, LockException, AccessDeniedException, RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeTypeManager getNodeTypeManager() {
+        return session.getNodeTypeManager();
+    }
+
+    public QueryManager getQueryManager() throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public VersionManager getVersionManager() throws UnsupportedRepositoryOperationException, RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, VersionException,
+            PathNotFoundException, ItemExistsException, ConstraintViolationException, InvalidSerializedDataException,
+            LockException, AccessDeniedException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void move(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException,
+            AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void restore(Version[] versions, boolean removeExisting) throws ItemExistsException,
+            UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,88 @@
+/*
+ * 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.j3.lock;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+import org.apache.jackrabbit.j3.NodeImpl;
+import org.apache.jackrabbit.j3.mc.Val;
+
+/**
+ * A lock implementation.
+ */
+public class LockImpl implements Lock {
+
+    private final NodeImpl node;
+    private final Val lockToken;
+    private final boolean isDeep;
+    private final boolean isSessionScoped;
+
+    public LockImpl(NodeImpl node, Val lockToken, boolean isDeep, boolean isSessionScoped) {
+        this.node = node;
+        this.lockToken = lockToken;
+        this.isDeep = isDeep;
+        this.isSessionScoped = isSessionScoped;
+    }
+
+    public boolean isDeep() {
+        return isDeep;
+    }
+
+    public boolean isSessionScoped() {
+        return isSessionScoped;
+    }
+
+    public NodeImpl getNode() {
+        return node;
+    }
+
+    public Val getInternalLockToken() {
+        return lockToken;
+    }
+
+    public String getLockOwner() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getLockToken() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public long getSecondsRemaining() throws RepositoryException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public boolean isLive() throws RepositoryException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean isLockOwningSession() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void refresh() throws LockException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+}



Mime
View raw message