directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10197 - in incubator/directory/rms/trunk/je/src: java/org/apache/rms/je/permissions test/org/apache/rms/je/permissions
Date Fri, 23 Apr 2004 18:40:22 GMT
Author: akarasulu
Date: Fri Apr 23 11:40:21 2004
New Revision: 10197

Added:
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/BitPermissionIndexDAOMonitor.java   (contents, props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/BitPermissionIndexDAOMonitorAdapter.java   (contents, props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/LoggingBitPermissionIndexDAOMonitor.java   (contents, props changed)
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/JeBitPermissionFactoryTest.java   (contents, props changed)
Modified:
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/BitPermissionIndexDAO.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionFactory.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexDAO.java
Log:
Commit changes ...
 
 o added the bit permission index factory test case (not complete)
 o added the bit permission index DAO's monitor interface
 o added the bit permission index DAO's NULL monitor implementation
 o added the bit permission index DAO's logging monitor implementation 



Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/BitPermissionIndexDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/BitPermissionIndexDAO.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/BitPermissionIndexDAO.java	Fri Apr 23 11:40:21 2004
@@ -57,7 +57,6 @@
      * @param appName the name of the application
      * @param index the index of the permission
      * @throws RmsException if there are problems accessing the tuple database
-     * or the entry does not exist
      */
     boolean has( String appName, int index ) throws RmsException ;
 
@@ -87,6 +86,7 @@
      * @param appName the name of the application
      * @return the first occupied index for the application
      * @throws RmsException if there are problems accessing the backing store
+     * @throws java.util.NoSuchElementException if no indices exist
      */
     int getFirst( String appName ) throws RmsException ;
 
@@ -96,6 +96,7 @@
      * @param appName the name of the application
      * @return the last occupied index for the application
      * @throws RmsException if there are problems accessing the backing store
+     * @throws java.util.NoSuchElementException if no indices exist
      */
     int getLast( String appName ) throws RmsException ;
 }

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/BitPermissionIndexDAOMonitor.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/BitPermissionIndexDAOMonitor.java	Fri Apr 23 11:40:21 2004
@@ -0,0 +1,249 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.rms.je.permissions ;
+
+
+import org.apache.commons.collections.primitives.IntIterator ;
+
+
+/**
+ * Monitors notable BitPermissionIndexDAO events.  This interface is intended
+ * for any kind of BitPermissionIndexDAO implementation.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface BitPermissionIndexDAOMonitor
+{
+    /**
+     * Monitors failures to put an index entry for an application into the
+     * BitPermission index mapping database.
+     *
+     * @param dao the data access object that failed
+     * @param appName the name of the application the new index was for
+     * @param index the new bit permission index being added
+     * @param info additional implementation specific operation info
+     */
+    void putFailure( BitPermissionIndexDAO dao, Object info, String appName,
+                     int index ) ;
+
+    /**
+     * Monitors failures to put an index entry for an application into the
+     * BitPermission index mapping database.
+     *
+     * @param dao the data access object that failed
+     * @param appName the name of the application the new index was for
+     * @param index the new bit permission index being added
+     * @param fault the fault that caused the failure
+     */
+    void putFailure( BitPermissionIndexDAO dao, String appName, int index,
+                     Throwable fault ) ;
+
+    /**
+     * Monitors failures to delete an index entry.
+     *
+     * @param dao the data access object that failed a delete operation
+     * @param info additional implementation specific operation info
+     * @param appName the name of the application associated with the index
+     * @param index the bit permission index that failed deletion
+     */
+    void deleteFailure( BitPermissionIndexDAO dao, Object info,
+                        String appName, int index ) ;
+
+    /**
+     * Monitors failures to delete an index entry.
+     *
+     * @param dao the data access object that failed a delete operation
+     * @param appName the name of the application associated with the index
+     * @param index the bit permission index that failed deletion
+     * @param fault the fault that caused the failure
+     */
+    void deleteFailure( BitPermissionIndexDAO dao, String appName, int index,
+                        Throwable fault ) ;
+
+    /**
+     * Monitors failures to delte a non-existant index entry.
+     *
+     * @param dao the data access object that failed a delete operation
+     * @param appName the name of the application associated with the index
+     * @param index the bit permission index that failed deletion
+     */
+    void nothingToDelete( JeBitPermissionIndexDAO dao, String appName,
+                          int index ) ;
+
+    /**
+     * Monitors failures to lookup the presence of an index for an
+     * application
+     *
+     * @param dao the data access object that failed a list operation
+     * @param appName the name of the application associated with the index
+     * @param index the bit permission index that failed lookup
+     * @param fault the fault that caused the failure
+     */
+    void lookupFailure( BitPermissionIndexDAO dao, String appName,
+                        int index, Throwable fault ) ;
+
+    /**
+     * Monitors the failure to close an index iterator or some other
+     * resource that must be released usign a close() operation.
+     *
+     * @param dao the data access object that failed a list operation
+     * @param o the object the close was attempted on
+     * @param fault the fault that caused the failure
+     */
+    void closeFailure( BitPermissionIndexDAO dao, Object o, Throwable fault ) ;
+
+    /**
+     * Monitors the failures while trying to list the permission indices of an
+     * application.
+     *
+     * @param dao the data access object that failed a list operation
+     * @param appName the name of the application
+     * @param fault the fault that caused the failure
+     */
+    void listFailure( BitPermissionIndexDAO dao, String appName,
+                      Throwable fault ) ;
+
+    /**
+     * Monitors when getFirst is called to get the last bit perission index
+     * when no permissions exist for the application.
+     *
+     * @param dao the data access object that failed a getFirst operation
+     * @param appName the name of the application associated with the index
+     */
+    void noFirstElement( BitPermissionIndexDAO dao, String appName ) ;
+
+    /**
+     * Monitors failures to get the first index of an application's bit
+     * permission.
+     *
+     * @param dao the data access object that failed a getFirst operation
+     * @param appName the name of the application
+     * @param fault the fault that caused the failure
+     */
+    void getFirstFailure( BitPermissionIndexDAO dao, String appName,
+                          Throwable fault ) ;
+
+    /**
+     * Monitors when getLast is called to get the last bit perission index
+     * when no permissions exist for the application.
+     *
+     * @param dao the data access object that failed a getLast operation
+     * @param appName the name of the application associated with the index
+     */
+    void noLastElement( BitPermissionIndexDAO dao, String appName ) ;
+
+    /**
+     * Monitors failures to get the last index of an application's bit
+     * permission.
+     *
+     * @param dao the data access object that failed a getLast operation
+     * @param appName the name of the application
+     * @param fault the fault that caused the failure
+     */
+    void getLastFailure( BitPermissionIndexDAO dao, String appName,
+                         Throwable fault ) ;
+
+    /**
+     * Monitors when a list is exhausted.
+     *
+     * @param dao the data access object that created the list
+     * @param list the list of indices that was exhausted
+     */
+    void listExhausted( BitPermissionIndexDAO dao,
+                        IntIterator list ) ;
+
+    /**
+     * Monitors when a list.next() is sucessfully called.
+     *
+     * @param dao the data access object that created the list
+     * @param list the list of indices
+     * @param retVal the next index value to return
+     */
+    void listNextSuccess( BitPermissionIndexDAO dao,
+                          IntIterator list, int retVal ) ;
+
+    /**
+     * Monitors when some closable or freeble resource was closed or released.
+     *
+     * @param dao the data access object that closes the resource
+     * @param resource the resource being closed or released
+     */
+    void closeSuccess( BitPermissionIndexDAO dao, Object resource ) ;
+
+    /**
+     * Monitors the successful lookup of the last index for an application.
+     *
+     * @param dao the data access object that performed the getLast operation
+     * @param appName the name of the application
+     * @param index the last index to be returned
+     */
+    void getLastSuccess( BitPermissionIndexDAO dao, String appName,
+                         int index ) ;
+
+    /**
+     * Monitors the successful lookup of the first index for an application.
+     *
+     * @param dao the data access object that performed the getFirst operation
+     * @param appName the name of the application
+     * @param index the first index to be returned
+     */
+    void getFirstSuccess( BitPermissionIndexDAO dao, String appName,
+                         int index ) ;
+
+    /**
+     * Monitors the successful start of an index listing.
+     *
+     * @param dao the data access object that performed the list operation
+     * @param appName the name of the application
+     * @param list the newly created index listing
+     */
+    void listSuccess( BitPermissionIndexDAO dao, String appName,
+                      IntIterator list ) ;
+
+    /**
+     * Monitors the successful lookup of an index which may mean the index
+     * was found or not found - both are a success.
+     *
+     * @param dao the data access object that performed the has operation
+     * @param appName the name of the application
+     * @param index the index being checked for existance
+     * @param exists the return value which is true if the index exists for
+     * the application false otherwise
+     */
+    void lookupSuccess( BitPermissionIndexDAO dao, String appName, int index,
+                        boolean exists ) ;
+
+    /**
+     * Monitors the successful deletion of an index entry.
+     *
+     * @param dao the data access object that permformed the delete operation
+     * @param appName the name of the application
+     * @param index the index that was deleted for the application
+     */
+    void deleteSuccess( BitPermissionIndexDAO dao, String appName,
+                        int index ) ;
+
+    /**
+     * Monitors the successful put of an index entry.
+     *
+     * @param dao the data access object that permformed the put operation
+     * @param appName the name of the application
+     * @param index the index that was added to the application
+     */
+    void putSuccess( BitPermissionIndexDAO dao, String appName, int index ) ;
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/BitPermissionIndexDAOMonitorAdapter.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/BitPermissionIndexDAOMonitorAdapter.java	Fri Apr 23 11:40:21 2004
@@ -0,0 +1,325 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.rms.je.permissions ;
+
+
+import org.apache.commons.collections.primitives.IntIterator ;
+
+
+/**
+ * A do nothing monitor for BitPermissionIndex data access objects.  This
+ * monitor will be cautious with exceptions and dump them to stderr as a
+ * bare minimum.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BitPermissionIndexDAOMonitorAdapter
+        implements BitPermissionIndexDAOMonitor
+{
+    /**
+     * Monitors failures to put an index entry for an application into the
+     * BitPermission index mapping database.
+     *
+     * @param dao     the data access object that failed
+     * @param appName the name of the application the new index was for
+     * @param index   the new bit permission index being added
+     * @param info    additional implementation specific operation info
+     */
+    public void putFailure( BitPermissionIndexDAO dao, Object info,
+                            String appName, int index )
+    {
+    }
+
+
+    /**
+     * Monitors failures to put an index entry for an application into the
+     * BitPermission index mapping database.
+     *
+     * @param dao     the data access object that failed
+     * @param appName the name of the application the new index was for
+     * @param index   the new bit permission index being added
+     * @param fault   the fault that caused the failure
+     */
+    public void putFailure( BitPermissionIndexDAO dao, String appName,
+                            int index, Throwable fault )
+    {
+        fault.printStackTrace() ;
+    }
+
+
+    /**
+     * Monitors failures to delete an index entry.
+     *
+     * @param dao     the data access object that failed a delete operation
+     * @param info    additional implementation specific operation info
+     * @param appName the name of the application associated with the index
+     * @param index   the bit permission index that failed deletion
+     */
+    public void deleteFailure( BitPermissionIndexDAO dao, Object info,
+                               String appName, int index )
+    {
+    }
+
+
+    /**
+     * Monitors failures to delete an index entry.
+     *
+     * @param dao     the data access object that failed a delete operation
+     * @param appName the name of the application associated with the index
+     * @param index   the bit permission index that failed deletion
+     * @param fault   the fault that caused the failure
+     */
+    public void deleteFailure( BitPermissionIndexDAO dao, String appName,
+                               int index, Throwable fault )
+    {
+        fault.printStackTrace() ;
+    }
+
+
+    /**
+     * Monitors failures to delte a non-existant index entry.
+     *
+     * @param dao     the data access object that failed a delete operation
+     * @param appName the name of the application associated with the index
+     * @param index   the bit permission index that failed deletion
+     */
+    public void nothingToDelete( JeBitPermissionIndexDAO dao, String appName,
+                                 int index )
+    {
+    }
+
+
+    /**
+     * Monitors failures to lookup the presence of an index for an application
+     *
+     * @param dao     the data access object that failed a list operation
+     * @param appName the name of the application associated with the index
+     * @param index   the bit permission index that failed lookup
+     * @param fault   the fault that caused the failure
+     */
+    public void lookupFailure( BitPermissionIndexDAO dao, String appName,
+                               int index, Throwable fault )
+    {
+        fault.printStackTrace() ;
+    }
+
+
+    /**
+     * Monitors the failure to close an index iterator or some other resource
+     * that must be released usign a close() operation.
+     *
+     * @param dao   the data access object that failed a list operation
+     * @param o     the object the close was attempted on
+     * @param fault the fault that caused the failure
+     */
+    public void closeFailure( BitPermissionIndexDAO dao, Object o,
+                              Throwable fault )
+    {
+        fault.printStackTrace() ;
+    }
+
+
+    /**
+     * Monitors the failures while trying to list the permission indices of
+     * an application.
+     *
+     * @param dao     the data access object that failed a list operation
+     * @param appName the name of the application
+     * @param fault   the fault that caused the failure
+     */
+    public void listFailure( BitPermissionIndexDAO dao, String appName,
+                             Throwable fault )
+    {
+        fault.printStackTrace() ;
+    }
+
+
+    /**
+     * Monitors when getFirst is called to get the last bit perission index
+     * when no permissions exist for the application.
+     *
+     * @param dao     the data access object that failed a getFirst operation
+     * @param appName the name of the application associated with the index
+     */
+    public void noFirstElement( BitPermissionIndexDAO dao, String appName )
+    {
+    }
+
+
+    /**
+     * Monitors failures to get the first index of an application's bit
+     * permission.
+     *
+     * @param dao     the data access object that failed a getFirst operation
+     * @param appName the name of the application
+     * @param fault   the fault that caused the failure
+     */
+    public void getFirstFailure( BitPermissionIndexDAO dao, String appName,
+                                 Throwable fault )
+    {
+        fault.printStackTrace() ;
+    }
+
+
+    /**
+     * Monitors when getLast is called to get the last bit perission index when
+     * no permissions exist for the
+     * application.
+     *
+     * @param dao     the data access object that failed a getLast operation
+     * @param appName the name of the application associated with the index
+     */
+    public void noLastElement( BitPermissionIndexDAO dao, String appName )
+    {
+    }
+
+
+    /**
+     * Monitors failures to get the last index of an application's bit
+     * permission.
+     *
+     * @param dao     the data access object that failed a getLast operation
+     * @param appName the name of the application
+     * @param fault   the fault that caused the failure
+     */
+    public void getLastFailure( BitPermissionIndexDAO dao, String appName,
+                                Throwable fault )
+    {
+        fault.printStackTrace() ;
+    }
+
+
+    /**
+     * Monitors when a list is exhausted.
+     *
+     * @param dao  the data access object that created the list
+     * @param list the list of indices that was exhausted
+     */
+    public void listExhausted( BitPermissionIndexDAO dao, IntIterator list )
+    {
+    }
+
+
+    /**
+     * Monitors when a list.next() is sucessfully called.
+     *
+     * @param dao    the data access object that created the list
+     * @param list   the list of indices
+     * @param retVal the next index value to return
+     */
+    public void listNextSuccess( BitPermissionIndexDAO dao, IntIterator list,
+                                 int retVal )
+    {
+    }
+
+
+    /**
+     * Monitors when some closable or freeble resource was closed or released.
+     *
+     * @param dao      the data access object that closes the resource
+     * @param resource the resource being closed or released
+     */
+    public void closeSuccess( BitPermissionIndexDAO dao, Object resource )
+    {
+    }
+
+
+    /**
+     * Monitors the successful lookup of the last index for an application.
+     *
+     * @param dao     the data access object that performed the getLast
+     *                operation
+     * @param appName the name of the application
+     * @param index   the last index to be returned
+     */
+    public void getLastSuccess( BitPermissionIndexDAO dao, String appName,
+                                int index )
+    {
+    }
+
+
+    /**
+     * Monitors the successful lookup of the first index for an application.
+     *
+     * @param dao     the data access object that performed the getFirst
+     *                operation
+     * @param appName the name of the application
+     * @param index   the first index to be returned
+     */
+    public void getFirstSuccess( BitPermissionIndexDAO dao, String appName,
+                                 int index )
+    {
+    }
+
+
+    /**
+     * Monitors the successful start of an index listing.
+     *
+     * @param dao     the data access object that performed the list operation
+     * @param appName the name of the application
+     * @param list    the newly created index listing
+     */
+    public void listSuccess( BitPermissionIndexDAO dao, String appName,
+                             IntIterator list )
+    {
+    }
+
+
+    /**
+     * Monitors the successful lookup of an index which may mean the index was
+     * found or not found - both are a success.
+     *
+     * @param dao     the data access object that performed the has operation
+     * @param appName the name of the application
+     * @param index   the index being checked for existance
+     * @param exists  the return value which is true if the index exists for the
+     *                application false otherwise
+     */
+    public void lookupSuccess( BitPermissionIndexDAO dao, String appName,
+                               int index, boolean exists )
+    {
+    }
+
+
+    /**
+     * Monitors the successful deletion of an index entry.
+     *
+     * @param dao     the data access object that permformed the delete
+     *                operation
+     * @param appName the name of the application
+     * @param index   the index that was deleted for the application
+     */
+    public void deleteSuccess( BitPermissionIndexDAO dao, String appName,
+                               int index )
+    {
+    }
+
+
+    /**
+     * Monitors the successful put of an index entry.
+     *
+     * @param dao     the data access object that permformed the put
+     *                operation
+     * @param appName the name of the application
+     * @param index   the index that was added to the application
+     */
+    public void putSuccess( BitPermissionIndexDAO dao, String appName,
+                            int index )
+    {
+    }
+}

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionFactory.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionFactory.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionFactory.java	Fri Apr 23 11:40:21 2004
@@ -19,17 +19,15 @@
 
 import org.apache.rms.RmsException ;
 import org.apache.rms.BitPermission ;
