directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10432 - in incubator/directory/rms/trunk/je/src: java/org/apache/rms/je java/org/apache/rms/je/application java/org/apache/rms/je/permission java/org/apache/rms/je/role test/org/apache/rms/je/application test/org/apache/rms/je/role
Date Thu, 29 Apr 2004 20:53:37 GMT
Author: akarasulu
Date: Thu Apr 29 13:53:36 2004
New Revision: 10432

Modified:
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/AbstractJeTest.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationFactory.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionDAO.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionFactory.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionIndexDAO.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleAppNameKeyCreator.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleBinding.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleDAO.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleFactory.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleNameKeyCreator.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/LoggingRoleDAOMonitor.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAO.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/application/JeApplicationFactoryTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/role/JeRoleDAOTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/role/JeRoleFactoryTest.java
Log:
Commit changes ...

 o fixed grueling bug where 2ndary db name overlaps were causing db corruption
     - changed secondary db constants in all DAO classes
 o reverted to using a ThreadLocal within the JeRoleBinding to propagate the 
   application down into binding operations - this fixed the issue of cyclic
   dependencies and involved the following changes:
     - simplified the app role iterator inner class in JeRoleDAO
     - removed constructors taking a binding on role key creators
     - made binding a static member in key creators and DAO
     - added ThreadLocal to JeRoleBinding and get() set(Application) ops
     - removed RoleDAO.list() and RoleDAO.list(String) and RoleDAO.listNames()
     - added RoleDAO.list(Application) 
 o completed the ApplicationFactory
     - added all methods 
     - added constraint checks for delete and rename in case perms or roles
       are defined for the application being deleted or renamed.
     - created inner mutable Application implementation
 o all unit tests for ApplicationFactory passed

