jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r932960 - in /jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3: lock/ mc/ mc/jdbc/ mc/mem/ retention/ security/
Date Sun, 11 Apr 2010 17:54:08 GMT
Author: thomasm
Date: Sun Apr 11 17:54:07 2010
New Revision: 932960

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

Added:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/HoldImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/RetentionManagerImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/RetentionPolicyImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlEntryImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlListImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlManagerImpl.java
Modified:
    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/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/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/security/PrivilegeImpl.java

Modified: 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=932960&r1=932959&r2=932960&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockImpl.java Sun Apr 11 17:54:07 2010
@@ -21,33 +21,40 @@ import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
 import org.apache.jackrabbit.j3.NodeImpl;
 import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
 
 /**
- * A lock implementation.
+ * The implementation of the corresponding JCR interface.
  */
-public class LockImpl implements Lock {
+public class LockImpl implements Lock, LogObject {
 
     private final NodeImpl node;
+    private final Log log;
     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.log = node.getLog();
         this.lockToken = lockToken;
         this.isDeep = isDeep;
         this.isSessionScoped = isSessionScoped;
     }
 
     public boolean isDeep() {
+        log.code(this, "isDeep");
         return isDeep;
     }
 
     public boolean isSessionScoped() {
+        log.code(this, "isSessionScoped");
         return isSessionScoped;
     }
 
     public NodeImpl getNode() {
+        log.codeAssign(node, this, "getNode");
         return node;
     }
 
@@ -56,31 +63,37 @@ public class LockImpl implements Lock {
     }
 
     public String getLockOwner() {
+        log.code(this, "getLockOwner");
         // TODO Auto-generated method stub
         return null;
     }
 
     public String getLockToken() {
+        log.code(this, "getLockToken");
         // TODO Auto-generated method stub
         return null;
     }
 
     public long getSecondsRemaining() throws RepositoryException {
+        log.code(this, "getSecondsRemaining");
         // TODO Auto-generated method stub
         return 0;
     }
 
     public boolean isLive() throws RepositoryException {
+        log.code(this, "isLive");
         // TODO Auto-generated method stub
         return false;
     }
 
     public boolean isLockOwningSession() {
+        log.code(this, "isLockOwningSession");
         // TODO Auto-generated method stub
         return false;
     }
 
     public void refresh() throws LockException, RepositoryException {
+        log.code(this, "refresh");
         // TODO Auto-generated method stub
 
     }

Modified: 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=932960&r1=932959&r2=932960&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockManagerImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/lock/LockManagerImpl.java Sun Apr 11 17:54:07 2010
@@ -27,18 +27,22 @@ import javax.jcr.lock.LockManager;
 import org.apache.jackrabbit.j3.NodeImpl;
 import org.apache.jackrabbit.j3.SessionImpl;
 import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
 
 /**
- * A lock manager implementation.
+ * The implementation of the corresponding JCR interface.
  */
-public class LockManagerImpl implements LockManager {
+public class LockManagerImpl implements LockManager, LogObject {
 
     private final LockSystem lockSystem;
     private final SessionImpl session;
+    private final Log log;
     private HashSet<Val> lockTokens = new HashSet<Val>();
 
     public LockManagerImpl(SessionImpl session, LockSystem lockSystem) {
         this.session = session;
+        this.log = session.getLog();
         this.lockSystem = lockSystem;
     }
 
@@ -49,13 +53,16 @@ public class LockManagerImpl implements 
     public Lock lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
             throws LockException, PathNotFoundException, AccessDeniedException, InvalidItemStateException,
             RepositoryException {
+        log.code(this, "lock", absPath, isDeep, isSessionScoped, timeoutHint, ownerInfo);
         NodeImpl node = session.getNode(absPath);
         LockImpl lock = node.lock(isDeep, isSessionScoped);
         lockTokens.add(lock.getInternalLockToken());
+        log.codeAssign(lock, this, "lock", absPath, isDeep, isSessionScoped, timeoutHint, ownerInfo);
         return lock;
     }
 
     public void addLockToken(String lockToken) throws LockException, RepositoryException {
+        log.code(this, "addLockToken", lockToken);
         synchronized (session) {
             lockTokens.add(Val.get(lockToken));
         }
@@ -63,32 +70,38 @@ public class LockManagerImpl implements 
 
     public Lock getLock(String absPath) throws PathNotFoundException, LockException, AccessDeniedException,
             RepositoryException {
+        log.code(this, "getLock", absPath);
         // TODO Auto-generated method stub
         return null;
     }
 
     public String[] getLockTokens() throws RepositoryException {
+        log.code(this, "getLockTokens");
         // TODO Auto-generated method stub
         return null;
     }
 
     public boolean holdsLock(String absPath) throws PathNotFoundException, RepositoryException {
+        log.code(this, "holdsLock", absPath);
         // TODO Auto-generated method stub
         return false;
     }
 
     public boolean isLocked(String absPath) throws PathNotFoundException, RepositoryException {
+        log.code(this, "isLocked", absPath);
         // TODO Auto-generated method stub
         return false;
     }
 
     public void removeLockToken(String lockToken) throws LockException, RepositoryException {
+        log.code(this, "removeLockToken", lockToken);
         // TODO Auto-generated method stub
 
     }
 
     public void unlock(String absPath) throws PathNotFoundException, LockException, AccessDeniedException,
             InvalidItemStateException, RepositoryException {
+        log.code(this, "unlock", absPath);
         // TODO Auto-generated method stub
 
     }

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=932960&r1=932959&r2=932960&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 Apr 11 17:54:07 2010
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.j3.mc;
 
 import javax.jcr.PropertyType;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
 
 /**
  * A byte buffer that contains serialized data.
@@ -301,7 +302,7 @@ public class Bundle {
             writeString(v.getString());
             break;
         default:
-            throw new IllegalArgumentException("type:" + v.getType());
+            throw ExceptionFactory.illegalArgument("type: {0}", v.getType());
         }
         int len = pos - start;
         if (len > 8) {
@@ -392,7 +393,7 @@ public class Bundle {
         case PropertyType.WEAKREFERENCE:
             return 1 + getStringLen(v.getString());
         default:
-            throw new IllegalArgumentException("type:" + v.getType());
+            throw ExceptionFactory.illegalArgument("type: {0}", v.getType());
         }
     }
 
@@ -463,7 +464,7 @@ public class Bundle {
                 }
                 return Val.get(array);
             }
-            throw new IllegalArgumentException("type:" + type);
+            throw ExceptionFactory.illegalArgument("type: {0}", 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=932960&r1=932959&r2=932960&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 Apr 11 17:54:07 2010
@@ -29,4 +29,8 @@ public class McException extends Runtime
         super(e);
     }
 
+    public McException(String message, Exception e) {
+        super(message, e);
+    }
+
 }

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=932960&r1=932959&r2=932960&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 Apr 11 17:54:07 2010
@@ -16,10 +16,14 @@
  */
 package org.apache.jackrabbit.j3.mc;
 
+import org.apache.jackrabbit.j3.util.CacheElement;
+import org.apache.jackrabbit.j3.util.Constants;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
+
 /**
  * The data container of a node.
  */
-public class NodeData {
+public class NodeData implements CacheElement {
 
     private static final int BIT_VERSION = 1;
     private static final int BIT_CHILDREN = 2;
@@ -35,6 +39,7 @@ public class NodeData {
     private Val[] propertyValuePairs;
     private Val[] childNameIdPairs;
     private int cachedParentIndex;
+    private int memoryCache;
 
     public NodeData(Val id, Val primaryParentId, long version) {
         this.id = id;
@@ -44,14 +49,43 @@ public class NodeData {
 
     public NodeData createCopy() {
         NodeData copy = new NodeData(id, primaryParentId, version);
+        copy.memoryCache = memoryCache;
         copy.propertyValuePairs = propertyValuePairs;
         copy.childNameIdPairs = childNameIdPairs;
         return copy;
     }
 
+    /**
+     * Get the property name by index.
+     *
+     * @param index the index (0, 1,...)
+     * @return null if the index is too large
+     */
+    public Val getPropertyName(int index) {
+        index += index;
+        if (propertyValuePairs == null || index >= propertyValuePairs.length) {
+            return null;
+        }
+        return propertyValuePairs[index];
+    }
+
+    /**
+     * Get the property value by index.
+     *
+     * @param index the index (0, 1,...)
+     * @return null if the index is too large
+     */
+    public Val getPropertyValue(int index) {
+        index += index;
+        if (propertyValuePairs == null || index >= propertyValuePairs.length) {
+            return null;
+        }
+        return propertyValuePairs[index];
+    }
+
     public void addChild(Val childName, Val childId) {
         if (getChildId(childName) != null) {
-            throw new McException("duplicate node");
+            throw ExceptionFactory.mcException("Duplicate node");
         }
         childNameIdPairs = updatePair(childNameIdPairs, childName, childId);
     }
@@ -65,11 +99,39 @@ public class NodeData {
     }
 
     public Val getName(NodeData parent) {
+        int index = getChildIndex(parent);
+        if (index < 0) {
+            if (parent == null) {
+                return Val.get("");
+            }
+            throw ExceptionFactory.mcException("Child not found: {0}", id);
+        }
+        return parent.childNameIdPairs[cachedParentIndex];
+    }
+
+    public Val getNextChildId(NodeData lastChild) {
+        int index;
+        if (lastChild == null) {
+            if (childNameIdPairs == null) {
+                return null;
+            }
+            index = 0;
+        } else {
+            index = lastChild.getChildIndex(this);
+            if (index < 0 || index + 2 >= childNameIdPairs.length) {
+                return null;
+            }
+            index += 2;
+        }
+        return childNameIdPairs[index + 1];
+    }
+
+    private int getChildIndex(NodeData parent) {
         if (parent == null) {
-            return Val.get("");
+            return -1;
         }
         if (parent.childNameIdPairs == null) {
-            throw new McException("Child not found: " + id);
+            return -1;
         }
         if (cachedParentIndex > parent.childNameIdPairs.length
                 || !parent.childNameIdPairs[cachedParentIndex + 1].equals(id)) {
@@ -80,10 +142,10 @@ public class NodeData {
                 }
             }
             if (!parent.childNameIdPairs[cachedParentIndex + 1].equals(id)) {
-                throw new McException("Child not found: " + id);
+                return -1;
             }
         }
-        return parent.childNameIdPairs[cachedParentIndex];
+        return cachedParentIndex;
     }
 
     public Val getChildId(Val name) {
@@ -98,6 +160,25 @@ public class NodeData {
         return childId;
     }
 
+    /**
+     * Get the index of the given property name.
+     * This method works like java.util.Array.binarySearch.
+     *
+     * @param propertyName the property name to search
+     * @return the index if found (0, 1,...); or (-index - 1) if not
+     */
+    public int getPropertyIndex(Val propertyName) {
+        if (propertyValuePairs == null) {
+            return -1;
+        }
+        int index = search(propertyName, propertyValuePairs);
+        return index / 2;
+    }
+
+    public int getPropertyCount() {
+        return propertyValuePairs == null ? 0 : propertyValuePairs.length / 2;
+    }
+
     public Val getPropertyValue(Val propertyName) {
         if (propertyValuePairs == null) {
             return null;
@@ -114,6 +195,7 @@ public class NodeData {
     }
 
     Val[] updatePair(Val[] pairs, Val key, Val value) {
+        memoryCache = 0;
         if (pairs == null) {
             if (value == null) {
                 return null;
@@ -170,8 +252,21 @@ public class NodeData {
         return -(low * 2 + 2);
     }
 
-    int getMemoryUsed() {
-        int memory = 16;
+    public int getMemoryUsed() {
+        if (memoryCache != 0) {
+            return memoryCache;
+        }
+        int memory = Constants.MEM_NODE_DATA;
+        memory += id.getMemoryUsed();
+        if (primaryParentId != null) {
+            memory += primaryParentId.getMemoryUsed();
+        }
+        if (primaryType != null) {
+            memory += primaryType.getMemoryUsed();
+        }
+        if (lockToken != null) {
+            memory += lockToken.getMemoryUsed();
+        }
         if (propertyValuePairs != null) {
             for (Val v : propertyValuePairs) {
                 memory += v.getMemoryUsed();
@@ -182,6 +277,7 @@ public class NodeData {
                 memory += v.getMemoryUsed();
             }
         }
+        memoryCache = memory;
         return memory;
     }
 
@@ -304,6 +400,7 @@ public class NodeData {
     }
 
     public void setLockToken(Val lockToken) {
+        memoryCache = 0;
         this.lockToken = lockToken;
     }
 
@@ -312,6 +409,7 @@ public class NodeData {
     }
 
     public void setPrimaryType(Val primaryType) {
+        memoryCache = 0;
         this.primaryType = primaryType;
     }
 

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=932960&r1=932959&r2=932960&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 Apr 11 17:54:07 2010
@@ -21,7 +21,7 @@ package org.apache.jackrabbit.j3.mc;
  */
 public interface Storage {
 
-    StorageSession openSession(String user, String password);
+    StorageSession openSession(String user, char[] password);
 
     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=932960&r1=932959&r2=932960&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 Apr 11 17:54:07 2010
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.j3.mc;
 import java.util.Arrays;
 import java.util.HashMap;
 import javax.jcr.PropertyType;
+import org.apache.jackrabbit.j3.util.Constants;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
 
 /**
  * A value.
@@ -163,7 +165,7 @@ public class Val implements Comparable<V
         };
         int i = 0;
         for (Val v : indexed) {
-            v.index = (short) i;
+            v.index = (byte) i;
             INDEXED[i] = v;
             INDEX_MAP.put(v, i);
             i++;
@@ -202,7 +204,7 @@ public class Val implements Comparable<V
 
     public static Val get(Val... array) {
         if (array == null) {
-            throw new NullPointerException();
+            throw ExceptionFactory.nullPointer();
         }
         return new Val(TYPE_MULTI_VALUE, 0, array);
     }
@@ -235,6 +237,10 @@ public class Val implements Comparable<V
             x = EMPTY_STRING;
         }
         switch (type) {
+        case PropertyType.BOOLEAN:
+            return get(Boolean.parseBoolean(x));
+        case PropertyType.LONG:
+            return get(Long.decode(x));
         case PropertyType.DECIMAL:
         case PropertyType.DATE:
         case PropertyType.NAME:
@@ -247,7 +253,7 @@ public class Val implements Comparable<V
         case PropertyType.BINARY:
             return cache(TYPE_BINARY_REFERENCE, x);
         }
-        throw new IllegalArgumentException("type: " + type + " value: " + x);
+        throw ExceptionFactory.illegalArgument("type: {0}, value: {0}", type, x);
     }
 
     public int hashCode() {
@@ -313,6 +319,10 @@ public class Val implements Comparable<V
         return (Double) value;
     }
 
+    public boolean getBoolean() {
+        return (Boolean) value;
+    }
+
     public byte[] getBytes() {
         return (byte[]) value;
     }
@@ -330,17 +340,24 @@ public class Val implements Comparable<V
     }
 
     public int getMemoryUsed() {
-        if (index == 0) {
+        if (index != 0) {
             return 0;
         }
         switch (type) {
         case PropertyType.BINARY:
-            return 32 + getBytes().length;
+            return Constants.MEM_VAL_BINARY + getBytes().length;
         case PropertyType.LONG:
         case PropertyType.DOUBLE:
-            return 16;
+            return Constants.MEM_VAL_LONG;
+        case TYPE_MULTI_VALUE: {
+            int mem = Constants.MEM_VAL_LONG;
+            for (Val v : getArray()) {
+                mem += v.getMemoryUsed() + Constants.MEM_VAL_OBJ;
+            }
+            return mem;
+        }
         }
-        return 32 + getString().length() * 2;
+        return Constants.MEM_VAL_STRING + getString().length() * 2;
     }
 
     public int compareTo(Val o) {

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=932960&r1=932959&r2=932960&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 Apr 11 17:54:07 2010
@@ -16,16 +16,16 @@
  */
 package org.apache.jackrabbit.j3.mc.jdbc;
 
-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 java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.concurrent.atomic.AtomicLong;
+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.util.ExceptionFactory;
 
 /**
  * A storage that uses the JDBC API.
@@ -41,14 +41,14 @@ public class JdbcStorage implements Stor
         this.url = url;
     }
 
-    public StorageSession openSession(String user, String password) {
+    public StorageSession openSession(String user, char[] password) {
         try {
-            Connection conn = JdbcUtils.getConnection(null, url, user, password);
+            Connection conn = JdbcUtils.getConnection(null, url, user, new String(password));
             JdbcStorageSession session = new JdbcStorageSession(this, conn);
             init(conn, session);
             return session;
         } catch (SQLException e) {
-            throw new McException(e);
+            throw ExceptionFactory.mcException(e);
         }
     }
 
@@ -67,7 +67,7 @@ public class JdbcStorage implements Stor
                 session.save(new NodeData[] { root });
             }
         } catch (SQLException e) {
-            throw new McException(e);
+            throw ExceptionFactory.mcException(e);
         }
         initDone = true;
     }

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=932960&r1=932959&r2=932960&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 Apr 11 17:54:07 2010
@@ -16,16 +16,16 @@
  */
 package org.apache.jackrabbit.j3.mc.jdbc;
 
-import org.apache.jackrabbit.j3.mc.Bundle;
-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 java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.HashMap;
+import org.apache.jackrabbit.j3.mc.Bundle;
+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.util.ExceptionFactory;
 
 /**
  * A session for the JDBC storage.
@@ -55,7 +55,7 @@ public class JdbcStorageSession implemen
         try {
             conn.close();
         } catch (SQLException e) {
-            throw new McException(e);
+            throw ExceptionFactory.mcException(e);
         }
     }
 
@@ -78,7 +78,7 @@ public class JdbcStorageSession implemen
             rs.close();
             return node;
         } catch (SQLException e) {
-            throw new McException(e);
+            throw ExceptionFactory.mcException(e);
         }
     }
 
@@ -109,15 +109,15 @@ public class JdbcStorageSession implemen
                         update.setBytes(2, bundle.getBytes());
                         int updateCount = update.executeUpdate();
                         if (updateCount != 1) {
-                            throw new McException("Update failed, update count is " + updateCount);
+                            throw ExceptionFactory.mcException("Update failed, update count is {0}", updateCount);
                         }
                     }
                 } catch (SQLException e) {
-                    throw new McException(e);
+                    throw ExceptionFactory.mcException(e);
                 }
             }
         } catch (SQLException e) {
-            throw new McException(e);
+            throw ExceptionFactory.mcException(e);
         }
     }
 

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=932960&r1=932959&r2=932960&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 Apr 11 17:54:07 2010
@@ -40,7 +40,7 @@ public class MemStorage implements Stora
     public void close() {
     }
 
-    public StorageSession openSession(String user, String password) {
+    public StorageSession openSession(String user, char[] password) {
         return new MemStorageSession(this, content);
     }
 

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/HoldImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/HoldImpl.java?rev=932960&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/HoldImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/HoldImpl.java Sun Apr 11 17:54:07 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.retention;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.retention.Hold;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class HoldImpl implements Hold, LogObject {
+
+    private final String name;
+    private final boolean isDeep;
+    private final Log log;
+
+    HoldImpl(String name, boolean isDeep, Log log) {
+        this.name = name;
+        this.isDeep = isDeep;
+        this.log = log;
+    }
+
+    public String getName() throws RepositoryException {
+        log.code(this, "getName");
+        // TODO Auto-generated method stub
+        return name;
+    }
+
+    public boolean isDeep() throws RepositoryException {
+        log.code(this, "isDeep");
+        // TODO Auto-generated method stub
+        return isDeep;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/RetentionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/RetentionManagerImpl.java?rev=932960&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/RetentionManagerImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/RetentionManagerImpl.java Sun Apr 11 17:54:07 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.retention;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
+import javax.jcr.retention.Hold;
+import javax.jcr.retention.RetentionManager;
+import javax.jcr.retention.RetentionPolicy;
+import javax.jcr.version.VersionException;
+import org.apache.jackrabbit.j3.SessionImpl;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class RetentionManagerImpl implements RetentionManager, LogObject {
+
+    private final Log log;
+
+    public RetentionManagerImpl(SessionImpl session) {
+        this.log = session.getLog();
+    }
+
+    public Hold addHold(String absPath, String name, boolean isDeep) throws PathNotFoundException,
+            AccessDeniedException, LockException, VersionException, RepositoryException {
+        log.code(this, "addHold", absPath, name, isDeep);
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Hold[] getHolds(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException {
+        log.code(this, "getHolds", absPath);
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public RetentionPolicy getRetentionPolicy(String absPath) throws PathNotFoundException, AccessDeniedException,
+            RepositoryException {
+        log.code(this, "getRetentionPolicy", absPath);
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void removeHold(String absPath, Hold hold) throws PathNotFoundException, AccessDeniedException,
+            LockException, VersionException, RepositoryException {
+        log.code(this, "removeHold", absPath, hold);
+        // TODO Auto-generated method stub
+
+    }
+
+    public void removeRetentionPolicy(String absPath) throws PathNotFoundException, AccessDeniedException,
+            LockException, VersionException, RepositoryException {
+        log.code(this, "removeRetentionPolicy", absPath);
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setRetentionPolicy(String absPath, RetentionPolicy retentionPolicy) throws PathNotFoundException,
+            AccessDeniedException, LockException, VersionException, RepositoryException {
+        log.code(this, "setRetentionPolicy", absPath, retentionPolicy);
+        // TODO Auto-generated method stub
+
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/RetentionPolicyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/RetentionPolicyImpl.java?rev=932960&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/RetentionPolicyImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/retention/RetentionPolicyImpl.java Sun Apr 11 17:54:07 2010
@@ -0,0 +1,43 @@
+/*
+ * 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.retention;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.retention.RetentionPolicy;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class RetentionPolicyImpl implements RetentionPolicy, LogObject {
+
+    private final String name;
+    private final Log log;
+
+    RetentionPolicyImpl(String name, Log log) {
+        this.name = name;
+        this.log = log;
+    }
+
+    public String getName() throws RepositoryException {
+        log.code(this, "getName");
+        // TODO Auto-generated method stub
+        return name;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlEntryImpl.java?rev=932960&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlEntryImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlEntryImpl.java Sun Apr 11 17:54:07 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.security;
+
+import java.security.Principal;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.Privilege;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class AccessControlEntryImpl implements AccessControlEntry, LogObject {
+
+    private final Principal principal;
+    private final Privilege[] privileges;
+    private final Log log;
+
+    AccessControlEntryImpl(Principal principal, Privilege[] privileges, Log log) {
+        this.principal = principal;
+        this.privileges = privileges;
+        this.log = log;
+    }
+
+    public Principal getPrincipal() {
+        log.code(this, "getPrincipal");
+        return principal;
+    }
+
+    public Privilege[] getPrivileges() {
+        log.code(this, "getPrivileges");
+        // TODO this array is mutable - is this a problem?
+        return privileges;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlListImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlListImpl.java?rev=932960&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlListImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlListImpl.java Sun Apr 11 17:54:07 2010
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import javax.jcr.RepositoryException;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.AccessControlException;
+import javax.jcr.security.AccessControlList;
+import javax.jcr.security.Privilege;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class AccessControlListImpl implements AccessControlList, LogObject {
+
+    private final ArrayList<AccessControlEntry> entries = new ArrayList<AccessControlEntry>();
+    private final Log log;
+
+    AccessControlListImpl(Log log) {
+        this.log = log;
+    }
+
+    public boolean addAccessControlEntry(Principal principal, Privilege[] privileges) throws AccessControlException,
+            RepositoryException {
+        log.code(this, "addAccessControlEntry", principal, privileges);
+        entries.add(new AccessControlEntryImpl(principal, privileges, log));
+        return true;
+    }
+
+    public AccessControlEntry[] getAccessControlEntries() throws RepositoryException {
+        log.code(this, "getAccessControlEntries");
+        return entries.toArray(new AccessControlEntry[entries.size()]);
+    }
+
+    public void removeAccessControlEntry(AccessControlEntry ace) throws AccessControlException, RepositoryException {
+        log.code(this, "removeAccessControlEntry", ace);
+        entries.remove(ace);
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlManagerImpl.java?rev=932960&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlManagerImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/AccessControlManagerImpl.java Sun Apr 11 17:54:07 2010
@@ -0,0 +1,128 @@
+/*
+ * 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;
+
+import java.util.Collection;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
+import javax.jcr.security.AccessControlException;
+import javax.jcr.security.AccessControlManager;
+import javax.jcr.security.AccessControlPolicy;
+import javax.jcr.security.AccessControlPolicyIterator;
+import javax.jcr.security.Privilege;
+import javax.jcr.version.VersionException;
+import org.apache.jackrabbit.j3.RangeIteratorImpl;
+import org.apache.jackrabbit.j3.SessionImpl;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class AccessControlManagerImpl implements AccessControlManager, LogObject {
+
+    private final SessionImpl session;
+    private final Log log;
+
+    public AccessControlManagerImpl(SessionImpl session) {
+        this.session = session;
+        this.log = session.getLog();
+    }
+
+    public AccessControlPolicyIterator getApplicablePolicies(String absPath) throws PathNotFoundException,
+            AccessDeniedException, RepositoryException {
+        log.code(this, "getApplicablePolicies", absPath);
+        // TODO
+        return null;
+    }
+
+    public AccessControlPolicy[] getEffectivePolicies(String absPath) throws PathNotFoundException,
+            AccessDeniedException, RepositoryException {
+        log.code(this, "getEffectivePolicies", absPath);
+        // TODO
+        return null;
+    }
+
+    public AccessControlPolicy[] getPolicies(String absPath) throws PathNotFoundException, AccessDeniedException,
+            RepositoryException {
+        log.code(this, "getPolicies", absPath);
+        // TODO
+        return null;
+    }
+
+    public Privilege[] getPrivileges(String absPath) throws PathNotFoundException, RepositoryException {
+        log.code(this, "getPrivileges", absPath);
+        // TODO
+        return null;
+    }
+
+    public Privilege[] getSupportedPrivileges(String absPath) throws PathNotFoundException, RepositoryException {
+        log.code(this, "getSupportedPrivileges", absPath);
+        // TODO
+        return null;
+    }
+
+    public boolean hasPrivileges(String absPath, Privilege[] privileges) throws PathNotFoundException,
+            RepositoryException {
+        log.code(this, "hasPrivileges", absPath, privileges);
+        // TODO
+        return false;
+    }
+
+    public PrivilegeImpl privilegeFromName(String privilegeName) throws AccessControlException, RepositoryException {
+        PrivilegeImpl p = PrivilegeImpl.get(session.parseName(privilegeName));
+        if (p == null) {
+            throw ExceptionFactory.accessControl("Privilege not found: {0}", privilegeName);
+        }
+        log.codeAssign(p, this, "privilegeFromName", privilegeName);
+        return p;
+    }
+
+    public void removePolicy(String absPath, AccessControlPolicy policy) throws PathNotFoundException,
+            AccessControlException, AccessDeniedException, LockException, VersionException, RepositoryException {
+        log.code(this, "removePolicy", absPath, policy);
+        // TODO
+
+    }
+
+    public void setPolicy(String absPath, AccessControlPolicy policy) throws PathNotFoundException,
+            AccessControlException, AccessDeniedException, LockException, VersionException, RepositoryException {
+        log.code(this, "setPolicy", absPath, policy);
+        // TODO
+
+    }
+
+    /**
+     * An AccessControlPolicyIterator implementation.
+     */
+    static class AccessControlPolicyIteratorImpl extends RangeIteratorImpl<AccessControlListImpl> implements AccessControlPolicyIterator  {
+
+        AccessControlPolicyIteratorImpl(Collection<AccessControlListImpl> coll, Log log) {
+            super(coll.iterator(), coll.size(), log);
+        }
+
+        public AccessControlPolicy nextAccessControlPolicy() {
+            log.code(this, "nextAccessControlPolicy");
+            return goNext();
+        }
+
+    }
+
+}

Modified: 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=932960&r1=932959&r2=932960&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/PrivilegeImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/security/PrivilegeImpl.java Sun Apr 11 17:54:07 2010
@@ -16,10 +16,18 @@
  */
 package org.apache.jackrabbit.j3.security;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import javax.jcr.security.Privilege;
+import org.apache.jackrabbit.j3.NamespaceRegistryImpl;
+import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.LogObject;
+
 /**
- * A privilege implementation.
+ * The implementation of the corresponding JCR interface.
  */
-public class PrivilegeImpl {
+public class PrivilegeImpl implements Privilege, LogObject {
 
     public static final int ADD_CHILD_NODES = 1;
     public static final int LIFECYCLE_MANAGEMENT = 2;
@@ -33,7 +41,6 @@ public class PrivilegeImpl {
     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 |
@@ -42,4 +49,125 @@ public class PrivilegeImpl {
             MODIFY_ACCESS_CONTROL | LOCK_MANAGEMENT |
             VERSION_MANAGEMENT | NODE_TYPE_MANAGEMENT |
             RETENTION_MANAGEMENT | LIFECYCLE_MANAGEMENT;
+
+    private static final HashMap<Integer, PrivilegeImpl> PRIVILEGE_TYPE_MAP = new HashMap<Integer, PrivilegeImpl>();
+    private static final HashMap<Val, PrivilegeImpl> PRIVILEGE_NAME_MAP = new HashMap<Val, PrivilegeImpl>();
+
+    private final int type;
+    private final String name;
+    private final PrivilegeImpl[] aggregatePrivileges;
+    private final PrivilegeImpl[] declaredAggregatePrivileges;
+
+    static {
+        NamespaceRegistryImpl nsReg = NamespaceRegistryImpl.BUILT_IN;
+        addPrivilege(nsReg, JCR_ADD_CHILD_NODES, ADD_CHILD_NODES);
+        addPrivilege(nsReg, JCR_LIFECYCLE_MANAGEMENT, LIFECYCLE_MANAGEMENT);
+        addPrivilege(nsReg, JCR_LOCK_MANAGEMENT, LOCK_MANAGEMENT);
+        addPrivilege(nsReg, JCR_MODIFY_ACCESS_CONTROL, MODIFY_ACCESS_CONTROL);
+        addPrivilege(nsReg, JCR_MODIFY_PROPERTIES, MODIFY_PROPERTIES);
+        addPrivilege(nsReg, JCR_NODE_TYPE_MANAGEMENT, NODE_TYPE_MANAGEMENT);
+        addPrivilege(nsReg, JCR_READ, READ);
+        addPrivilege(nsReg, JCR_READ_ACCESS_CONTROL, READ_ACCESS_CONTROL);
+        addPrivilege(nsReg, JCR_REMOVE_CHILD_NODES, REMOVE_CHILD_NODES);
+        addPrivilege(nsReg, JCR_REMOVE_NODE, REMOVE_NODE);
+        addPrivilege(nsReg, JCR_RETENTION_MANAGEMENT, RETENTION_MANAGEMENT);
+        addPrivilege(nsReg, JCR_VERSION_MANAGEMENT, VERSION_MANAGEMENT);
+        addPrivilege(nsReg, JCR_WRITE, WRITE,
+                MODIFY_PROPERTIES, ADD_CHILD_NODES, REMOVE_NODE, REMOVE_CHILD_NODES);
+        addPrivilege(nsReg, JCR_ALL, ALL,
+                READ, WRITE, READ_ACCESS_CONTROL,
+                MODIFY_ACCESS_CONTROL, LOCK_MANAGEMENT,
+                VERSION_MANAGEMENT, NODE_TYPE_MANAGEMENT,
+                RETENTION_MANAGEMENT, LIFECYCLE_MANAGEMENT);
+    };
+
+    static void addPrivilege(NamespaceRegistryImpl nsReg, String name, int type, int... aggregates) {
+        Val n = nsReg.parseName(name);
+        String qualifiedName = nsReg.nameToString(n);
+        PrivilegeImpl[] aggregatePrivileges;
+        PrivilegeImpl[] declaredAggregatePrivileges;
+        if (aggregates != null && aggregates.length > 0) {
+            ArrayList<PrivilegeImpl> declaredAgg = new ArrayList<PrivilegeImpl>();
+            ArrayList<PrivilegeImpl> allAgg = new ArrayList<PrivilegeImpl>();
+            for (int i : aggregates) {
+                PrivilegeImpl p = PRIVILEGE_TYPE_MAP.get(i);
+                declaredAgg.add(p);
+                if (p.getAggregatePrivileges() != null) {
+                    allAgg.addAll(Arrays.asList(p.getAggregatePrivileges()));
+                } else {
+                    allAgg.add(p);
+                }
+            }
+            declaredAggregatePrivileges = declaredAgg.toArray(new PrivilegeImpl[declaredAgg.size()]);
+            aggregatePrivileges = allAgg.toArray(new PrivilegeImpl[allAgg.size()]);
+        } else {
+            aggregatePrivileges = null;
+            declaredAggregatePrivileges = null;
+        }
+        PrivilegeImpl p = new PrivilegeImpl(type, qualifiedName, aggregatePrivileges, declaredAggregatePrivileges);
+        PRIVILEGE_TYPE_MAP.put(type, p);
+        PRIVILEGE_NAME_MAP.put(n, p);
+    }
+
+    private PrivilegeImpl(int type, String name, PrivilegeImpl[] aggregatePrivileges, PrivilegeImpl[] declaredAggregatePrivileges) {
+        this.type = type;
+        this.name = name;
+        this.aggregatePrivileges = aggregatePrivileges;
+        this.declaredAggregatePrivileges = declaredAggregatePrivileges;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    public static int getPrivilege(String action) {
+        int privilege = 0, index;
+        do {
+            index = action.indexOf(',');
+            String token;
+            if (index < 0) {
+                token = action;
+            } else {
+                token = action.substring(0, index);
+                action = action.substring(index + 1);
+            }
+            if (token.equals("add_node")) {
+                privilege |= ADD_CHILD_NODES;
+            } else if (token.equals("set_property")) {
+                privilege |= MODIFY_PROPERTIES;
+            } else if (token.equals("remove")) {
+                privilege |= REMOVE_NODE | MODIFY_PROPERTIES;
+            } else if (token.equals("read")) {
+                privilege |= READ;
+            }
+        } while (index > 0);
+        return privilege;
+    }
+
+    public PrivilegeImpl[] getAggregatePrivileges() {
+        // TODO the array is mutable
+        return aggregatePrivileges;
+    }
+
+    public PrivilegeImpl[] getDeclaredAggregatePrivileges() {
+        // TODO the array is mutable
+        return declaredAggregatePrivileges;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public boolean isAbstract() {
+        return false;
+    }
+
+    public boolean isAggregate() {
+        return aggregatePrivileges != null;
+    }
+
+    static PrivilegeImpl get(Val privilegeName) {
+        return PRIVILEGE_NAME_MAP.get(privilegeName);
+    }
+
 }



Mime
View raw message