-import org.apache.rms.je.sequence.Sequence;
-import org.apache.rms.je.sequence.Sequence;
 import org.apache.rms.spi.PermissionFactory ;
 
 import org.apache.commons.lang.Validate ;
-import org.apache.commons.lang.NotImplementedException ;
+import org.apache.commons.collections.Factory ;
+import org.apache.commons.collections.list.LazyList ;
+import org.apache.commons.collections.primitives.IntIterator ;
 
 import java.util.List ;
-
-import com.sleepycat.je.Database ;
-import com.sleepycat.je.SecondaryDatabase;
+import java.util.ArrayList ;
 
 
 /**
@@ -40,61 +38,66 @@
  */
 public class JeBitPermissionFactory implements PermissionFactory
 {
-    /** the JE database to use for this factory */
-    private final Database db ;
-    /** the sequence we use to create new permission row ids with */
-    private final Sequence seq ;
-    /** the secondary database used to index permissions by vector indices */
-    private final SecondaryDatabase byIdx ;
-    /** the secondary database used to index permission by name */
-    private final SecondaryDatabase byName ;
-    /** the secondary database used to index permission by app name */
-    private final SecondaryDatabase byApp ;
+    /** Null returning factory instance */
+    public static final Factory NULL_FACTORY = new Factory() {
+        public Object create() { return null ; } } ;
+
+    /** A bit permission database Data Access Object */
+    private BitPermissionDAO permDAO = null ;
+    /** A bit permission index mapping database Data Access Object */
+    private JeBitPermissionIndexDAO indexDAO = null ;
 
 
     /**
      * Creates a JE based permission factory using a JE database.
      *
-     * @param db the JE Database for the permission factory
+     * @param permDAO the JE Database bit permission data access object
+     * @param indexDAO the JE Database bit permission to index mapping DAO
      */
-    JeBitPermissionFactory( Database db, Sequence seq, SecondaryDatabase idx,
-                   SecondaryDatabase name, SecondaryDatabase app )
+    JeBitPermissionFactory( JeBitPermissionDAO permDAO, JeBitPermissionIndexDAO indexDAO )
     {
-        Validate.notNull( db ) ;
-        Validate.notNull( seq ) ;
-        Validate.notNull( app ) ;
-        Validate.notNull( idx ) ;
-        Validate.notNull( name ) ;
-
-        this.db = db ;
-        this.seq = seq ;
-        this.byApp = app ;
-        this.byIdx = idx ;
-        this.byName = name ;
+        Validate.notNull( permDAO ) ;
+        Validate.notNull( indexDAO ) ;
+        
+        this.permDAO = permDAO ;
+        this.indexDAO = indexDAO ;
     }
 
 
     public List getPermissionsMap( String appName ) throws RmsException
     {
-        throw new NotImplementedException( "STUB" ) ;
+        List list = LazyList.decorate( new ArrayList(), NULL_FACTORY ) ;
+        IntIterator indices = indexDAO.list( appName ) ;
+
+        while( indices.hasNext() )
+        {
+            int index = indices.next() ;
+            BitPermission perm = permDAO.getPermission( appName, index ) ;
+            list.get( index ) ;  // makes the list grow
+            list.set( index, perm ) ;
+        }
+
+        return list ;
     }
 
 
     public BitPermission create( String appName, String permName ) throws RmsException
     {
-        throw new NotImplementedException( "STUB" ) ;
+        int index = permDAO.create( appName, permName ) ;
+        return new JeBitPermission( permName, index, appName ) ;
     }
 
 
     public void delete( String appName, String permName ) throws RmsException
     {
-        throw new NotImplementedException( "STUB" ) ;
+        permDAO.delete( appName, permName ) ;
     }
 
 
-    public void rename( String appName, String oldPermName, String newPermName ) throws RmsException
+    public void rename( String appName, String oldPermName,
+                        String newPermName ) throws RmsException
     {
-        throw new NotImplementedException( "STUB" ) ;
+        permDAO.rename( appName, oldPermName, newPermName ) ;
     }
 }
 

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexDAO.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexDAO.java	Fri Apr 23 11:40:21 2004
@@ -38,10 +38,18 @@
 {
     /** the JE database this DAO is designed for */
     private final Database db ;
+    /** monitor for notable DAO events */
+    private BitPermissionIndexDAOMonitor monitor ;
+
+
+    // -----------------------------------------------------------------------
+    // C O N S T R U C T O R S
+    // -----------------------------------------------------------------------
 
 
     /**
-     * Creates a DAO wrapper around the permission index database.
+     * Creates a DAO wrapper around the permission index database and uses the
+     * default monitor adapter.
      *
      * @param db the permission index JE database
      * @throws RmsException if the db does not allow duplicates
@@ -61,9 +69,15 @@
         }
 
         this.db = db ;
+        this.monitor = new BitPermissionIndexDAOMonitorAdapter() ;
     }
 
 
+    // -----------------------------------------------------------------------
+    // BitPermissionIndexDAO Methods
+    // -----------------------------------------------------------------------
+
+
     /**
      * Puts a new record of an index being used into the database.
      *
@@ -87,6 +101,7 @@
 
             if ( status != OperationStatus.SUCCESS )
             {
+                monitor.putFailure( this, status, appName, index ) ;
                 throw new RmsException( "Put of index entry " +
                         index + " for application named " + appName
                         + " failed with a status of " + status.toString() ) ;
@@ -94,12 +109,16 @@
         }
         catch ( UnsupportedEncodingException e )
         {
+            monitor.putFailure( this, appName, index, e ) ;
             throw new RmsException( e ) ;
         }
         catch ( DatabaseException e )
         {
+            monitor.putFailure( this, appName, index, e ) ;
             throw new RmsException( e ) ;
         }
+
+        monitor.putSuccess( this, appName, index ) ;
     }
 
 
@@ -131,34 +150,35 @@
 
                 if ( status != OperationStatus.SUCCESS )
                 {
+                    monitor.deleteFailure( this, status, appName, index ) ;
                     throw new RmsException(
                             "Delete operation failed with status "
                             + status.toString() ) ;
                 }
             }
+            else
+            {
+                monitor.nothingToDelete( this, appName, index ) ;
+                throw new RmsException( "Could not find index " + index
+                    + " for application " + appName + " to delete." ) ;
+            }
         }
         catch ( UnsupportedEncodingException e )
         {
+            monitor.deleteFailure( this, appName, index, e ) ;
             throw new RmsException( e ) ;
         }
         catch ( DatabaseException e )
         {
+            monitor.deleteFailure( this, appName, index, e ) ;
             throw new RmsException( e ) ;
         }
         finally
         {
-            if ( cursor != null )
-            {
-                try
-                {
-                    cursor.close() ;
-                }
-                catch ( DatabaseException e )
-                {
-                    throw new RmsException( e ) ;
-                }
-            }
+            closeNoError( cursor ) ;
         }
+
+        monitor.deleteSuccess( this, appName, index ) ;
     }
 
 
@@ -169,7 +189,7 @@
      * @param appName the name of the application
      * @param index   the index of the permission
      * @throws org.apache.rms.RmsException if there are problems accessing
-     * the tuple database or the entry does not exist
+     * the tuple database
      */
     public boolean has( String appName, int index ) throws RmsException
     {
@@ -187,33 +207,27 @@
         }
         catch ( UnsupportedEncodingException e )
         {
+            monitor.lookupFailure( this, appName, index, e ) ;
             throw new RmsException( e ) ;
         }
         catch ( DatabaseException e )
         {
+            monitor.lookupFailure( this, appName, index, e ) ;
             throw new RmsException( e ) ;
         }
         finally
         {
-            if ( cursor != null )
-            {
-                try
-                {
-                    cursor.close() ;
-                }
-                catch ( DatabaseException e )
-                {
-                    throw new RmsException( e ) ;
-                }
-            }
+            closeNoError( cursor ) ;
         }
 
         if ( status == OperationStatus.SUCCESS )
         {
+            monitor.lookupSuccess( this, appName, index, true ) ;
             return true ;
         }
         else
         {
+            monitor.lookupSuccess( this, appName, index, false ) ;
             return false ;
         }
     }