Things left todo:

 o add unit tests to to validate correct constraint checking in app factory
 o create monitor, adapter, and logging monitor for ApplicationFactory
 o use inner class ApplicationFactory.JeMutableApplication instead of 
   JeApplication which needs to be removed.
 o JeRole and JePermission must undergo same transformation as JeApplication



Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/AbstractJeTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/AbstractJeTest.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/AbstractJeTest.java	Thu Apr 29 13:53:36 2004
@@ -119,6 +119,16 @@
         {
             String name = ( String ) list.next() ;
             Database xtraDb = ( Database ) dbMap.get( name ) ;
+
+            databases = xtraDb.getSecondaryDatabases() ;
+            for ( int ii = 0; ii < databases.size(); ii++ )
+            {
+                Database secdb = ( Database ) databases.get( ii ) ;
+                String secdbName = secdb.getDatabaseName() ;
+                secdb.close() ;
+                env.removeDatabase( null, secdbName ) ;
+            }
+
             xtraDb.close() ;
             env.removeDatabase( null, name ) ;
         }

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java	Thu Apr 29 13:53:36 2004
@@ -42,7 +42,7 @@
 public class JeApplicationDAO implements ApplicationDAO
 {
     /** the name of the secondary database keyed by application name */
-    static final String APP_SECDB = "byAppName" ;
+    static final String APP_SECDB = "appByAppName" ;
 
     /** the tuple binding for an application */
     private static final JeApplicationBinding BINDING =

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationFactory.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationFactory.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationFactory.java	Thu Apr 29 13:53:36 2004
@@ -18,12 +18,19 @@
 
 
 import org.apache.rms.RmsException ;
+import org.apache.rms.BitPermission ;
+import org.apache.rms.spi.MutableRole ;
+import org.apache.rms.DefaultApplication ;
+import org.apache.rms.je.role.JeRoleFactory ;
 import org.apache.rms.spi.ApplicationFactory ;
 import org.apache.rms.spi.MutableApplication ;
+import org.apache.rms.spi.MutableBitPermission ;
+import org.apache.rms.je.permission.JeBitPermissionFactory ;
 
+import org.apache.commons.collections.IteratorUtils ;
 import org.apache.commons.lang.NotImplementedException ;
 
-import java.util.Iterator ;
+import java.util.* ;
 
 
 /**
@@ -36,16 +43,26 @@
 {
     /** the application data access object for Berkeley DB Je */
     private final JeApplicationDAO dao ;
+    /** the role factory to be used by this app factory */
+    private final JeRoleFactory roleFactory ;
+    /** the permission factory to be used by this app factory */
+    private final JeBitPermissionFactory permissionFactory ;
 
 
     /**
      * Creates an Application factory for Berkeley DB Je.
      *
      * @param dao the application data access object for Berkeley DB Je
+     * @param roleFactory the role factory to be used by this app factory
+     * @param permissionFactory the permission factory to be used by this app
+     * factory
      */
-    JeApplicationFactory( JeApplicationDAO dao )
+    JeApplicationFactory( JeApplicationDAO dao, JeRoleFactory roleFactory,
+                          JeBitPermissionFactory permissionFactory )
     {
         this.dao = dao ;
+        this.roleFactory = roleFactory ;
+        this.permissionFactory = permissionFactory ;
     }
 
 
@@ -60,16 +77,17 @@
     public MutableApplication getApplication( String appName )
             throws RmsException
     {
-        if ( dao.has( appName ) )
+        if ( ! dao.has( appName ) )
         {
-            /**
-             * @todo need to build the application up with perms and roles.
-             */
-            throw new NotImplementedException( "STUB" ) ;
-            // return new JeApplication( appName ) ;
+            throw new RmsException( "Application " + appName
+                    + " doesn't exist" ) ;
         }
 
-        throw new RmsException( "Application " + appName + " doesn't exist" ) ;
+        JeMutableApplication application = new JeMutableApplication( appName ) ;
+        application.setRoles( roleFactory.getRoles( application ) ) ;
+        List list = permissionFactory.getPermissionsMap( appName ) ;
+        application.setPermissions( list ) ;
+        return application ;
     }
 
 
@@ -98,8 +116,8 @@
             throws RmsException
     {
         dao.create( appName ) ;
-
-        return new JeApplication( appName ) ;
+        return new JeMutableApplication( appName, new HashMap(),
+                new ArrayList() ) ;
     }
 
 
@@ -112,14 +130,30 @@
      */
     public void deleteApplication( String appName ) throws RmsException
     {
-        // dao.delete( appName ) ;
-        /**
-         * @todo need to check and see if the application is in use by
-         * other role or permission objects within the database.  The
-         * delete cannot occur if other objects are using this application
-         * name.
-         */
-        throw new NotImplementedException( "STUB" ) ;
+        checkForDependents( appName ) ;
+        dao.delete( appName ) ;
+    }
+
+
+    private void checkForDependents( String appName )
+            throws RmsException
+    {
+        List permMap = permissionFactory.getPermissionsMap( appName ) ;
+        if ( permMap.size() > 0 )
+        {
+            throw new RmsException( "Constraint violation: cannot delete "
+                + appName + " while these permissions exist for it: "
+                + permMap ) ;
+        }
+
+        Iterator iterator = roleFactory.getRoleNames( appName ) ;
+        List roleNames = IteratorUtils.toList( iterator ) ;
+        if ( roleNames.size() > 0 )
+        {
+            throw new RmsException( "Constraint violation: cannot delete "
+                    + appName + " while these roles exist for it: "
+                    + roleNames ) ;
+        }
     }
 
 
@@ -134,12 +168,83 @@
     public void renameApplication( String oldName, String newName )
             throws RmsException
     {
-        /**
-         * @todo need to check and see if the application is in use by
-         * other role or permission objects within the database.  The
-         * rename cannot occur if other objects are using this application
-         * name.
-         */
-        throw new NotImplementedException( "STUB" ) ;
+        checkForDependents( oldName ) ;
+        dao.rename( oldName, newName ) ;
+    }
+
+
+    class JeMutableApplication extends DefaultApplication implements MutableApplication
+    {
+        JeMutableApplication( String name )
+        {
+            super( name ) ;
+        }
+
+
+        JeMutableApplication( String name, Map roles, List mapping )
+        {
+            super( name, roles, mapping ) ;
+        }
+
+
+        public void setRoles( Map roles )
+        {
+            super.setRoles( roles ) ;
+        }
+
+
+        public void setPermissions( List mapping )
+        {
+            super.setPermissions( mapping ) ;
+        }
+
+
+        public MutableBitPermission createPermission( String permName )
+                throws RmsException
+        {
+            throw new NotImplementedException( "STUB" );
+        }
+
+        public void deletePermission( BitPermission perm ) throws RmsException
+        {
+            throw new NotImplementedException( "STUB" );
+        }
+
+        public void deletePermission( String permName ) throws RmsException
+        {
+            throw new NotImplementedException( "STUB" );
+        }
+
+        public void renamePermission( String oldPermName, String newPermName )
+                throws RmsException
+        {
+            throw new NotImplementedException( "STUB" );
+        }
+
+        public void renamePermission( MutableBitPermission perm,
+                                      String newPermName ) throws RmsException
+        {
+            throw new NotImplementedException( "STUB" );
+        }
+
+        public MutableRole createRole( String roleName ) throws RmsException
+        {
+            throw new NotImplementedException( "STUB" );
+        }
+
+        public void deleteRole( MutableRole role ) throws RmsException
+        {
+            throw new NotImplementedException( "STUB" );
+        }
+
+        public void deleteRole( String roleName ) throws RmsException
+        {
+            throw new NotImplementedException( "STUB" );
+        }
+
+        public void rename( String name ) throws RmsException
+        {
+            throw new NotImplementedException( "STUB" );
+        }
     }
 }

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionDAO.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionDAO.java	Thu Apr 29 13:53:36 2004
@@ -43,11 +43,11 @@
 public class JeBitPermissionDAO implements BitPermissionDAO
 {
     /** the name of the secondary database keyed by application name */
-    static final String APP_SECDB = "byAppName" ;
+    public static final String APP_SECDB = "permByAppName" ;
     /** the name of the secondary database keyed by permission name */
-    static final String PERM_SECDB = "byPermName" ;
+    public static final String PERM_SECDB = "permByPermName" ;
     /** the name of the secondary database keyed by permission */
-    static final String INDEX_SECDB = "byIdx" ;
+    public static final String INDEX_SECDB = "permByIdx" ;
 
     /** A BitPermission binding */
     private static final JeBitPermissionTupleBinding BINDING =

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionFactory.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionFactory.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionFactory.java	Thu Apr 29 13:53:36 2004
@@ -54,7 +54,7 @@
      * @param permDAO the JE Database bit permission data access object
      * @param indexDAO the JE Database bit permission to index mapping DAO
      */
-    JeBitPermissionFactory( JeBitPermissionDAO permDAO, JeBitPermissionIndexDAO indexDAO )
+    public JeBitPermissionFactory( JeBitPermissionDAO permDAO, JeBitPermissionIndexDAO indexDAO )
     {
         Validate.notNull( permDAO ) ;
         Validate.notNull( indexDAO ) ;

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionIndexDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionIndexDAO.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permission/JeBitPermissionIndexDAO.java	Thu Apr 29 13:53:36 2004
@@ -60,7 +60,8 @@
         {
             if ( ! db.getConfig().getAllowDuplicates() )
             {
-                throw new RmsException( "Duplicates must be enable for db" ) ;
+                throw new RmsException( "Duplicates must be enable for db "
+                        + db.getDatabaseName() ) ;
             }
         }
         catch ( DatabaseException e )

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleAppNameKeyCreator.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleAppNameKeyCreator.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleAppNameKeyCreator.java	Thu Apr 29 13:53:36 2004
@@ -24,8 +24,6 @@
 
 import java.io.IOException ;
 
-import org.apache.rms.je.permission.JeBitPermissionTupleBinding;
-
 
 /**
  * A permission appName key creator for the appName secondary database.
@@ -35,19 +33,8 @@
  */
 public class JeRoleAppNameKeyCreator implements SecondaryKeyCreator
 {
-    /** the binding used to manipulate a serialized role */
-    private final JeRoleBinding binding ;
-
-
-    /**
-     * Creates a application name key creator based on a role binding.
-     *
-     * @param binding the role binding
-     */
-    JeRoleAppNameKeyCreator( JeRoleBinding binding )
-    {
-        this.binding = binding ;
-    }
+    /** the BINDING used to manipulate a serialized role */
+    private static final JeRoleBinding BINDING = new JeRoleBinding() ;
 
 
     /**
@@ -70,7 +57,7 @@
 
         try
         {
-            name = binding.getApplicationName( dataEntry ) ;
+            name = BINDING.getApplicationName( dataEntry ) ;
             resultEntry.setData( name.getBytes( "UTF-8" ) ) ;
         }
         catch ( IOException e )

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleBinding.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleBinding.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleBinding.java	Thu Apr 29 13:53:36 2004
@@ -16,6 +16,7 @@
  */
 package org.apache.rms.je.role ;
 
+
 import com.sleepycat.je.DatabaseEntry ;
 import com.sleepycat.bind.tuple.TupleInput ;
 import com.sleepycat.bind.tuple.TupleOutput ;
@@ -24,8 +25,6 @@
 import java.io.IOException ;
 
 import org.apache.rms.Application ;
-import org.apache.rms.RmsException;
-import org.apache.rms.spi.ApplicationFactory;
 
 
 /**
@@ -38,20 +37,29 @@
  */
 public class JeRoleBinding extends TupleBinding
 {
-    private final ApplicationFactory factory ;
+    /** used to associate an application with a thread while creating roles */
+    private static ThreadLocal applications = new ThreadLocal() ;
 
 
     /**
-     * Creates a RoleBinding that uses an application factory to resolve
-     * applications.
+     * Sets the current thread's application.
      *
-     * @param factory
+     * @param application the application to be associated with this thread
      */
-    public JeRoleBinding( ApplicationFactory factory )
+    static void set( Application application )
     {
-        super() ;
+        applications.set(  application ) ;
+    }
+
 
-        this.factory = factory ;
+    /**
+     * Gets the current thread's application if one exists.
+     *
+     * @return the application associated with this thread if one exists
+     */
+    static Application get()
+    {
+        return ( Application ) applications.get() ;
     }
 
 
@@ -70,18 +78,7 @@
     public Object entryToObject( TupleInput tupleInput ) throws IOException
     {
         String appName = tupleInput.readString() ;
-        Application application = null ;
-
-        try
-        {
-            application = factory.getApplication( appName ) ;
-        }
-        catch ( RmsException e )
-        {
-            throw new IllegalStateException( "An application by the name of "
-                + appName + " does not exist" ) ;
-        }
-
+        Application application = get() ;
 
         if ( application == null )
         {

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleDAO.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleDAO.java	Thu Apr 29 13:53:36 2004
@@ -45,13 +45,13 @@
  */
 public class JeRoleDAO implements RoleDAO
 {
+    /** A Role binding */
+    private static final JeRoleBinding BINDING = new JeRoleBinding() ;
     /** the name of the secondary database keyed by application name */
-    static final String APP_SECDB = "byAppName" ;
+    public static final String APP_SECDB = "roleByAppName" ;
     /** the name of the secondary database keyed by role name */
-    static final String ROLE_SECDB = "byRoleName" ;
+    public static final String ROLE_SECDB = "roleByRoleName" ;
 
-    /** A Role binding */
-    private final JeRoleBinding binding ;
     /** the JE database to use for this DAO */
     private final Database db ;
     /** the sequence we use to create new role database row ids with */
@@ -74,7 +74,7 @@
      *
      * @param db the JE Database for the role DAO
      */
-    public JeRoleDAO( Database db, Sequence seq, JeRoleBinding binding )
+    public JeRoleDAO( Database db, Sequence seq )
             throws RmsException
     {
         Validate.notNull( db ) ;
@@ -83,7 +83,6 @@
         this.db = db ;
         this.seq = seq ;
         this.monitor = new RoleDAOMonitorAdapter() ;
-        this.binding = binding ;
 
         List secdbs = null ;
         try
@@ -145,9 +144,11 @@
 
         try
         {
-            binding.objectToEntry( data, appName, roleName,
+            BINDING.objectToEntry( data, appName, roleName,
                     ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+            JeRoleBinding.set( application ) ;
             status = db.put( null, key, data ) ;
+            JeRoleBinding.set( null ) ;
         }
         catch ( IOException e )
         {
@@ -281,10 +282,10 @@
             status = db.get( null, key, value, LockMode.DEFAULT ) ;
 
             // extract the grants from the record
-            byte[] grants = binding.getGrants( value ) ;
+            byte[] grants = BINDING.getGrants( value ) ;
 
             // use grants, appName and new role name to construct new record
-            binding.objectToEntry( value, appName, newName, grants ) ;
+            BINDING.objectToEntry( value, appName, newName, grants ) ;
 
             // put data record into primary overwriting the old data record
             status = db.put( null, key, value ) ;
@@ -346,7 +347,9 @@
 
         try
         {
-            role = ( Role ) binding.entryToObject( data ) ;
+            JeRoleBinding.set( application ) ;
+            role = ( Role ) BINDING.entryToObject( data ) ;
+            JeRoleBinding.set( null ) ;
         }
         catch ( IOException e )
         {
@@ -452,7 +455,7 @@
         try
         {
             DatabaseEntry data = getRow( appName, roleName, false ) ;
-            grants = binding.getGrants( data ) ;
+            grants = BINDING.getGrants( data ) ;
         }
         catch ( IOException e )
         {
@@ -510,7 +513,7 @@
             status = db.get( null, key, value, LockMode.DEFAULT ) ;
 
             // use appName, roleName and new role grants to construct new record
-            binding.objectToEntry( value, appName, roleName, grants ) ;
+            BINDING.objectToEntry( value, appName, roleName, grants ) ;
 
             // put data record into primary overwriting the old data record
             status = db.put( null, key, value ) ;
@@ -541,42 +544,16 @@
 
 
     /**
-     * Lists all the roles within the entire database for all applications.
-     *
-     * @return an iterator listing all the Role objects within the database
-     * @throws org.apache.rms.RmsException if there is a failure accessing the
-     * underlying database
-     */
-    public Iterator list() throws RmsException
-    {
-        return new JeAppRoleIterator( false ) ;
-    }
-
-
-    /**
      * Lists all the roles within the database defined for an application.
      *
-     * @param appName the name of the application
+     * @param application the application
      * @return an iterator listing all the Role objects for the application
      * @throws org.apache.rms.RmsException if there is a failure accessing the
      * underlying database, or if the application does not exist
      */
-    public Iterator list( String appName ) throws RmsException
-    {
-        return new JeAppRoleIterator( appName, false ) ;
-    }
-
-
-    /**
-     * Lists the role names within the database for all applications.
-     *
-     * @return an iterator listing all names of roles within the database
-     * @throws org.apache.rms.RmsException if there is a failure accessing
-     * the underlying database
-     */
-    public Iterator listNames() throws RmsException
+    public Iterator list( Application application ) throws RmsException
     {
-        return new JeAppRoleIterator( true ) ;
+        return new JeAppRoleIterator( application ) ;
     }
 
 
@@ -590,7 +567,7 @@
      */
     public Iterator listNames( String appName ) throws RmsException
     {
-        return new JeAppRoleIterator( appName, true ) ;
+        return new JeAppRoleIterator( appName ) ;
     }
 
 
@@ -806,8 +783,7 @@
         final DatabaseEntry value = new DatabaseEntry() ;
 
         final String appName ;
-        final boolean onlyNames ;
-        final boolean fullScan ;
+        final Application application ;
 
         boolean hasNext = true ;
         Object prefetched = null ;
@@ -815,11 +791,10 @@
         OperationStatus status = null ;
 
 
-        JeAppRoleIterator( String appName, boolean onlyNames ) throws RmsException
+        JeAppRoleIterator( String appName ) throws RmsException
         {
-            this.fullScan = false ;
             this.appName = appName ;
-            this.onlyNames = onlyNames ;
+            this.application = null ;
 
             try
             {
@@ -832,95 +807,81 @@
                     hasNext = false ;
                     closeNoError( cursor ) ;
                     monitor.listingEmpty( JeRoleDAO.this, this, appName,
-                            onlyNames ) ;
+                            true ) ;
                     return ;
                 }
 
-                if ( onlyNames )
-                {
-                    prefetched = binding.getRoleName( value ) ;
-                    monitor.listingNamesOnly( JeRoleDAO.this, this, appName ) ;
-                }
-                else
-                {
-                    prefetched = binding.entryToObject( value ) ;
-                    monitor.listingRoles( JeRoleDAO.this, this, appName ) ;
-                }
+                prefetched = BINDING.getRoleName( value ) ;
+                monitor.listingNamesOnly( JeRoleDAO.this, this, appName ) ;
             }
             catch ( DatabaseException e )
             {
                 closeNoError( cursor ) ;
                 monitor.failedListing( JeRoleDAO.this, this, appName,
-                        onlyNames, e ) ;
+                        true, e ) ;
                 throw new RmsException( e ) ;
             }
             catch ( UnsupportedEncodingException e )
             {
                 closeNoError( cursor ) ;
                 monitor.failedListing( JeRoleDAO.this, this, appName,
-                        onlyNames, e ) ;
+                        true, e ) ;
                 throw new RmsException( e ) ;
             }
             catch ( IOException e )
             {
                 closeNoError( cursor ) ;
                 monitor.failedListing( JeRoleDAO.this, this, appName,
-                        onlyNames, e ) ;
+                        true, e ) ;
                 throw new RmsException( e ) ;
             }
         }
 
 
-        JeAppRoleIterator( boolean onlyNames ) throws RmsException
+        JeAppRoleIterator( Application application ) throws RmsException
         {
-            this.fullScan = true ;
             this.appName = null ;
-            this.onlyNames = onlyNames ;
+            this.application = application ;
 
             try
             {
+                key.setData( application.getName().getBytes( "UTF-8" ) ) ;
                 cursor = byAppName.openSecondaryCursor( null, null ) ;
-                status = cursor.getFirst( key, value, LockMode.DEFAULT ) ;
+                status = cursor.getSearchKey( key, value, LockMode.DEFAULT ) ;
 
                 if ( status != OperationStatus.SUCCESS )
                 {
                     hasNext = false ;
                     closeNoError( cursor ) ;
                     monitor.listingEmpty( JeRoleDAO.this, this, appName,
-                            onlyNames ) ;
+                            false ) ;
                     return ;
                 }
 
-                if ( onlyNames )
-                {
-                    prefetched = binding.getRoleName( value ) ;
-                    monitor.listingNamesOnly( JeRoleDAO.this, this, appName ) ;
-                }
-                else
-                {
-                    prefetched = binding.entryToObject( value ) ;
-                    monitor.listingRoles( JeRoleDAO.this, this, appName ) ;
-                }
+                JeRoleBinding.set( application ) ;
+                prefetched = BINDING.entryToObject( value ) ;
+                JeRoleBinding.set( null ) ;
+                monitor.listingRoles( JeRoleDAO.this, this, appName ) ;
             }
             catch ( DatabaseException e )
             {
                 closeNoError( cursor ) ;
                 monitor.failedListing( JeRoleDAO.this, this, appName,
-                        onlyNames, e ) ;
+                        false, e ) ;
                 throw new RmsException( e ) ;
             }
             catch ( UnsupportedEncodingException e )
             {
                 closeNoError( cursor ) ;
                 monitor.failedListing( JeRoleDAO.this, this, appName,
-                        onlyNames, e ) ;
+                        false, e ) ;
                 throw new RmsException( e ) ;
             }
             catch ( IOException e )
             {
                 closeNoError( cursor ) ;
                 monitor.failedListing( JeRoleDAO.this, this, appName,
-                        onlyNames, e ) ;
+                        false, e ) ;
                 throw new RmsException( e ) ;
             }
         }
@@ -940,20 +901,13 @@
 
         public Object next()
         {
+            boolean onlyNames = application == null ;
             OperationStatus status = null ;
             Object retVal = prefetched ;
 
             try
             {
-                if ( fullScan )
-                {
-                    status = cursor.getNext( key, value, LockMode.DEFAULT ) ;
-                }
-                else
-                {
-                    status = cursor.getNextDup( key, value,
-                            LockMode.DEFAULT ) ;
-                }
+                status = cursor.getNextDup( key, value, LockMode.DEFAULT ) ;
 
                 if ( status != OperationStatus.SUCCESS )
                 {
@@ -966,13 +920,15 @@
                 {
                     if ( onlyNames )
                     {
-                        prefetched = binding.getRoleName( value ) ;
+                        prefetched = BINDING.getRoleName( value ) ;
                         monitor.successOnNextName( JeRoleDAO.this, this,
                                 appName, retVal, prefetched ) ;
                     }
                     else
                     {
-                        prefetched = binding.entryToObject( value ) ;
+                        JeRoleBinding.set( application ) ;
+                        prefetched = BINDING.entryToObject( value ) ;
+                        JeRoleBinding.set( null ) ;
                         monitor.successOnNextRole( JeRoleDAO.this, this,
                                 appName, retVal, prefetched ) ;
                     }

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleFactory.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleFactory.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleFactory.java	Thu Apr 29 13:53:36 2004
@@ -46,7 +46,7 @@
      *
      * @param dao the data access object to the role database
      */
-    JeRoleFactory( JeRoleDAO dao )
+    public JeRoleFactory( JeRoleDAO dao )
     {
         this.dao = dao ;
     }
@@ -94,7 +94,7 @@
      */
     public Map getRoles( Application application ) throws RmsException
     {
-        Iterator list = dao.list( application.getName() ) ;
+        Iterator list = dao.list( application ) ;
         HashMap roles = new HashMap() ;
         while( list.hasNext() )
         {

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleNameKeyCreator.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleNameKeyCreator.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleNameKeyCreator.java	Thu Apr 29 13:53:36 2004
@@ -24,8 +24,6 @@
 
 import java.io.IOException ;
 
-import org.apache.rms.je.permission.JeBitPermissionTupleBinding;
-
 
 /**
  * A permission appName key creator for the appName secondary database.
@@ -35,19 +33,8 @@
  */
 public class JeRoleNameKeyCreator implements SecondaryKeyCreator
 {
-    /** the binding used to manipulate a serialized role */
-    private final JeRoleBinding binding ;
-
-
-    /**
-     * Creates a application role name key creator based on a role binding.
-     *
-     * @param binding the role binding
-     */
-    JeRoleNameKeyCreator( JeRoleBinding binding )
-    {
-        this.binding = binding ;
-    }
+    /** the BINDING used to manipulate a serialized role */
+    private static final JeRoleBinding BINDING = new JeRoleBinding() ;
 
 
     /**
@@ -70,7 +57,7 @@
 
         try
         {
-            name = binding.getRoleName( dataEntry ) ;
+            name = BINDING.getRoleName( dataEntry ) ;
             resultEntry.setData( name.getBytes( "UTF-8" ) ) ;
         }
         catch ( IOException e )

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/LoggingRoleDAOMonitor.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/LoggingRoleDAOMonitor.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/LoggingRoleDAOMonitor.java	Thu Apr 29 13:53:36 2004
@@ -36,24 +36,13 @@
  */
 public class LoggingRoleDAOMonitor implements RoleDAOMonitor
 {
-    /** the entry <-> object binding used for prefetched entry transformation */
-    private final EntryBinding binding ;
+    /** the entry <-> object BINDING used for prefetched entry transformation */
+    private static final EntryBinding BINDING = new JeRoleBinding() ;
     /** the log used by this logging monitor */
     private Log log = LogFactory.getLog( RoleDAO.class ) ;
 
 
     /**
-     * Creates a Role DAO monitor using a Je Role EntryBinding.
-     *
-     * @param binding the role tuple binding
-     */
-    LoggingRoleDAOMonitor( JeRoleBinding binding )
-    {
-        this.binding = binding ;
-    }
-
-
-    /**
      * Monitors events where the DAO fails to create a new Role.
      *
      * @param dao     the data access object that failed
@@ -580,7 +569,7 @@
                     try
                     {
                         role = ( Role )
-                                binding.entryToObject( ( DatabaseEntry ) prefetched ) ;
+                                BINDING.entryToObject( ( DatabaseEntry ) prefetched ) ;
                     }
                     catch ( IOException e )
                     {

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAO.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAO.java	Thu Apr 29 13:53:36 2004
@@ -109,32 +109,14 @@
     boolean has( String appName, String roleName ) throws RmsException ;
 
     /**
-     * Lists all the roles within the entire database for all applications.
-     *
-     * @return an iterator listing all the Role objects within the database
-     * @throws RmsException if there is a failure accessing the underlying
-     * database
-     */
-    Iterator list() throws RmsException ;
-
-    /**
      * Lists all the roles within the database defined for an application.
      *
-     * @param appName the name of the application
+     * @param application the application
      * @return an iterator listing all the Role objects for the application
      * @throws RmsException if there is a failure accessing the underlying
      * database, or if the application does not exist
      */
-    Iterator list( String appName ) throws RmsException ;
-
-    /**
-     * Lists the role names within the database for all applications.
-     *
-     * @return an iterator listing all names of roles within the database
-     * @throws RmsException if there is a failure accessing the underlying
-     * database
-     */
-    Iterator listNames() throws RmsException ;
+    Iterator list( Application application ) throws RmsException ;
 
     /**
      * Lists the role names within the database defined for an application.
@@ -145,5 +127,4 @@
      * database, or if the application does not exist
      */
     Iterator listNames( String appName ) throws RmsException ;
-
 }

Modified: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/application/JeApplicationFactoryTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/application/JeApplicationFactoryTest.java	(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/application/JeApplicationFactoryTest.java	Thu Apr 29 13:53:36 2004
@@ -21,6 +21,11 @@
 
 import org.apache.rms.RmsException ;
 import org.apache.rms.je.AbstractJeTest ;
+import org.apache.rms.je.role.JeRoleFactory;
+import org.apache.rms.je.role.JeRoleDAO;
+import org.apache.rms.je.role.JeRoleAppNameKeyCreator;
+import org.apache.rms.je.role.JeRoleNameKeyCreator;
+import org.apache.rms.je.permission.*;
 import org.apache.rms.je.sequence.Sequence ;
 import org.apache.rms.je.sequence.JeSequenceDao ;
 import org.apache.rms.je.sequence.JeSequenceFactory ;
@@ -37,29 +42,127 @@
 public class JeApplicationFactoryTest extends AbstractJeTest
 {
     JeApplicationDAO dao ;
+    JeRoleFactory roleFactory ;
     JeApplicationFactory factory ;
-
+    JeBitPermissionFactory permissionFactory ;
+    SecondaryDatabase roleAppNameDb ;
 
     protected void setUp() throws Exception
     {
+        SecondaryConfig sconf = null ;
         DatabaseConfig conf = new DatabaseConfig() ;
         conf.setAllowCreate( true ) ;
         setupDb( "seqDb", conf ) ;
+
+        conf = new DatabaseConfig() ;
+        conf.setAllowCreate( true ) ;
+        setupDb( "roleDb", conf ) ;
+
+        conf = new DatabaseConfig() ;
+        conf.setAllowCreate( true ) ;
+        setupDb( "permissionDb", conf ) ;
+
+        conf = new DatabaseConfig() ;
+        conf.setAllowCreate( true ) ;
+        conf.setAllowDuplicates( true ) ;
+        setupDb( "indexDb", conf ) ;
+
         super.setUp() ;
 
-        SecondaryConfig sconf = new SecondaryConfig() ;
+        // -------------------------------------------------------------------
+        // Setup the sequence database/dao/factory
+        // -------------------------------------------------------------------
+
+        JeSequenceDao seqDAO = new JeSequenceDao( getDb( "seqDb" ) ) ;
+        JeSequenceFactory seqFactory = new JeSequenceFactory( seqDAO ) ;
+
+        // -------------------------------------------------------------------
+        // Setup the permission index database/dao/factory
+        // -------------------------------------------------------------------
+
+        Database indexDb = getDb( "indexDb" ) ;
+        JeBitPermissionIndexDAO indexDAO =
+                new JeBitPermissionIndexDAO( indexDb ) ;
+        JeBitPermissionIndexManager indexMgr =
+                new JeBitPermissionIndexManager( indexDAO ) ;
+
+        // -------------------------------------------------------------------
+        // Setup the permission database/dao/factory
+        // -------------------------------------------------------------------
+
+        Database permissionDb = getDb( "permissionDb" ) ;
+        Sequence permissionSeq = seqFactory.create( "permissionSeq" ) ;
+
+        sconf = new SecondaryConfig() ;
+        sconf.setAllowCreate( true ) ;
+        sconf.setAllowDuplicates( true ) ;
+        sconf.setKeyCreator( new
+                org.apache.rms.je.permission.JeAppNameKeyCreator() ) ;
+        env.openSecondaryDatabase( null, JeBitPermissionDAO.APP_SECDB, sconf,
+                permissionDb ) ;
+
+        sconf = new SecondaryConfig() ;
+        sconf.setAllowCreate( true ) ;
+        sconf.setAllowDuplicates( true ) ;
+        sconf.setKeyCreator( new
+                org.apache.rms.je.permission.JePermNameKeyCreator() ) ;
+        env.openSecondaryDatabase( null, JeBitPermissionDAO.PERM_SECDB, sconf,
+                permissionDb ) ;
+
+        sconf = new SecondaryConfig() ;
+        sconf.setAllowCreate( true ) ;
+        sconf.setAllowDuplicates( true ) ;
+        sconf.setKeyCreator( new
+                org.apache.rms.je.permission.JeIndexKeyCreator() ) ;
+        env.openSecondaryDatabase( null, JeBitPermissionDAO.INDEX_SECDB,
+                sconf, permissionDb ) ;
+
+        JeBitPermissionDAO permissionDAO =
+                new JeBitPermissionDAO( permissionDb, permissionSeq,
+                        indexMgr ) ;
+        permissionFactory = new JeBitPermissionFactory( permissionDAO,
+                indexDAO ) ;
+
+        // -------------------------------------------------------------------
+        // Setup the role database/dao/factory
+        // -------------------------------------------------------------------
+
+        Database roleDb = getDb( "roleDb" ) ;
+
+        sconf = new SecondaryConfig() ;
+        sconf.setAllowCreate( true ) ;
+        sconf.setAllowDuplicates( true ) ;
+        sconf.setKeyCreator( new JeRoleAppNameKeyCreator() ) ;
+        roleAppNameDb = env.openSecondaryDatabase( null, JeRoleDAO.APP_SECDB,
+                sconf, roleDb ) ;
+
+        sconf = new SecondaryConfig() ;
+        sconf.setAllowCreate( true ) ;
+        sconf.setAllowDuplicates( true ) ;
+        sconf.setKeyCreator( new JeRoleNameKeyCreator() ) ;
+        env.openSecondaryDatabase( null, JeRoleDAO.ROLE_SECDB,
+                sconf, roleDb ) ;
+
+        Sequence roleSeq = seqFactory.create( "roleSeq" ) ;
+        JeRoleDAO roleDAO = new JeRoleDAO( roleDb, roleSeq ) ;
+        roleFactory = new JeRoleFactory( roleDAO ) ;
+
+        // -------------------------------------------------------------------
+        // Setup the application database/dao/factory
+        // -------------------------------------------------------------------
+
+        sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
         sconf.setAllowDuplicates( true ) ;
         sconf.setKeyCreator( new JeAppNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeApplicationDAO.APP_SECDB,
                 sconf, db ) ;
 
-        JeSequenceDao seqDAO = new JeSequenceDao( getDb( "seqDb" ) ) ;
-        JeSequenceFactory seqFactory = new JeSequenceFactory( seqDAO ) ;
         Sequence seq = seqFactory.create( "applicationSeq" ) ;
         dao = new JeApplicationDAO( db, seq ) ;
         dao.setMonitor( new LoggingApplicationDAOMonitor() ) ;
-        factory = new JeApplicationFactory( dao ) ;
+        factory = new JeApplicationFactory( dao, roleFactory,
+                permissionFactory ) ;
     }
 
 

Modified: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/role/JeRoleDAOTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/role/JeRoleDAOTest.java	(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/role/JeRoleDAOTest.java	Thu Apr 29 13:53:36 2004
@@ -50,9 +50,6 @@
 
     protected void setUp() throws Exception
     {
-        ApplicationFactory factory = new DummyFactory() ;
-        JeRoleBinding binding = new JeRoleBinding( factory ) ;
-
         DatabaseConfig conf = new DatabaseConfig() ;
         conf.setAllowCreate( true ) ;
         setupDb( "seqDb", conf ) ;
@@ -61,21 +58,21 @@
         SecondaryConfig sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
         sconf.setAllowDuplicates( true ) ;
-        sconf.setKeyCreator( new JeRoleAppNameKeyCreator( binding ) ) ;
+        sconf.setKeyCreator( new JeRoleAppNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeRoleDAO.APP_SECDB,
                 sconf, db ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
         sconf.setAllowDuplicates( true ) ;
-        sconf.setKeyCreator( new JeRoleNameKeyCreator( binding ) ) ;
+        sconf.setKeyCreator( new JeRoleNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeRoleDAO.ROLE_SECDB,
                 sconf, db ) ;
 
         JeSequenceDao seqDAO = new JeSequenceDao( getDb( "seqDb" ) ) ;
         JeSequenceFactory seqFactory = new JeSequenceFactory( seqDAO ) ;
         Sequence seq = seqFactory.create( "roleSeq" ) ;
-        roleDAO = new JeRoleDAO( db, seq, binding ) ;
+        roleDAO = new JeRoleDAO( db, seq ) ;
         //dao.setMonitor( new LoggingRoleDAOMonitor() ) ;
     }
 
@@ -294,100 +291,6 @@
     }
 
 
-    public void testCreateAndList() throws Exception
-    {
-        assertFalse( roleDAO.has( "app1", "roleA" ) ) ;
-        assertFalse( roleDAO.has( "app1", "roleB" ) ) ;
-        assertFalse( roleDAO.has( "app1", "roleC" ) ) ;
-        assertFalse( roleDAO.has( "app1", "roleD" ) ) ;
-
-        DefaultApplication application = new JeApplication( "app1" ) ;
-        roleDAO.create( application, "roleA" ) ;
-        roleDAO.create( application, "roleB" ) ;
-        roleDAO.create( application, "roleC" ) ;
-        roleDAO.create( application, "roleD" ) ;
-
-        application = new JeApplication( "app2" ) ;
-        roleDAO.create( application, "roleA" ) ;
-        roleDAO.create( application, "roleB" ) ;
-        roleDAO.create( application, "roleY" ) ;
-        roleDAO.create( application, "roleZ" ) ;
-
-        assertTrue( roleDAO.has( "app1", "roleA" ) ) ;
-        assertTrue( roleDAO.has( "app1", "roleB" ) ) ;
-        assertTrue( roleDAO.has( "app1", "roleC" ) ) ;
-        assertTrue( roleDAO.has( "app1", "roleD" ) ) ;
-
-        assertTrue( roleDAO.has( "app2", "roleA" ) ) ;
-        assertTrue( roleDAO.has( "app2", "roleB" ) ) ;
-        assertTrue( roleDAO.has( "app2", "roleY" ) ) ;
-        assertTrue( roleDAO.has( "app2", "roleZ" ) ) ;
-
-        Iterator list = null ;
-        JeRole role = null ;
-
-        list = roleDAO.list() ;
-
-        role = ( JeRole ) list.next() ;
-        assertNotNull( role ) ;
-        assertEquals( "app1", role.getApplicationName() ) ;
-        assertEquals( "roleA", role.getName() ) ;
-        assertTrue( ArrayUtils.isEquals( ArrayUtils.EMPTY_BYTE_ARRAY,
-                role.getGrantBits() ) ) ;
-
-        role = ( JeRole ) list.next() ;
-        assertNotNull( role ) ;
-        assertEquals( "app1", role.getApplicationName() ) ;
-        assertEquals( "roleB", role.getName() ) ;
-        assertTrue( ArrayUtils.isEquals( ArrayUtils.EMPTY_BYTE_ARRAY,
-                role.getGrantBits() ) ) ;
-
-        role = ( JeRole ) list.next() ;
-        assertNotNull( role ) ;
-        assertEquals( "app1", role.getApplicationName() ) ;
-        assertEquals( "roleC", role.getName() ) ;
-        assertTrue( ArrayUtils.isEquals( ArrayUtils.EMPTY_BYTE_ARRAY,
-                role.getGrantBits() ) ) ;
-
-        role = ( JeRole ) list.next() ;
-        assertNotNull( role ) ;
-        assertEquals( "app1", role.getApplicationName() ) ;
-        assertEquals( "roleD", role.getName() ) ;
-        assertTrue( ArrayUtils.isEquals( ArrayUtils.EMPTY_BYTE_ARRAY,
-                role.getGrantBits() ) ) ;
-
-        role = ( JeRole ) list.next() ;
-        assertNotNull( role ) ;
-        assertEquals( "app2", role.getApplicationName() ) ;
-        assertEquals( "roleA", role.getName() ) ;
-        assertTrue( ArrayUtils.isEquals( ArrayUtils.EMPTY_BYTE_ARRAY,
-                role.getGrantBits() ) ) ;
-
-        role = ( JeRole ) list.next() ;
-        assertNotNull( role ) ;
-        assertEquals( "app2", role.getApplicationName() ) ;
-        assertEquals( "roleB", role.getName() ) ;
-        assertTrue( ArrayUtils.isEquals( ArrayUtils.EMPTY_BYTE_ARRAY,
-                role.getGrantBits() ) ) ;
-
-        role = ( JeRole ) list.next() ;
-        assertNotNull( role ) ;
-        assertEquals( "app2", role.getApplicationName() ) ;
-        assertEquals( "roleY", role.getName() ) ;
-        assertTrue( ArrayUtils.isEquals( ArrayUtils.EMPTY_BYTE_ARRAY,
-                role.getGrantBits() ) ) ;
-
-        role = ( JeRole ) list.next() ;
-        assertNotNull( role ) ;
-        assertEquals( "app2", role.getApplicationName() ) ;
-        assertEquals( "roleZ", role.getName() ) ;
-        assertTrue( ArrayUtils.isEquals( ArrayUtils.EMPTY_BYTE_ARRAY,
-                role.getGrantBits() ) ) ;
-
-        assertFalse( list.hasNext() ) ;
-    }
-
-
     public void testCreateAndListString() throws Exception
     {
         assertFalse( roleDAO.has( "app1", "roleA" ) ) ;
@@ -420,7 +323,7 @@
         Iterator list = null ;
         JeRole role = null ;
 
-        list = roleDAO.list( "app2" ) ;
+        list = roleDAO.list( application ) ;
 
         role = ( JeRole ) list.next() ;
         assertNotNull( role ) ;
@@ -454,76 +357,6 @@
     }
 
 
-    public void testCreateAndListNames() throws Exception
-    {
-        assertFalse( roleDAO.has( "app1", "roleA" ) ) ;
-        assertFalse( roleDAO.has( "app1", "roleB" ) ) ;
-        assertFalse( roleDAO.has( "app1", "roleC" ) ) ;
-        assertFalse( roleDAO.has( "app1", "roleD" ) ) ;
-
-        DefaultApplication application = new JeApplication( "app1" ) ;
-        roleDAO.create( application, "roleA" ) ;
-        roleDAO.create( application, "roleB" ) ;
-        roleDAO.create( application, "roleC" ) ;
-        roleDAO.create( application, "roleD" ) ;
-
-        application = new JeApplication( "app2" ) ;
-        roleDAO.create( application, "roleA" ) ;
-        roleDAO.create( application, "roleB" ) ;
-        roleDAO.create( application, "roleY" ) ;
-        roleDAO.create( application, "roleZ" ) ;
-
-        assertTrue( roleDAO.has( "app1", "roleA" ) ) ;
-        assertTrue( roleDAO.has( "app1", "roleB" ) ) ;
-        assertTrue( roleDAO.has( "app1", "roleC" ) ) ;
-        assertTrue( roleDAO.has( "app1", "roleD" ) ) ;
-
-        assertTrue( roleDAO.has( "app2", "roleA" ) ) ;
-        assertTrue( roleDAO.has( "app2", "roleB" ) ) ;
-        assertTrue( roleDAO.has( "app2", "roleY" ) ) ;
-        assertTrue( roleDAO.has( "app2", "roleZ" ) ) ;
-
-        Iterator list = null ;
-        String roleName = null ;
-
-        list = roleDAO.listNames() ;
-
-        roleName = ( String ) list.next() ;
-        assertNotNull( roleName ) ;
-        assertEquals( "roleA", roleName ) ;
-
-        roleName = ( String ) list.next() ;
-        assertNotNull( roleName ) ;
-        assertEquals( "roleB", roleName ) ;
-
-        roleName = ( String ) list.next() ;
-        assertNotNull( roleName ) ;
-        assertEquals( "roleC", roleName ) ;
-
-        roleName = ( String ) list.next() ;
-        assertNotNull( roleName ) ;
-        assertEquals( "roleD", roleName ) ;
-
-        roleName = ( String ) list.next() ;
-        assertNotNull( roleName ) ;
-        assertEquals( "roleA", roleName ) ;
-
-        roleName = ( String ) list.next() ;
-        assertNotNull( roleName ) ;
-        assertEquals( "roleB", roleName ) ;
-
-        roleName = ( String ) list.next() ;
-        assertNotNull( roleName ) ;
-        assertEquals( "roleY", roleName ) ;
-
-        roleName = ( String ) list.next() ;
-        assertNotNull( roleName ) ;
-        assertEquals( "roleZ", roleName ) ;
-
-        assertFalse( list.hasNext() ) ;
-    }
-
-
     public void testCreateAndListNamesString() throws Exception
     {
         assertFalse( roleDAO.has( "app1", "roleA" ) ) ;
@@ -556,7 +389,7 @@
         Iterator list = null ;
         String roleName = null ;
 
-        list = roleDAO.listNames( "app2" ) ;
+        list = roleDAO.listNames( application.getName() ) ;
 
         roleName = ( String ) list.next() ;
         assertNotNull( roleName ) ;
@@ -575,37 +408,5 @@
         assertEquals( "roleZ", roleName ) ;
 
         assertFalse( list.hasNext() ) ;
-    }
-
-
-    class DummyFactory implements ApplicationFactory
-    {
-        public MutableApplication getApplication( String appName )
-                throws RmsException
-        {
-            return new JeApplication( appName ) ;
-        }
-
-        public Iterator getApplicationNames() throws RmsException
-        {
-            throw new NotImplementedException( "STUB" ) ;
-        }
-
-        public MutableApplication createApplication( String appName )
-                throws RmsException
-        {
-            throw new NotImplementedException( "STUB" ) ;
-        }
-
-        public void deleteApplication( String appName ) throws RmsException
-        {
-            throw new NotImplementedException( "STUB" ) ;
-        }
-
-        public void renameApplication( String oldName, String newName )
-                throws RmsException
-        {
-            throw new NotImplementedException( "STUB" ) ;
-        }
     }
 }

Modified: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/role/JeRoleFactoryTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/role/JeRoleFactoryTest.java	(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/role/JeRoleFactoryTest.java	Thu Apr 29 13:53:36 2004
@@ -21,7 +21,6 @@
 
 import org.apache.rms.Role ;
 import org.apache.rms.RmsException ;
-import org.apache.rms.DefaultApplication ;
 import org.apache.rms.spi.ApplicationFactory ;
 import org.apache.rms.spi.MutableApplication ;
 
@@ -52,9 +51,6 @@
 
     protected void setUp() throws Exception
     {
-        ApplicationFactory appFactory = new DummyFactory() ;
-        JeRoleBinding binding = new JeRoleBinding( appFactory ) ;
-
         DatabaseConfig conf = new DatabaseConfig() ;
         conf.setAllowCreate( true ) ;
         setupDb( "seqDb", conf ) ;
@@ -63,21 +59,21 @@
         SecondaryConfig sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
         sconf.setAllowDuplicates( true ) ;
-        sconf.setKeyCreator( new JeRoleAppNameKeyCreator( binding ) ) ;
+        sconf.setKeyCreator( new JeRoleAppNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeRoleDAO.APP_SECDB, sconf, db ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
         sconf.setAllowDuplicates( true ) ;
-        sconf.setKeyCreator( new JeRoleNameKeyCreator( binding ) ) ;
+        sconf.setKeyCreator( new JeRoleNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeRoleDAO.ROLE_SECDB, sconf, db ) ;
 
         JeSequenceDao seqDAO = new JeSequenceDao( getDb( "seqDb" ) ) ;
         JeSequenceFactory seqFactory = new JeSequenceFactory( seqDAO ) ;
         Sequence seq = seqFactory.create( "roleSeq" ) ;
-        dao = new JeRoleDAO( db, seq, binding ) ;
+        dao = new JeRoleDAO( db, seq ) ;
         factory = new JeRoleFactory( dao ) ;
-        dao.setMonitor( new LoggingRoleDAOMonitor( binding ) ) ;
+        dao.setMonitor( new LoggingRoleDAOMonitor() ) ;
     }
 
 
@@ -298,7 +294,7 @@
     }
 
 
-    public void testCreateAndListRoles() throws Exception
+    public void testCreateAndGetRoles() throws Exception
     {
         assertFalse( dao.has( "app1", "roleA" ) ) ;
         assertFalse( dao.has( "app1", "roleB" ) ) ;

Mime
View raw message