jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r928437 [2/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
Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockManagerImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockManagerImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockManagerImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,96 @@
+/*
+ * 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 java.util.HashSet;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+import javax.jcr.lock.LockManager;
+import org.apache.jackrabbit.j3.NodeImpl;
+import org.apache.jackrabbit.j3.SessionImpl;
+import org.apache.jackrabbit.j3.mc.Val;
+
+/**
+ * A lock manager implementation.
+ */
+public class LockManagerImpl implements LockManager {
+
+    private final LockSystem lockSystem;
+    private final SessionImpl session;
+    private HashSet<Val> lockTokens = new HashSet<Val>();
+
+    public LockManagerImpl(SessionImpl session, LockSystem lockSystem) {
+        this.session = session;
+        this.lockSystem = lockSystem;
+    }
+
+    public boolean hasLockToken(Val lockToken) {
+        return lockTokens.contains(lockToken);
+    }
+
+    public Lock lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
+            throws LockException, PathNotFoundException, AccessDeniedException, InvalidItemStateException,
+            RepositoryException {
+        NodeImpl node = session.getNode(absPath);
+        LockImpl lock = node.lock(isDeep, isSessionScoped);
+        lockTokens.add(lock.getInternalLockToken());
+        return lock;
+    }
+
+    public void addLockToken(String lockToken) throws LockException, RepositoryException {
+        synchronized (session) {
+            lockTokens.add(Val.get(lockToken));
+        }
+    }
+
+    public Lock getLock(String absPath) throws PathNotFoundException, LockException, AccessDeniedException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String[] getLockTokens() throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean holdsLock(String absPath) throws PathNotFoundException, RepositoryException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean isLocked(String absPath) throws PathNotFoundException, RepositoryException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void removeLockToken(String lockToken) throws LockException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void unlock(String absPath) throws PathNotFoundException, LockException, AccessDeniedException,
+            InvalidItemStateException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockSystem.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockSystem.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockSystem.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.Repository;
+
+/**
+ * A lock system. It is only used if there are any locks used.
+ */
+public class LockSystem {
+
+    // Actually, maybe it's not required at all.
+
+    private final Repository rep;
+
+    public LockSystem(Repository rep) {
+        this.rep = rep;
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java Sun Mar 28 15:43:18 2010
@@ -18,16 +18,20 @@ package org.apache.jackrabbit.j3.mc;
 
 import javax.jcr.PropertyType;
 
+/**
+ * A byte buffer that contains serialized data.
+ */
 public class Bundle {
 
     // types 0 (PropertyType.UNDEFINED) - 12 (PropertyType.DECIMAL) are used
 
-    private static final int BACK_POINTER = 42;
-    private static final int MULTI_VALUE = 43;
-    private static final int BINARY_REFERENCE = 44;
-    private static final int BOOLEAN_FALSE = 45;
-    private static final int BOOLEAN_TRUE = 46;
-    private static final int LONG_NEGATIVE = 47;
+    private static final int BACK_POINTER = 38;
+    private static final int MULTI_VALUE = 39;
+    private static final int BINARY_REFERENCE = 40;
+    private static final int BOOLEAN_FALSE = 41;
+    private static final int BOOLEAN_TRUE = 42;
+    private static final int LONG_NEGATIVE = 43;
+    private static final int MULTI_VALUE_LEN_0_3 = 44;
     private static final int STRING_LEN_0_15 = 48;
     private static final int INDEXED = 64;
 
@@ -233,8 +237,13 @@ public class Bundle {
         int type = v.getType();
         switch (type) {
         case Val.TYPE_MULTI_VALUE: {
-            writeByte((byte) MULTI_VALUE);
-            writeVarInt(v.getArray().length);
+            int len = v.getArray().length;
+            if (len < 4) {
+                writeByte((byte) (MULTI_VALUE_LEN_0_3 + len));
+            } else {
+                writeByte((byte) MULTI_VALUE);
+                writeVarInt(len);
+            }
             for (Val x : v.getArray()) {
                 writeVal(x);
             }
@@ -334,7 +343,12 @@ public class Bundle {
         switch (type) {
         case Val.TYPE_MULTI_VALUE: {
             Val[] array = v.getArray();
-            int len = 1 + getVarLongLen(array.length);
+            int len = array.length;
+            if (len < 4) {
+                len = 1;
+            } else {
+                len = 1 + getVarLongLen(len);
+            }
             for (Val x : array) {
                 len += getValLen(x);
             }
@@ -405,8 +419,8 @@ public class Bundle {
         }
         case MULTI_VALUE: {
             int len = readVarInt();
-            Val array[] = new Val[len];
-            for (int i=0; i<len; i++) {
+            Val[] array = new Val[len];
+            for (int i = 0; i < len; i++) {
                 array[i] = readVal();
             }
             return Val.get(array);
@@ -442,6 +456,12 @@ public class Bundle {
         default:
             if (type >= STRING_LEN_0_15 && type < STRING_LEN_0_15 + 16) {
                 return Val.get(readString(type - STRING_LEN_0_15));
+            } else if (type >= MULTI_VALUE_LEN_0_3 && type < MULTI_VALUE_LEN_0_3 + 4) {
+                Val[] array = new Val[type - MULTI_VALUE_LEN_0_3];
+                for (int i = 0; i < array.length; i++) {
+                    array[i] = readVal();
+                }
+                return Val.get(array);
             }
             throw new IllegalArgumentException("type:" + type);
         }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/McException.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/McException.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/McException.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/McException.java Sun Mar 28 15:43:18 2010
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.j3.mc;
 
+/**
+ * A runtime exception.
+ */
 public class McException extends RuntimeException {
 
     public McException(String message) {

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/NodeData.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/NodeData.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/NodeData.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/NodeData.java Sun Mar 28 15:43:18 2010
@@ -16,11 +16,22 @@
  */
 package org.apache.jackrabbit.j3.mc;
 
+/**
+ * The data container of a node.
+ */
 public class NodeData {
 
+    private static final int BIT_VERSION = 1;
+    private static final int BIT_CHILDREN = 2;
+    private static final int BIT_PROPERTIES = 4;
+    private static final int BIT_PRIMARY_TYPE = 8;
+    private static final int BIT_LOCKED = 16;
+
     private final Val id;
     private final Val primaryParentId;
     private long version;
+    private Val primaryType;
+    private Val lockToken;
     private Val[] propertyValuePairs;
     private Val[] childNameIdPairs;
     private int cachedParentIndex;
@@ -31,7 +42,7 @@ public class NodeData {
         this.version = version;
     }
 
-    public NodeData clone() {
+    public NodeData createCopy() {
         NodeData copy = new NodeData(id, primaryParentId, version);
         copy.propertyValuePairs = propertyValuePairs;
         copy.childNameIdPairs = childNameIdPairs;
@@ -206,32 +217,77 @@ public class NodeData {
         if (mainParentId == Val.FALSE) {
             mainParentId = null;
         }
-        int version = bundle.readVarInt();
+        int flags = bundle.readVarInt();
+        int version = 0;
+        if ((flags & BIT_VERSION) != 0) {
+            version = bundle.readVarInt();
+        }
         NodeData data = new NodeData(id, mainParentId, version);
-        Val children = bundle.readVal();
-        if (children != Val.FALSE) {
-            data.childNameIdPairs = children.getArray();
-        }
-        Val properties = bundle.readVal();
-        if (properties != Val.FALSE) {
-            data.propertyValuePairs = properties.getArray();
+        if ((flags & BIT_LOCKED) != 0) {
+            data.lockToken = bundle.readVal();
+        }
+        if ((flags & BIT_PRIMARY_TYPE) != 0) {
+            data.primaryType = bundle.readVal();
+        }
+        if ((flags & BIT_CHILDREN) != 0) {
+            int count = bundle.readVarInt();
+            data.childNameIdPairs = readArray(bundle, count * 2);
+        }
+        if ((flags & BIT_PROPERTIES) != 0) {
+            int count = bundle.readVarInt();
+            data.propertyValuePairs = readArray(bundle, count * 2);
         }
         return data;
     }
 
+    private static Val[] readArray(Bundle bundle, int count) {
+        Val[] array = new Val[count];
+        for (int i = 0; i < count; i++) {
+            array[i] = bundle.readVal();
+        }
+        return array;
+    }
+
     public void writeTo(Bundle bundle) {
         bundle.writeVal(id);
         bundle.writeVal(primaryParentId == null ? Val.FALSE : primaryParentId);
-        bundle.writeVarLong(version);
-        if (childNameIdPairs == null) {
-            bundle.writeVal(Val.FALSE);
-        } else {
-            bundle.writeVal(Val.get(childNameIdPairs));
+        int flags = 0;
+        if (version != 0) {
+            flags |= BIT_VERSION;
         }
-        if (propertyValuePairs == null) {
-            bundle.writeVal(Val.FALSE);
-        } else {
-            bundle.writeVal(Val.get(propertyValuePairs));
+        if (lockToken != null) {
+            flags |= BIT_LOCKED;
+        }
+        if (primaryType != null) {
+            flags |= BIT_PRIMARY_TYPE;
+        }
+        if (childNameIdPairs != null) {
+            flags |= BIT_CHILDREN;
+        }
+        if (propertyValuePairs != null) {
+            flags |= BIT_PROPERTIES;
+        }
+        bundle.writeVarLong(flags);
+        if (version != 0) {
+            bundle.writeVarLong(version);
+        }
+        if (lockToken != null) {
+            bundle.writeVal(lockToken);
+        }
+        if (primaryType != null) {
+            bundle.writeVal(primaryType);
+        }
+        if (childNameIdPairs != null) {
+            bundle.writeVarInt(childNameIdPairs.length / 2);
+            for (Val v : childNameIdPairs) {
+                bundle.writeVal(v);
+            }
+        }
+        if (propertyValuePairs != null) {
+            bundle.writeVarInt(propertyValuePairs.length / 2);
+            for (Val v : propertyValuePairs) {
+                bundle.writeVal(v);
+            }
         }
     }
 
@@ -243,6 +299,22 @@ public class NodeData {
         return primaryParentId;
     }
 
+    public Val getLockToken() {
+        return lockToken;
+    }
+
+    public void setLockToken(Val lockToken) {
+        this.lockToken = lockToken;
+    }
+
+    public Val getPrimaryType() {
+        return primaryType;
+    }
+
+    public void setPrimaryType(Val primaryType) {
+        this.primaryType = primaryType;
+    }
+
     public void incrementVersion() {
         version++;
     }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Storage.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Storage.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Storage.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Storage.java Sun Mar 28 15:43:18 2010
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.j3.mc;
 
+/**
+ * The storage interface.
+ */
 public interface Storage {
 
     StorageSession openSession(String user, String password);

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/StorageSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/StorageSession.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/StorageSession.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/StorageSession.java Sun Mar 28 15:43:18 2010
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.j3.mc;
 
+/**
+ * A session bound to a storage.
+ */
 public interface StorageSession {
 
     void close();

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java Sun Mar 28 15:43:18 2010
@@ -20,6 +20,9 @@ import java.util.Arrays;
 import java.util.HashMap;
 import javax.jcr.PropertyType;
 
+/**
+ * A value.
+ */
 public class Val implements Comparable<Val> {
 
     public static final Val TRUE = new Val(PropertyType.BOOLEAN, 0, true);
@@ -341,6 +344,9 @@ public class Val implements Comparable<V
     }
 
     public int compareTo(Val o) {
+        if (this == o) {
+            return 0;
+        }
         int result = compareInt(type, o.type);
         if (result != 0) {
             return result;
@@ -381,4 +387,32 @@ public class Val implements Comparable<V
         return Integer.signum(data1.length - data2.length);
     }
 
+    public Val addOrdered(Val x) {
+        // if this is a performance problem,
+        // use java.util.TreeMap<Val, Integer> where the value is the count
+        // or java.util.ArrayList<Val>
+        Val[] oldArray = getArray();
+        int pos = Arrays.binarySearch(oldArray, x);
+        if (pos < 0) {
+            pos = -1 - pos;
+        }
+        Val[] newArray = new Val[oldArray.length + 1];
+        System.arraycopy(oldArray, 0, newArray, 0, pos);
+        System.arraycopy(oldArray, pos, newArray, pos + 1, oldArray.length - pos);
+        newArray[pos] = x;
+        return Val.get(newArray);
+    }
+
+    public Val removeOrdered(Val x) {
+        Val[] oldArray = getArray();
+        int pos = Arrays.binarySearch(oldArray, x);
+        if (pos < 0) {
+            return this;
+        }
+        Val[] newArray = new Val[oldArray.length - 1];
+        System.arraycopy(oldArray, 0, newArray, 0, pos);
+        System.arraycopy(oldArray, pos + 1, newArray, pos, oldArray.length - pos - 1);
+        return Val.get(newArray);
+    }
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorage.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorage.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorage.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorage.java Sun Mar 28 15:43:18 2010
@@ -27,11 +27,14 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.concurrent.atomic.AtomicLong;
 
+/**
+ * A storage that uses the JDBC API.
+ */
 public class JdbcStorage implements Storage {
 
     private final String url;
     private boolean initDone;
-    private final static Val rootNodeId = Val.get(0);
+    private static final Val rootNodeId = Val.get(0);
     private AtomicLong nextNodeId;
 
     public JdbcStorage(String url) {

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorageSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorageSession.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorageSession.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorageSession.java Sun Mar 28 15:43:18 2010
@@ -27,6 +27,9 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.HashMap;
 
+/**
+ * A session for the JDBC storage.
+ */
 public class JdbcStorageSession implements StorageSession {
 
     private final JdbcStorage storage;

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorage.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorage.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorage.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorage.java Sun Mar 28 15:43:18 2010
@@ -23,9 +23,12 @@ import org.apache.jackrabbit.j3.mc.Stora
 import java.util.HashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
+/**
+ * A storage that keeps all data in memory.
+ */
 public class MemStorage implements Storage {
 
-    private final static Val rootNodeId = Val.get(0);
+    private static final Val rootNodeId = Val.get(0);
     private final HashMap<Val, NodeData> content = new HashMap<Val, NodeData>();
     private AtomicLong nextNodeId = new AtomicLong(1);
 

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorageSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorageSession.java?rev=928437&r1=928436&r2=928437&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorageSession.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorageSession.java Sun Mar 28 15:43:18 2010
@@ -21,6 +21,9 @@ import org.apache.jackrabbit.j3.mc.NodeD
 import org.apache.jackrabbit.j3.mc.StorageSession;
 import org.apache.jackrabbit.j3.mc.Val;
 
+/**
+ * A session for the memory storage.
+ */
 public class MemStorageSession implements StorageSession {
 
     private final MemStorage storage;

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/ItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/ItemDefinitionImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/ItemDefinitionImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/ItemDefinitionImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,64 @@
+/*
+ * 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.nodetype;
+
+import javax.jcr.nodetype.ItemDefinition;
+import javax.jcr.nodetype.NodeType;
+import org.apache.jackrabbit.j3.mc.Val;
+
+/**
+ * The item definition implementation.
+ */
+public class ItemDefinitionImpl implements ItemDefinition {
+
+    protected final NodeTypeManagerImpl manager;
+    protected Val name;
+    protected int onParentVersion;
+    protected boolean isAutoCreated;
+    protected boolean isMandatory;
+    protected boolean isProtected;
+
+    ItemDefinitionImpl(NodeTypeManagerImpl manager) {
+        this.manager = manager;
+    }
+
+    public NodeType getDeclaringNodeType() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getName() {
+        return manager.nameToString(name);
+    }
+
+    public int getOnParentVersion() {
+        return onParentVersion;
+    }
+
+    public boolean isAutoCreated() {
+        return isAutoCreated;
+    }
+
+    public boolean isMandatory() {
+        return isMandatory;
+    }
+
+    public boolean isProtected() {
+        return isProtected;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,56 @@
+/*
+ * 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.nodetype;
+
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+
+/**
+ * The node definition implementation.
+ */
+public class NodeDefinitionImpl extends ItemDefinitionImpl implements NodeDefinition {
+
+    protected NodeType defaultPrimaryType;
+    protected boolean allowsSameNameSiblings;
+
+    NodeDefinitionImpl(NodeTypeManagerImpl manager) {
+        super(manager);
+    }
+
+    public boolean allowsSameNameSiblings() {
+        return allowsSameNameSiblings;
+    }
+
+    public NodeType getDefaultPrimaryType() {
+        return defaultPrimaryType;
+    }
+
+    public String getDefaultPrimaryTypeName() {
+        return defaultPrimaryType == null ? null : defaultPrimaryType.getName();
+    }
+
+    public String[] getRequiredPrimaryTypeNames() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeType[] getRequiredPrimaryTypes() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionTemplateImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionTemplateImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionTemplateImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3.nodetype;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeDefinitionTemplate;
+
+/**
+ * The node definition template implementation.
+ */
+public class NodeDefinitionTemplateImpl extends NodeDefinitionImpl implements NodeDefinitionTemplate {
+
+    NodeDefinitionTemplateImpl(NodeTypeManagerImpl manager) {
+        super(manager);
+    }
+
+    public void setName(String name) throws ConstraintViolationException {
+        this.name = manager.parseName(name);
+    }
+
+    public void setAutoCreated(boolean autoCreated) {
+        this.isAutoCreated = autoCreated;
+    }
+
+    public void setDefaultPrimaryTypeName(String name) throws ConstraintViolationException {
+        try {
+            this.defaultPrimaryType = manager.getNodeType(name);
+        } catch (RepositoryException e) {
+            throw new ConstraintViolationException(e);
+        }
+    }
+
+    public void setMandatory(boolean mandatory) {
+        this.isMandatory = mandatory;
+    }
+
+    public void setOnParentVersion(int opv) {
+        this.onParentVersion = opv;
+    }
+
+    public void setProtected(boolean protectedStatus) {
+        this.isProtected = protectedStatus;
+    }
+
+    public void setRequiredPrimaryTypeNames(String[] names) throws ConstraintViolationException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setSameNameSiblings(boolean allowSameNameSiblings) {
+        this.allowsSameNameSiblings = allowSameNameSiblings;
+    }
+
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeDefinitionImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeDefinitionImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeDefinitionImpl.java Sun Mar 28 15:43:18 2010
@@ -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.j3.nodetype;
+
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
+import org.apache.jackrabbit.j3.mc.Val;
+
+/**
+ * The node type definition implementation.
+ */
+public class NodeTypeDefinitionImpl implements NodeTypeDefinition {
+
+    protected final NodeTypeManagerImpl manager;
+    protected Val name;
+    protected boolean hasOrderableChildNodes;
+    protected boolean isAbstract;
+    protected boolean isMixin;
+    protected boolean isQueryable;
+    protected Val primaryItemName;
+
+    NodeTypeDefinitionImpl(NodeTypeManagerImpl manager) {
+        this.manager = manager;
+    }
+
+    public String getName() {
+        return manager.nameToString(name);
+    }
+
+    public NodeDefinition[] getDeclaredChildNodeDefinitions() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public PropertyDefinition[] getDeclaredPropertyDefinitions() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String[] getDeclaredSupertypeNames() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getPrimaryItemName() {
+        return manager.nameToString(primaryItemName);
+    }
+
+    public boolean hasOrderableChildNodes() {
+        return hasOrderableChildNodes;
+    }
+
+    public boolean isAbstract() {
+        return isAbstract;
+    }
+
+    public boolean isMixin() {
+        return isMixin;
+    }
+
+    public boolean isQueryable() {
+        return isQueryable;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,105 @@
+/*
+ * 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.nodetype;
+
+import javax.jcr.Value;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.PropertyDefinition;
+
+/**
+ * The node type implementation.
+ */
+public class NodeTypeImpl extends NodeTypeDefinitionImpl implements NodeType {
+
+    NodeTypeImpl(NodeTypeManagerImpl manager) {
+        super(manager);
+    }
+
+    public boolean canAddChildNode(String childNodeName) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean canAddChildNode(String childNodeName, String nodeTypeName) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean canRemoveItem(String itemName) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean canRemoveNode(String nodeName) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean canRemoveProperty(String propertyName) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean canSetProperty(String propertyName, Value value) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean canSetProperty(String propertyName, Value[] values) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public NodeDefinition[] getChildNodeDefinitions() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeTypeIterator getDeclaredSubtypes() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeType[] getDeclaredSupertypes() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public PropertyDefinition[] getPropertyDefinitions() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeTypeIterator getSubtypes() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeType[] getSupertypes() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean isNodeType(String nodeTypeName) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeManagerImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeManagerImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeManagerImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,218 @@
+/*
+ * 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.nodetype;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeDefinitionTemplate;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.nodetype.NodeTypeExistsException;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NodeTypeTemplate;
+import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import org.apache.jackrabbit.j3.SessionImpl;
+import org.apache.jackrabbit.j3.mc.Val;
+
+/**
+ * A node type manager implementation.
+ */
+public class NodeTypeManagerImpl implements NodeTypeManager {
+
+    private final HashMap<Val, NodeTypeImpl> nodeTypes = new HashMap<Val, NodeTypeImpl>();
+    private final SessionImpl session;
+
+    void initSystemNodeTypes() {
+        String[] name = {
+                "nt:base",
+                "nt:hierarchyNode",
+                "nt:file",
+                "nt:linkedFile",
+                "nt:folder",
+                "nt:resource",
+                "mix:title",
+                "mix:created",
+                "mix:lastModified",
+                "mix:language",
+                "mix:mimeType",
+                "nt:address",
+                "mix:etag",
+                "nt:unstructured",
+                "nt:nodeType",
+                "nt:propertyDefinition",
+                "nt:childNodeDefinition",
+                "mix:referenceable",
+                "mix:lockable",
+                "mix:shareable",
+                "mix:lifecycle",
+                "mix:simpleVersionable",
+                "mix:versionable",
+                "nt:version",
+                "nt:versionHistory",
+                "nt:frozenNode",
+                "nt:versionLabels",
+                "nt:versionedChild"
+        };
+        for (String n : name) {
+            NodeTypeImpl nt = new NodeTypeImpl(this);
+            nt.name = parseName(n);
+            nodeTypes.put(nt.name, nt);
+        }
+    }
+
+    public NodeTypeManagerImpl(SessionImpl session) {
+        this.session = session;
+        initSystemNodeTypes();
+    }
+
+    String nameToString(Val name) {
+        return session.nameToString(name);
+    }
+
+    Val parseName(String name) {
+        return session.parseName(name);
+    }
+
+    public NodeType getNodeType(Val nodeTypeName) {
+        return nodeTypes.get(nodeTypeName);
+    }
+
+    public NodeType getNodeType(String nodeTypeName) throws NoSuchNodeTypeException, RepositoryException {
+        return getNodeType(parseName(nodeTypeName));
+    }
+
+    public NodeDefinitionTemplate createNodeDefinitionTemplate() throws UnsupportedRepositoryOperationException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeTypeTemplate createNodeTypeTemplate() throws UnsupportedRepositoryOperationException,
+            RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd)
+            throws UnsupportedRepositoryOperationException, RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public PropertyDefinitionTemplate createPropertyDefinitionTemplate()
+            throws UnsupportedRepositoryOperationException, RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
+        return new NodeTypeIteratorImpl(nodeTypes.values());
+    }
+
+    public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean hasNodeType(String name) throws RepositoryException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
+            throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
+            UnsupportedRepositoryOperationException, RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)
+            throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
+            UnsupportedRepositoryOperationException, RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void unregisterNodeType(String name) throws UnsupportedRepositoryOperationException,
+            NoSuchNodeTypeException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void unregisterNodeTypes(String[] names) throws UnsupportedRepositoryOperationException,
+            NoSuchNodeTypeException, RepositoryException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /**
+     * The node type iterator implementation.
+     */
+    class NodeTypeIteratorImpl implements NodeTypeIterator {
+
+        private final Iterator<NodeTypeImpl> iterator;
+        private int pos;
+
+        NodeTypeIteratorImpl(Collection<NodeTypeImpl> coll) {
+            this.iterator = coll.iterator();
+        }
+
+        public NodeType nextNodeType() {
+            pos++;
+            return iterator.next();
+        }
+
+        public long getPosition() {
+            return pos;
+        }
+
+        public long getSize() {
+            return nodeTypes.size();
+        }
+
+        public void skip(long skipNum) {
+            for (long i = 0; i < skipNum; i++) {
+                next();
+            }
+        }
+
+        public boolean hasNext() {
+            return iterator.hasNext();
+        }
+
+        public Object next() {
+            return nextNodeType();
+        }
+
+        public void remove() {
+            iterator.remove();
+        }
+
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeRegistry.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeRegistry.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeRegistry.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,24 @@
+/*
+ * 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.nodetype;
+
+/**
+ * The node type registry.
+ */
+public class NodeTypeRegistry {
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeTemplateImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeTemplateImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeTemplateImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3.nodetype;
+
+import java.util.List;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeDefinitionTemplate;
+import javax.jcr.nodetype.NodeTypeTemplate;
+import javax.jcr.nodetype.PropertyDefinitionTemplate;
+
+/**
+ * The node type template implementation.
+ */
+public class NodeTypeTemplateImpl extends NodeTypeDefinitionImpl implements NodeTypeTemplate {
+
+    NodeTypeTemplateImpl(NodeTypeManagerImpl manager) {
+        super(manager);
+    }
+
+    public void setName(String name) throws ConstraintViolationException {
+        this.name = manager.parseName(name);
+    }
+
+    public List<NodeDefinitionTemplate> getNodeDefinitionTemplates() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<PropertyDefinitionTemplate> getPropertyDefinitionTemplates() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void setAbstract(boolean abstractStatus) {
+        this.isAbstract = abstractStatus;
+    }
+
+    public void setDeclaredSuperTypeNames(String[] names) throws ConstraintViolationException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setMixin(boolean mixin) {
+        this.isMixin = mixin;
+    }
+
+    public void setOrderableChildNodes(boolean orderable) {
+        this.hasOrderableChildNodes = orderable;
+    }
+
+    public void setPrimaryItemName(String name) throws ConstraintViolationException {
+        this.primaryItemName = manager.parseName(name);
+    }
+
+    public void setQueryable(boolean queryable) {
+        this.isQueryable = queryable;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3.nodetype;
+
+import javax.jcr.Value;
+import javax.jcr.nodetype.PropertyDefinition;
+
+/**
+ * The property definition implementation.
+ */
+public class PropertyDefinitionImpl extends ItemDefinitionImpl implements PropertyDefinition {
+
+    protected int requiredType;
+    protected boolean isFullTextSearchable;
+    protected boolean isMultiple;
+    protected boolean isQueryOrderable;
+
+    PropertyDefinitionImpl(NodeTypeManagerImpl manager) {
+        super(manager);
+    }
+
+    public String[] getAvailableQueryOperators() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Value[] getDefaultValues() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public int getRequiredType() {
+        return requiredType;
+    }
+
+    public String[] getValueConstraints() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean isFullTextSearchable() {
+        return isFullTextSearchable;
+    }
+
+    public boolean isMultiple() {
+        return isMultiple;
+    }
+
+    public boolean isQueryOrderable() {
+        return isQueryOrderable;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionTemplateImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionTemplateImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionTemplateImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3.nodetype;
+
+import javax.jcr.Value;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.PropertyDefinitionTemplate;
+
+/**
+ * The property definition template implementation.
+ */
+public class PropertyDefinitionTemplateImpl extends PropertyDefinitionImpl implements PropertyDefinitionTemplate {
+
+    PropertyDefinitionTemplateImpl(NodeTypeManagerImpl manager) {
+        super(manager);
+    }
+
+    public void setName(String name) throws ConstraintViolationException {
+        this.name = manager.parseName(name);
+    }
+
+    public void setAutoCreated(boolean autoCreated) {
+        this.isAutoCreated = autoCreated;
+    }
+
+    public void setAvailableQueryOperators(String[] operators) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setDefaultValues(Value[] defaultValues) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setFullTextSearchable(boolean fullTextSearchable) {
+        this.isFullTextSearchable = fullTextSearchable;
+    }
+
+    public void setMandatory(boolean mandatory) {
+        this.isMandatory = mandatory;
+    }
+
+    public void setMultiple(boolean multiple) {
+        this.isMultiple = multiple;
+    }
+
+    public void setOnParentVersion(int opv) {
+        this.onParentVersion = opv;
+    }
+
+    public void setProtected(boolean protectedStatus) {
+        this.isProtected = protectedStatus;
+    }
+
+    public void setQueryOrderable(boolean queryOrderable) {
+        this.isQueryOrderable = queryOrderable;
+    }
+
+    public void setRequiredType(int type) {
+        this.requiredType = type;
+    }
+
+    public void setValueConstraints(String[] constraints) {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventConsumer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventConsumer.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventConsumer.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventConsumer.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,168 @@
+/*
+ * 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.observation;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventIterator;
+import javax.jcr.observation.EventListener;
+import org.apache.jackrabbit.j3.Change;
+import org.apache.jackrabbit.j3.ChangeList;
+import org.apache.jackrabbit.j3.SessionImpl;
+
+/**
+ * A observation listener wrapper.
+ */
+public class EventConsumer {
+
+    private final SessionImpl session;
+    private final EventListener listener;
+    private final int eventTypes;
+    private final String absPath;
+    private final boolean isDeep;
+    private final HashSet<String> identifierSet;
+    private final HashSet<String> nodeTypeNameSet;
+    private final boolean noLocal;
+
+    EventConsumer(SessionImpl session, EventListener listener, int eventTypes, String absPath, boolean isDeep, String[] identifiers, String[] nodeTypeName, boolean noLocal) {
+        this.session = session;
+        this.listener = listener;
+        this.eventTypes = eventTypes;
+        this.absPath = absPath;
+        this.isDeep = isDeep;
+        if (identifiers == null) {
+            identifierSet = null;
+        } else {
+            identifierSet = new HashSet<String>();
+            for (String id : identifiers) {
+                identifierSet.add(id);
+            }
+        }
+        if (nodeTypeName == null) {
+            nodeTypeNameSet = null;
+        } else {
+            nodeTypeNameSet = new HashSet<String>();
+            for (String name : nodeTypeName) {
+                nodeTypeNameSet.add(name);
+            }
+        }
+        this.noLocal = noLocal;
+    }
+
+    public EventListener getListener() {
+        return listener;
+    }
+
+    boolean matchesType(int type) {
+        return (type & eventTypes) != 0;
+    }
+
+    boolean matchesIdentifier(String identifier) {
+        if (identifier == null || identifierSet == null) {
+            return true;
+        }
+        return identifierSet.contains(identifier);
+    }
+
+    boolean matchesNodeTypeName(String nodeTypeName) {
+        if (nodeTypeName == null || nodeTypeNameSet == null) {
+            return true;
+        }
+        return nodeTypeNameSet.contains(nodeTypeName);
+    }
+
+    void dispatch(ChangeList events) {
+        if (noLocal && events.getSession() == session) {
+            return;
+        }
+        listener.onEvent(new FilteredEventIterator(events));
+    }
+
+    /**
+     * An event iterator that filters events for a given event listener.
+     */
+    class FilteredEventIterator implements EventIterator {
+
+        private final Iterator<Change> iterator;
+        private Event next;
+        private int pos;
+
+        FilteredEventIterator(ChangeList events) {
+            iterator = events.getChangeList().iterator();
+            go();
+        }
+
+        private void go() {
+            try {
+                while (true) {
+                    if (!iterator.hasNext()) {
+                        next = null;
+                        return;
+                    }
+                    next = iterator.next();
+                    if (!matchesType(next.getType())) {
+                        continue;
+                    }
+                    if (!matchesIdentifier(next.getIdentifier())) {
+                        continue;
+                    }
+                    // TODO matchesNodeTypeName
+                    // TODO matchesPath
+                    return;
+                }
+            } catch (RepositoryException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        public Event nextEvent() {
+            Event result = next;
+            go();
+            return result;
+        }
+
+        public long getPosition() {
+            return pos;
+        }
+
+        public long getSize() {
+            return -1;
+        }
+
+        public void skip(long skipNum) {
+            for (int i = 0; i < skipNum; i++) {
+                go();
+            }
+        }
+
+        public boolean hasNext() {
+            return next != null;
+        }
+
+        public Object next() {
+            return nextEvent();
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/ObservationManagerImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/ObservationManagerImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/ObservationManagerImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,127 @@
+/*
+ * 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.observation;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.observation.EventJournal;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.EventListenerIterator;
+import javax.jcr.observation.ObservationManager;
+import org.apache.jackrabbit.j3.ChangeList;
+import org.apache.jackrabbit.j3.SessionImpl;
+
+/**
+ * The observation manager implementation.
+ */
+public class ObservationManagerImpl implements ObservationManager {
+
+    private final SessionImpl session;
+    private final ArrayList<EventConsumer> eventConsumers = new ArrayList<EventConsumer>();
+
+    public ObservationManagerImpl(SessionImpl session) {
+        this.session = session;
+    }
+
+    public void setUserData(String userData) throws RepositoryException {
+        session.setObservationUserData(userData);
+    }
+
+    public void addEventListener(EventListener listener, int eventTypes, String absPath, boolean isDeep, String[] uuid,
+            String[] nodeTypeName, boolean noLocal) throws RepositoryException {
+        EventConsumer consumer = new EventConsumer(session, listener, eventTypes, absPath, isDeep, uuid, nodeTypeName, noLocal);
+        eventConsumers.add(consumer);
+    }
+
+    public void removeEventListener(EventListener listener) throws RepositoryException {
+        for (EventConsumer consumer : eventConsumers) {
+            if (consumer.getListener() == listener) {
+                // TODO block until the listener has completed
+                eventConsumers.remove(consumer);
+                return;
+            }
+        }
+    }
+
+    public EventListenerIterator getRegisteredEventListeners() throws RepositoryException {
+        return new EventListenerIteratorImpl();
+    }
+
+    public EventJournal getEventJournal() throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public EventJournal getEventJournal(int eventTypes, String absPath, boolean isDeep, String[] uuid,
+            String[] nodeTypeName) throws RepositoryException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /**
+     * A event listener iterator implementation.
+     */
+    class EventListenerIteratorImpl implements EventListenerIterator {
+
+        private final Iterator<EventConsumer> iterator;
+        private int pos;
+
+        EventListenerIteratorImpl() {
+            iterator = eventConsumers.iterator();
+        }
+
+        public EventListener nextEventListener() {
+            pos++;
+            return iterator.next().getListener();
+        }
+
+        public long getPosition() {
+            return pos;
+        }
+
+        public long getSize() {
+            return eventConsumers.size();
+        }
+
+        public void skip(long skipNum) {
+            for (long i = 0; i < skipNum; i++) {
+                next();
+            }
+        }
+
+        public boolean hasNext() {
+            return iterator.hasNext();
+        }
+
+        public Object next() {
+            return nextEventListener();
+        }
+
+        public void remove() {
+            iterator.remove();
+        }
+
+    }
+
+    public void dispatchEvents(ChangeList events) {
+        for (EventConsumer consumer : eventConsumers) {
+            consumer.dispatch(events);
+        }
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/PrivilegeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/PrivilegeImpl.java?rev=928437&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/PrivilegeImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/PrivilegeImpl.java Sun Mar 28 15:43:18 2010
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3.security;
+
+/**
+ * A privilege implementation.
+ */
+public class PrivilegeImpl {
+
+    public static final int ADD_CHILD_NODES = 1;
+    public static final int LIFECYCLE_MANAGEMENT = 2;
+    public static final int LOCK_MANAGEMENT = 4;
+    public static final int MODIFY_ACCESS_CONTROL = 8;
+    public static final int MODIFY_PROPERTIES = 16;
+    public static final int NODE_TYPE_MANAGEMENT = 32;
+    public static final int READ = 64;
+    public static final int READ_ACCESS_CONTROL = 128;
+    public static final int REMOVE_CHILD_NODES = 256;
+    public static final int REMOVE_NODE = 512;
+    public static final int RETENTION_MANAGEMENT = 1024;
+    public static final int VERSION_MANAGEMENT = 2048;
+
+    public static final int LOCK_OK = 4096;
+
+    public static final int WRITE = MODIFY_PROPERTIES |
+            ADD_CHILD_NODES | REMOVE_NODE | REMOVE_CHILD_NODES;
+    public static final int ALL = READ | WRITE | READ_ACCESS_CONTROL |
+            MODIFY_ACCESS_CONTROL | LOCK_MANAGEMENT |
+            VERSION_MANAGEMENT | NODE_TYPE_MANAGEMENT |
+            RETENTION_MANAGEMENT | LIFECYCLE_MANAGEMENT;
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/site/resources/images/drawing.png
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/site/resources/images/drawing.png?rev=928437&view=auto
==============================================================================
Binary file - no diff available.

Propchange: jackrabbit/sandbox/jackrabbit-j3/src/site/resources/images/drawing.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message