@@ -224,18 +238,22 @@
      * by consuming the iterator.
      *
      * @param list the iterator to close the cursor of
-     * @throws org.apache.rms.RmsException if the iterator was not created by
-     * this DAO
      */
-    public void close( IntIterator list ) throws RmsException
+    public void close( IntIterator list )
     {
         if ( list instanceof IndexIterator )
         {
-            ( ( IndexIterator ) list ).close() ;
-            return ;
+            try
+            {
+                ( ( IndexIterator ) list ).close() ;
+            }
+            catch ( RmsException e )
+            {
+                monitor.closeFailure( this, list, e ) ;
+            }
         }
 
-        throw new RmsException( "Cannot close: Iterator != IndexIterator" ) ;
+        monitor.closeSuccess( this, list ) ;
     }
 
 
@@ -253,27 +271,31 @@
     {
         try
         {
-            return new IndexIterator( appName ) ;
+            IntIterator list = new IndexIterator( appName ) ;
+            monitor.listSuccess( this, appName, list ) ;
+            return list ;
         }
         catch ( DatabaseException e )
         {
+            monitor.listFailure( this, appName, e ) ;
             throw new RmsException( e ) ;
         }
         catch ( UnsupportedEncodingException e )
         {
+            monitor.listFailure( this, appName, e ) ;
             throw new RmsException( e ) ;
         }
     }
 
 
     /**
-     * Gets the first occupied index for an application or -1 if there are no
-     * permissions for the application.
+     * Gets the first occupied index for an application.
      *
      * @param appName the name of the application
      * @return the first occupied index for the application
      * @throws org.apache.rms.RmsException if there are problems accessing
      * the backing store
+     * @throws java.util.NoSuchElementException if no indices exist
      */
     public int getFirst( String appName ) throws RmsException
     {
@@ -288,6 +310,7 @@
         }
         catch ( UnsupportedEncodingException e )
         {
+            monitor.getFirstFailure( this, appName, e ) ;
             throw new RmsException( e ) ;
         }
 
@@ -300,15 +323,20 @@
         }
         catch ( DatabaseException e )
         {
+            monitor.getFirstFailure( this, appName, e ) ;
             throw new RmsException( e ) ;
         }
 
         if ( status == OperationStatus.NOTFOUND )
         {
-            return -1 ;
+            monitor.noFirstElement( this, appName ) ;
+            throw new NoSuchElementException(
+                    "There are no indices for application " + appName ) ;
         }
 
-        return JeUtils.decodeInt( value.getData() ) ;
+        int index = JeUtils.decodeInt( value.getData() ) ;
+        monitor.getFirstSuccess( this, appName, index ) ;
+        return index ;
     }
 
 
@@ -319,6 +347,7 @@
      * @param appName the name of the application
      * @return the last occupied index for the application
      * @throws org.apache.rms.RmsException if there are problems accessing the backing store
+     * @throws java.util.NoSuchElementException if no indices exist
      */
     public int getLast( String appName ) throws RmsException
     {
@@ -334,6 +363,7 @@
         }
         catch ( UnsupportedEncodingException e )
         {
+            monitor.getLastFailure( this, appName, e ) ;
             throw new RmsException( e ) ;
         }
 
@@ -348,37 +378,90 @@
         }
         catch ( DatabaseException e )
         {
+            monitor.getLastFailure( this, appName, e ) ;
             throw new RmsException( e ) ;
         }
         finally
         {
-            if ( cursor != null )
-            {
-                try
-                {
-                    cursor.close() ;
-                }
-                catch ( DatabaseException e )
-                {
-                    throw new RmsException( e ) ;
-                }
-            }
+            closeNoError( cursor ) ;
         }
 
         if ( status == OperationStatus.NOTFOUND )
         {
-            return -1 ;
+            monitor.noLastElement( this, appName ) ;
+            throw new NoSuchElementException(
+                    "There are no indices for application " + appName ) ;
+        }
+
+        int index = JeUtils.decodeInt( value.getData() ) ;
+        monitor.getLastSuccess( this, appName, index ) ;
+        return index ;
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Monitor Methods
+    // -----------------------------------------------------------------------
+
+
+    /**
+     * Gets the BitPermissionIndexDAO monitor for this DAO.
+     *
+     * @return the BitPermissionIndexDAO monitor
+     */
+    public BitPermissionIndexDAOMonitor getMonitor()
+    {
+        return monitor ;
+    }
+
+
+    /**
+     * Sets the BitPermissionIndexDAO monitor for this DAO.
+     *
+     * @param monitor the BitPermissionIndexDAO monitor to set
+     */
+    public void setMonitor( BitPermissionIndexDAOMonitor monitor )
+    {
+        this.monitor = monitor ;
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Private Utility Methods
+    // -----------------------------------------------------------------------
+
+
+    /**
+     * Closes a cursor without throwing an error.
+     */
+    private void closeNoError( Cursor cursor )
+    {
+        if ( cursor != null )
+        {
+            try
+            {
+                cursor.close() ;
+            }
+            catch ( DatabaseException e )
+            {
+                monitor.closeFailure( this, cursor, e ) ;
+            }
         }
 
-        return JeUtils.decodeInt( value.getData() ) ;
+        monitor.closeSuccess( this, cursor ) ;
     }
 
 
+    /**
+     * A special integer primitive type IntIterator over the indices in use
+     * of an application's permissions.
+     */
     class IndexIterator implements IntIterator
     {
         final Cursor cursor ;
         final DatabaseEntry key ;
         final DatabaseEntry value ;
+        final String appName ;
         boolean hasNext = true ;
         int prefetched = -1 ;
 
@@ -386,6 +469,7 @@
         IndexIterator( String appName )
                 throws DatabaseException, UnsupportedEncodingException
         {
+            this.appName = appName ;
             OperationStatus status = null ;
             value = new DatabaseEntry() ;
             key = new DatabaseEntry( appName.getBytes( "UTF-8" ) ) ;
@@ -397,6 +481,8 @@
             }
             catch( DatabaseException e )
             {
+                monitor.listFailure( JeBitPermissionIndexDAO.this,
+                        appName, e ) ;
                 hasNext = false ;
                 cursor.close() ;
                 throw e ;
@@ -430,9 +516,11 @@
             }
             catch ( DatabaseException e )
             {
+                monitor.listFailure( JeBitPermissionIndexDAO.this,
+                        appName, e ) ;
                 hasNext = false ;
                 e.printStackTrace() ;
-                try { close() ;} catch( RmsException e2 ) {}
+                closeNoError( cursor ) ;
                 throw new NoSuchElementException( "database access failure" ) ;
             }
 
@@ -444,9 +532,10 @@
             {
                 hasNext = false ;
                 prefetched = -1 ;
-                try { cursor.close() ; } catch( DatabaseException e ) {}
+                closeNoError( cursor ) ;
             }
 
+            monitor.listNextSuccess( JeBitPermissionIndexDAO.this, this, retVal ) ;
             return retVal ;
         }
 
@@ -470,6 +559,8 @@
             {
                 throw new RmsException( e ) ;
             }
+
+            monitor.listExhausted( JeBitPermissionIndexDAO.this, this ) ;
         }
     }
 }

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/LoggingBitPermissionIndexDAOMonitor.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/LoggingBitPermissionIndexDAOMonitor.java	Fri Apr 23 11:40:21 2004
@@ -0,0 +1,436 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.rms.je.permissions ;
+
+
+import org.apache.commons.collections.primitives.IntIterator ;
+
+import org.apache.commons.logging.Log ;
+import org.apache.commons.logging.LogFactory ;
+
+
+/**
+ * A logging monitor for BitPermissionIndex data access objects.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class LoggingBitPermissionIndexDAOMonitor
+        implements BitPermissionIndexDAOMonitor
+{
+    private Log log = LogFactory.getLog( "BitPermissionIndexDAO" ) ;
+
+
+    /**
+     * Monitors failures to put an index entry for an application into the
+     * BitPermission index mapping database.
+     *
+     * @param dao     the data access object that failed
+     * @param appName the name of the application the new index was for
+     * @param index   the new bit permission index being added
+     * @param info    additional implementation specific operation info
+     */
+    public void putFailure( BitPermissionIndexDAO dao, Object info,
+                            String appName, int index )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            String msg = dao + ".put(" + appName + ", " + index
+                    + ") failed: " + info.toString() ;
+            log.error( msg ) ;
+        }
+    }
+
+
+    /**
+     * Monitors failures to put an index entry for an application into the
+     * BitPermission index mapping database.
+     *
+     * @param dao     the data access object that failed
+     * @param appName the name of the application the new index was for
+     * @param index   the new bit permission index being added
+     * @param fault   the fault that caused the failure
+     */
+    public void putFailure( BitPermissionIndexDAO dao, String appName,
+                            int index, Throwable fault )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            String msg = dao + ".put(" + appName + ", " + index
+                    + ") failed: " + fault.getMessage() ;
+            log.error( msg, fault ) ;
+        }
+    }
+
+
+    /**
+     * Monitors failures to delete an index entry.
+     *
+     * @param dao     the data access object that failed a delete operation
+     * @param info    additional implementation specific operation info
+     * @param appName the name of the application associated with the index
+     * @param index   the bit permission index that failed deletion
+     */
+    public void deleteFailure( BitPermissionIndexDAO dao, Object info,
+                               String appName, int index )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            String msg = dao + ".delete(" + appName + ", " + index
+                    + ") failed: " + info.toString() ;
+            log.error( msg ) ;
+        }
+    }
+
+
+    /**
+     * Monitors failures to delete an index entry.
+     *
+     * @param dao     the data access object that failed a delete operation
+     * @param appName the name of the application associated with the index
+     * @param index   the bit permission index that failed deletion
+     * @param fault   the fault that caused the failure
+     */
+    public void deleteFailure( BitPermissionIndexDAO dao, String appName,
+                               int index, Throwable fault )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            String msg = dao + ".delete(" + appName + ", " + index
+                    + ") failed: " + fault.getMessage() ;
+            log.error( msg, fault ) ;
+        }
+    }
+
+
+    /**
+     * Monitors failures to delte a non-existant index entry.
+     *
+     * @param dao     the data access object that failed a delete operation
+     * @param appName the name of the application associated with the index
+     * @param index   the bit permission index that failed deletion
+     */
+    public void nothingToDelete( JeBitPermissionIndexDAO dao, String appName,
+                                 int index )
+    {
+        if ( log.isWarnEnabled() )
+        {
+            String msg = dao + ".delete(" + appName + ", " + index
+                    + ") failed because the index does not exist" ;
+            log.warn( msg ) ;
+        }
+    }
+
+
+    /**
+     * Monitors failures to lookup the presence of an index for an application
+     *
+     * @param dao     the data access object that failed a list operation
+     * @param appName the name of the application associated with the index
+     * @param index   the bit permission index that failed lookup
+     * @param fault   the fault that caused the failure
+     */
+    public void lookupFailure( BitPermissionIndexDAO dao, String appName,
+                               int index, Throwable fault )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            String msg = dao + ".has(" + appName + ", " + index
+                    + ") failed: " + fault.getMessage() ;
+            log.error( msg, fault ) ;
+        }
+    }
+
+
+    /**
+     * Monitors the failure to close an index iterator or some other resource
+     * that must be released usign a close() operation.
+     *
+     * @param dao   the data access object that failed a list operation
+     * @param o     the object the close was attempted on
+     * @param fault the fault that caused the failure
+     */
+    public void closeFailure( BitPermissionIndexDAO dao, Object o,
+                              Throwable fault )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            String msg = o + ".close() by " + dao + " failed: "
+                    + fault.getMessage() ;
+            log.error( msg, fault ) ;
+        }
+    }
+
+
+    /**
+     * Monitors the failures while trying to list the permission indices of
+     * an application.
+     *
+     * @param dao     the data access object that failed a list operation
+     * @param appName the name of the application
+     * @param fault   the fault that caused the failure
+     */
+    public void listFailure( BitPermissionIndexDAO dao, String appName,
+                             Throwable fault )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            String msg = dao + ".list(" + appName + ") failed: "
+                    + fault.getMessage() ;
+            log.error( msg, fault ) ;
+        }
+    }
+
+
+    /**
+     * Monitors when getFirst is called to get the last bit perission index
+     * when no permissions exist for the application.
+     *
+     * @param dao     the data access object that failed a getFirst operation
+     * @param appName the name of the application associated with the index
+     */
+    public void noFirstElement( BitPermissionIndexDAO dao, String appName )
+    {
+        if ( log.isWarnEnabled() )
+        {
+            String msg = dao + ".getFirst(" + appName
+                    + ") failed since there are no indices for " + appName ;
+            log.warn( msg ) ;
+        }
+    }
+
+
+    /**
+     * Monitors failures to get the first index of an application's bit
+     * permission.
+     *
+     * @param dao     the data access object that failed a getFirst operation
+     * @param appName the name of the application
+     * @param fault   the fault that caused the failure
+     */
+    public void getFirstFailure( BitPermissionIndexDAO dao, String appName,
+                                 Throwable fault )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            String msg = dao + ".getFirst(" + appName + ") failed: "
+                    + fault.getMessage() ;
+            log.error( msg, fault ) ;
+        }
+    }
+
+
+    /**
+     * Monitors when getLast is called to get the last bit perission index when
+     * no permissions exist for the
+     * application.
+     *
+     * @param dao     the data access object that failed a getLast operation
+     * @param appName the name of the application associated with the index
+     */
+    public void noLastElement( BitPermissionIndexDAO dao, String appName )
+    {
+        if ( log.isWarnEnabled() )
+        {
+            String msg = dao + ".getLast(" + appName
+                    + ") failed since there are no indices for " + appName ;
+            log.warn( msg ) ;
+        }
+    }
+
+
+    /**
+     * Monitors failures to get the last index of an application's bit
+     * permission.
+     *
+     * @param dao     the data access object that failed a getLast operation
+     * @param appName the name of the application
+     * @param fault   the fault that caused the failure
+     */
+    public void getLastFailure( BitPermissionIndexDAO dao, String appName,
+                                Throwable fault )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            String msg = dao + ".getLast(" + appName + ") failed: "
+                    + fault.getMessage() ;
+            log.error( msg, fault ) ;
+        }
+    }
+
+
+    /**
+     * Monitors when a list is exhausted.
+     *
+     * @param dao  the data access object that created the list
+     * @param list the list of indices that was exhausted
+     */
+    public void listExhausted( BitPermissionIndexDAO dao, IntIterator list )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            String msg = list + " created by " + dao + " has been consumed" ;
+            log.debug( msg ) ;
+        }
+    }
+
+
+    /**
+     * Monitors when a list.next() is sucessfully called.
+     *
+     * @param dao    the data access object that created the list
+     * @param list   the list of indices
+     * @param retVal the next index value to return
+     */
+    public void listNextSuccess( BitPermissionIndexDAO dao, IntIterator list,
+                                 int retVal )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            String msg = list + " created by " + dao + " returning " + retVal
+                    + " on next()" ;
+            log.debug( msg ) ;
+        }
+    }
+
+
+    /**
+     * Monitors when some closable or freeble resource was closed or released.
+     *
+     * @param dao      the data access object that closes the resource
+     * @param resource the resource being closed or released
+     */
+    public void closeSuccess( BitPermissionIndexDAO dao, Object resource )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( resource + " closed by " + dao ) ;
+        }
+    }
+
+
+    /**
+     * Monitors the successful lookup of the last index for an application.
+     *
+     * @param dao     the data access object that performed the getLast
+     *                operation
+     * @param appName the name of the application
+     * @param index   the last index to be returned
+     */
+    public void getLastSuccess( BitPermissionIndexDAO dao, String appName,
+                                int index )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( dao + ".getLast(" + appName + ") returned " + index ) ;
+        }
+    }
+
+
+    /**
+     * Monitors the successful lookup of the first index for an application.
+     *
+     * @param dao     the data access object that performed the getFirst
+     *                operation
+     * @param appName the name of the application
+     * @param index   the first index to be returned
+     */
+    public void getFirstSuccess( BitPermissionIndexDAO dao, String appName,
+                                 int index )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( dao + ".getFirst(" + appName + ") returned " + index );
+        }
+    }
+
+
+    /**
+     * Monitors the successful start of an index listing.
+     *
+     * @param dao     the data access object that performed the list operation
+     * @param appName the name of the application
+     * @param list    the newly created index listing
+     */
+    public void listSuccess( BitPermissionIndexDAO dao, String appName,
+                             IntIterator list )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( dao + ".list(" + appName + ") returned " + list ) ;
+        }
+    }
+
+
+    /**
+     * Monitors the successful lookup of an index which may mean the index was
+     * found or not found - both are a success.
+     *
+     * @param dao     the data access object that performed the has operation
+     * @param appName the name of the application
+     * @param index   the index being checked for existance
+     * @param exists  the return value which is true if the index exists for the
+     *                application false otherwise
+     */
+    public void lookupSuccess( BitPermissionIndexDAO dao, String appName,
+                               int index, boolean exists )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( dao + ".has(" + appName + ", " + index + ") returned "
+                    + exists ) ;
+        }
+    }
+
+
+    /**
+     * Monitors the successful deletion of an index entry.
+     *
+     * @param dao     the data access object that permformed the delete
+     *                operation
+     * @param appName the name of the application
+     * @param index   the index that was deleted for the application
+     */
+    public void deleteSuccess( BitPermissionIndexDAO dao, String appName,
+                               int index )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( dao + ".delete(" + appName + ", " + index
+                    + ") succeeded" ) ;
+        }
+    }
+
+
+    /**
+     * Monitors the successful put of an index entry.
+     *
+     * @param dao     the data access object that permformed the put
+     *                operation
+     * @param appName the name of the application
+     * @param index   the index that was added to the application
+     */
+    public void putSuccess( BitPermissionIndexDAO dao, String appName,
+                            int index )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( dao + ".put(" + appName + ", " + index
+                    + ") succeeded" ) ;
+        }
+    }
+}

Added: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/JeBitPermissionFactoryTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/JeBitPermissionFactoryTest.java	Fri Apr 23 11:40:21 2004
@@ -0,0 +1,187 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.rms.je.permissions ;
+
+
+import org.apache.rms.je.sequence.JeSequenceDao;
+import org.apache.rms.je.sequence.JeSequenceFactory;
+import org.apache.rms.je.sequence.Sequence;
+import org.apache.rms.je.AbstractJeTest;
+import org.apache.rms.RmsException;
+import org.apache.rms.BitPermission;
+import com.sleepycat.je.DatabaseConfig;
+import com.sleepycat.je.SecondaryConfig;
+
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * Put some documentation here.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeBitPermissionFactoryTest extends AbstractJeTest
+{
+    JeBitPermissionFactory factory ;
+    JeBitPermissionDAO bitPermissionDAO ;
+    JeBitPermissionIndexManager indexManager ;
+
+
+    protected void setUp() throws Exception
+    {
+        DatabaseConfig conf = new DatabaseConfig() ;
+        conf.setAllowCreate( true ) ;
+        conf.setAllowDuplicates( true ) ;
+        setupDb( "indexManDb", conf ) ;
+        conf = new DatabaseConfig() ;
+        conf.setAllowCreate( true ) ;
+        setupDb( "seqDb", conf ) ;
+        super.setUp() ;
+
+        SecondaryConfig sconf = new SecondaryConfig() ;
+        sconf.setAllowCreate( true ) ;
+        sconf.setAllowDuplicates( true ) ;
+        sconf.setKeyCreator( new JeIndexKeyCreator() ) ;
+        env.openSecondaryDatabase( null, JeBitPermissionDAO.INDEX_SECDB,
+                sconf, db ) ;
+
+        sconf = new SecondaryConfig() ;
+        sconf.setAllowCreate( true ) ;
+        sconf.setAllowDuplicates( true ) ;
+        sconf.setKeyCreator( new JePermNameKeyCreator() ) ;
+        env.openSecondaryDatabase( null, JeBitPermissionDAO.PERM_SECDB,
+                sconf, db ) ;
+
+        sconf = new SecondaryConfig() ;
+        sconf.setAllowCreate( true ) ;
+        sconf.setAllowDuplicates( true ) ;
+        sconf.setKeyCreator( new JeAppNameKeyCreator() ) ;
+        env.openSecondaryDatabase( null, JeBitPermissionDAO.APP_SECDB,
+                sconf, db ) ;
+
+        JeBitPermissionIndexDAO indexDAO =
+                new JeBitPermissionIndexDAO( getDb( "indexManDb" ) ) ;
+        indexManager = new JeBitPermissionIndexManager( indexDAO ) ;
+        JeSequenceDao seqDAO = new JeSequenceDao( getDb( "seqDb" ) ) ;
+        JeSequenceFactory seqFactory = new JeSequenceFactory( seqDAO ) ;
+        Sequence seq = seqFactory.create( "indexSeq" ) ;
+        bitPermissionDAO = new JeBitPermissionDAO( db, seq, indexManager ) ;
+        factory = new JeBitPermissionFactory( bitPermissionDAO, indexDAO ) ;
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown() ;
+        factory = null ;
+        bitPermissionDAO = null ;
+        indexManager = null ;
+    }
+
+
+    public void testAll() throws Exception
+    {
+        BitPermission perm = null ;
+        factory.create( "app1", "perm1" ) ;
+        factory.create( "app1", "perm2" ) ;
+        factory.create( "app1", "perm3" ) ;
+        factory.create( "app1", "perm4" ) ;
+
+        List map = factory.getPermissionsMap( "app1" ) ;
+        assertEquals( "perm1", ( ( BitPermission ) map.get( 0 ) ).getName() ) ;
+        assertEquals( "perm2", ( ( BitPermission ) map.get( 1 ) ).getName() ) ;
+        assertEquals( "perm3", ( ( BitPermission ) map.get( 2 ) ).getName() ) ;
+        assertEquals( "perm4", ( ( BitPermission ) map.get( 3 ) ).getName() ) ;
+
+        try
+        {
+            bitPermissionDAO.getIndex( "asdf", "asdf" ) ;
+            fail( "this above should not succeed" ) ;
+        }
+        catch ( RmsException e )
+        {
+        }
+
+        bitPermissionDAO.delete( "app1", "perm1" ) ;
+        try
+        {
+            bitPermissionDAO.getIndex( "app1", "perm1" ) ;
+            fail( "this above should not succeed" ) ;
+        }
+        catch ( RmsException e )
+        {
+        }
+
+        bitPermissionDAO.create( "app1", "perm5" ) ;
+        assertEquals( 0, bitPermissionDAO.getIndex( "app1", "perm5" ) ) ;
+        bitPermissionDAO.create( "app1", "perm1" ) ;
+        assertEquals( 4, bitPermissionDAO.getIndex( "app1", "perm1" ) ) ;
+        bitPermissionDAO.rename( "app1", "perm1", "perm6" ) ;
+        assertEquals( 4, bitPermissionDAO.getIndex( "app1", "perm6" ) ) ;
+
+        try
+        {
+            bitPermissionDAO.getIndex( "app1", "perm1" ) ;
+            fail( "this above should not succeed" ) ;
+        }
+        catch ( RmsException e )
+        {
+        }
+
+        assertEquals( 4, bitPermissionDAO.getPermission( "app1",
+                "perm6" ).getIndex() ) ;
+
+        bitPermissionDAO.create( "app2", "permA" ) ;
+        assertEquals( 0, bitPermissionDAO.getIndex( "app2", "permA" ) ) ;
+
+        Iterator list = null ;
+        BitPermission perm = null ;
+        String name = null ;
+
+        list = bitPermissionDAO.list() ;
+        perm = ( BitPermission ) list.next() ;
+        assertEquals( "perm2", perm.getName() ) ;
+        perm = ( BitPermission ) list.next() ;
+        assertEquals( "perm3", perm.getName() ) ;
+        perm = ( BitPermission ) list.next() ;
+        assertEquals( "perm4", perm.getName() ) ;
+        perm = ( BitPermission ) list.next() ;
+        assertEquals( "perm5", perm.getName() ) ;
+        perm = ( BitPermission ) list.next() ;
+        assertEquals( "perm6", perm.getName() ) ;
+        perm = ( BitPermission ) list.next() ;
+        assertEquals( "permA", perm.getName() ) ;
+        assertFalse( list.hasNext() ) ;
+
+        list = bitPermissionDAO.listNames() ;
+        name = ( String ) list.next() ;
+        assertEquals( "perm2", name ) ;
+        name = ( String ) list.next() ;
+        assertEquals( "perm3", name ) ;
+        name = ( String ) list.next() ;
+        assertEquals( "perm4", name ) ;
+        name = ( String ) list.next() ;
+        assertEquals( "perm5", name ) ;
+        name = ( String ) list.next() ;
+        assertEquals( "perm6", name ) ;
+        name = ( String ) list.next() ;
+        assertEquals( "permA", name ) ;
+        assertFalse( list.hasNext() ) ;
+    }
+}
\ No newline at end of file

Mime
View raw message