directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 20744 - in incubator/directory/rms/trunk/je: . src/java/org/apache/rms/je src/java/org/apache/rms/je/permission src/java/org/apache/rms/je/profile src/test/org/apache/rms/je/application src/test/org/apache/rms/je/permission src/test/org/apache/rms/je/profile src/test/org/apache/rms/je/role
Date Wed, 02 Jun 2004 00:35:06 GMT
Author: akarasulu
Date: Tue Jun  1 17:35:05 2004
New Revision: 20744

Modified:
   incubator/directory/rms/trunk/je/project.xml
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeIterator.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeJoinIterator.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeSecondaryIterator.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/profile/JeProfileDAO.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/application/JeApplicationDAOTest.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/permission/JeBitPermissionDAOTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionFactoryTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionIndexDAOTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionIndexManagerTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/profile/JeProfileDAOTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/profile/JeProfileRoleLinkDAOTest.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:
Change commmits:

 o upgraded JE lib to 1.4.10 from 1.3.0
    + changed [set]getAllowsDuplicates to [set]getSortedDuplicates
    + changed all openSecondaryCursor parameter order
 o fixed bug in JeSecondaryIterator
 o added more to the test case for JeProfileDAOTest



Modified: incubator/directory/rms/trunk/je/project.xml
==============================================================================
--- incubator/directory/rms/trunk/je/project.xml	(original)
+++ incubator/directory/rms/trunk/je/project.xml	Tue Jun  1 17:35:05 2004
@@ -58,7 +58,7 @@
     <dependency>
       <groupId>bdb</groupId>
       <artifactId>je</artifactId>
-      <version>1.3.0</version>
+      <version>1.4.10</version>
       <url>http://www.sleepycat.com/products/je.shtml</url>
     </dependency>
 

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeIterator.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeIterator.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeIterator.java	Tue Jun  1
17:35:05 2004
@@ -21,6 +21,7 @@
 
 import com.sleepycat.je.OperationStatus;
 import com.sleepycat.bind.EntryBinding;
+import org.apache.commons.collections.Transformer;
 
 
 /**
@@ -42,6 +43,12 @@
 
 
     EntryBinding getBinding();
+
+
+    Transformer getTransformer();
+
+
+    void setTransformer( Transformer transformer ) ;
 
 
     void close();

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeJoinIterator.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeJoinIterator.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeJoinIterator.java	Tue Jun
 1 17:35:05 2004
@@ -24,6 +24,7 @@
 
 import com.sleepycat.je.* ;
 import com.sleepycat.bind.EntryBinding ;
+import org.apache.commons.collections.Transformer;
 
 
 /**
@@ -44,17 +45,6 @@
 public class JeJoinIterator extends Observable
         implements JeIterator
 {
-    /** tracks if we have another item to return */
-    private boolean hasNext = true ;
-    /** the operation status of the last prefetch operation */
-    private OperationStatus status ;
-    /** the last prefetched item */
-    private Object prefetched ;
-    /** a monitor to track the events associated with this iterator */
-    private JeIteratorMonitor monitor ;
-    /** a failure if one has occurred */
-    private Throwable fault ;
-
     /** the Join cursor that we wrap */
     private final JoinCursor cursor ;
     /** the database entry primary key populated */
@@ -66,6 +56,19 @@
     /** the secondary cursors for the JoinCursor */
     private final SecondaryCursor[] secCursors ;
 
+    /** tracks if we have another item to return */
+    private boolean hasNext = true ;
+    /** the operation status of the last prefetch operation */
+    private OperationStatus status ;
+    /** the last prefetched item */
+    private Object prefetched ;
+    /** a monitor to track the events associated with this iterator */
+    private JeIteratorMonitor monitor ;
+    /** a failure if one has occurred */
+    private Throwable fault ;
+    /** an optional tranformer to use for transforming objects before next() */
+    private Transformer transformer ;
+
 
     /**
      * Creates a JeJoinIterator that iterates over values: db rows/records.
@@ -219,6 +222,11 @@
             throw e ;
         }
 
+        if ( transformer != null )
+        {
+            return transformer.transform( retval ) ;
+        }
+
         return retval ;
     }
 
@@ -331,6 +339,39 @@
     }
 
 
+    /**
+     * Gets the transformer currently being used by this JeIterator to transform
+     * objects before they are returned by the next().
+     *
+     * @return the transformer to apply before next() returns
+     */
+    public Transformer getTransformer()
+    {
+        return transformer ;
+    }
+
+
+    /**
+     * Sets the transformer to be used by this JeIterator to transform objects
+     * before they are returned by the next().
+     *
+     * @param transformer the new transformer to apply before next() returns
+     */
+    public void setTransformer( Transformer transformer )
+    {
+        this.transformer = transformer;
+    }
+
+
+    /**
+     * Finalizes this JeJoinIterator by closing it.
+     */
+    public void finalize()
+    {
+        close() ;
+    }
+
+
     // -----------------------------------------------------------------------
     // Protected Methods
     // -----------------------------------------------------------------------
@@ -442,14 +483,5 @@
                 throw e ;
             }
         }
-    }
-
-
-    /**
-     * Finalizes this JeJoinIterator by closing it.
-     */
-    public void finalize()
-    {
-        close() ;
     }
 }

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeSecondaryIterator.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeSecondaryIterator.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/JeSecondaryIterator.java	Tue
Jun  1 17:35:05 2004
@@ -24,6 +24,7 @@
 
 import com.sleepycat.je.* ;
 import com.sleepycat.bind.EntryBinding ;
+import org.apache.commons.collections.Transformer;
 
 
 /**
@@ -44,51 +45,64 @@
 public class JeSecondaryIterator extends Observable
         implements JeIterator
 {
+    /** the Secondary cursor that we wrap */
+    private final SecondaryCursor cursor ;
+    /** the database entry primary key populated */
+    private final DatabaseEntry pk ;
+    /** the secondary database key */
+    private final DatabaseEntry key ;
+    /** the database entry data populated */
+    private final DatabaseEntry data ;
+    /** the optional entry binding to use */
+    private final EntryBinding binding ;
+    /** whether or not to fetch the primary key or the data record */
+    private final boolean fetchPk ;
+
     /** tracks if we have another item to return */
     private boolean hasNext = true ;
     /** the operation status of the last prefetch operation */
     private OperationStatus status ;
     /** the last prefetched item */
-    private Object prefetched ;
+    private DatabaseEntry prefetched = new DatabaseEntry() ;
+    /** the prefetched entry to return item */
+    private DatabaseEntry returnEntry = new DatabaseEntry() ;
     /** a monitor to track the events associated with this iterator */
     private JeIteratorMonitor monitor ;
     /** a failure if one has occurred */
     private Throwable fault ;
-
-    /** the Secondary cursor that we wrap */
-    private final SecondaryCursor cursor ;
-    /** the database entry primary key populated */
-    private final DatabaseEntry pk ;
-    /** the database entry data populated */
-    private final DatabaseEntry data ;
-    /** the optional entry binding to use */
-    private final EntryBinding binding ;
+    /** an optional tranformer to use for transforming objects before next() */
+    private Transformer transformer ;
+    /** check to see if this is first fetch operation */
+    private boolean isFirstFetch = true ;
 
 
     /**
      * Creates a JeSecondaryIterator that iterates over values: db records.
      *
      * @param cursor the underlying cursor being wrapped
+     * @param key the secondary key to return duplicates for
      */
-    public JeSecondaryIterator( SecondaryCursor cursor )
+    public JeSecondaryIterator( SecondaryCursor cursor, String key )
             throws DatabaseException, IOException
     {
-        this( cursor, null, true ) ;
+        this( cursor, key, null, false ) ;
     }
 
 
     /**
-     * Creates a JeSecondaryIterator that iterates over primary key entries,
+     * Creates a JeSecondaryIterator that iterates over primary keys,
      * or values.
      *
      * @param cursor the underlying cursor being wrapped
-     * @param getBoth whether or not to fetch both the pk and the data - if
-     * true the data is fetched as well
+     * @param key the secondary key to return duplicates for
+     * @param fetchPk whether or not to fetch the pk or the data - if
+     * true the pk is fetched and returned, otherwise the data is returned
      */
-    public JeSecondaryIterator( SecondaryCursor cursor, boolean getBoth )
+    public JeSecondaryIterator( SecondaryCursor cursor, String key,
+                                boolean fetchPk )
             throws DatabaseException, IOException
     {
-        this( cursor, null, getBoth ) ;
+        this( cursor, key, null, fetchPk ) ;
     }
 
 
@@ -97,32 +111,27 @@
      * or bound object using an optional binding.
      *
      * @param cursor the underlying cursor being wrapped
+     * @param key the secondary key to return duplicates for
      * @param binding optional binding to apply to pk or data before it is
      * returned in the prefetch operation
-     * @param getBoth whether or not to fetch both the pk and the data - if
-     * true the data is fetched as well
+     * @param fetchPk whether or not to fetch the pk or the data - if
+     * true the pk is fetched and returned, otherwise the data is returned
      */
-    public JeSecondaryIterator( SecondaryCursor cursor,
-                       EntryBinding binding, boolean getBoth )
+    public JeSecondaryIterator( SecondaryCursor cursor, String key,
+                                EntryBinding binding, boolean fetchPk )
             throws DatabaseException, IOException
     {
         this.pk = new DatabaseEntry() ;
         this.cursor = cursor ;
         this.monitor = new JeIteratorMonitorAdapter() ;
         this.binding = binding ;
-
-        if ( getBoth )
-        {
-            this.data = new DatabaseEntry() ;
-        }
-        else
-        {
-            this.data = null ;
-        }
+        this.fetchPk = fetchPk ;
+        this.data = new DatabaseEntry() ;
 
         try
         {
-            prefetched = prefetch() ;
+            this.key = new DatabaseEntry( key.getBytes( "UTF-8" ) ) ;
+            prefetched.setData( prefetch().getData() ) ;
         }
         catch ( DatabaseException e )
         {
@@ -183,7 +192,8 @@
      */
     public final Object next()
     {
-        Object retval = prefetched ;
+        Object retval = null ;
+        returnEntry.setData( prefetched.getData() ) ;
 
         if ( ! hasNext )
         {
@@ -192,13 +202,23 @@
 
         try
         {
-            prefetched = prefetch() ;
-            monitor.prefetch( this, prefetched, retval ) ;
+            prefetched.setData( prefetch().getData() ) ;
+            monitor.prefetch( this, prefetched ) ;
+
+            if ( binding != null )
+            {
+                retval = binding.entryToObject( returnEntry ) ;
+            }
+            else
+            {
+                retval = returnEntry ;
+            }
+
         }
         catch ( Exception e )
         {
             close( e ) ;
-            monitor.prefetchFailure( this, retval ) ;
+            monitor.prefetchFailure( this, prefetched ) ;
 
             if ( e instanceof RuntimeException )
             {
@@ -208,10 +228,15 @@
         catch ( Error e )
         {
             close( e ) ;
-            monitor.prefetchFailure( this, retval ) ;
+            monitor.prefetchFailure( this, prefetched ) ;
             throw e ;
         }
 
+        if ( transformer != null )
+        {
+            return transformer.transform( retval ) ;
+        }
+
         return retval ;
     }
 
@@ -324,8 +349,41 @@
     }
 
 
+    /**
+     * Gets the transformer currently being used by this JeIterator to transform
+     * objects before they are returned by the next().
+     *
+     * @return the transformer to apply before next() returns
+     */
+    public Transformer getTransformer()
+    {
+        return transformer ;
+    }
+
+
+    /**
+     * Sets the transformer to be used by this JeIterator to transform objects
+     * before they are returned by the next().
+     *
+     * @param transformer the new transformer to apply before next() returns
+     */
+    public void setTransformer( Transformer transformer )
+    {
+        this.transformer = transformer ;
+    }
+
+
+    /**
+     * Finalizes this JeJoinIterator by closing it.
+     */
+    public void finalize()
+    {
+        close() ;
+    }
+
+
     // -----------------------------------------------------------------------
-    // Protected Methods
+    // Private Methods
     // -----------------------------------------------------------------------
 
 
@@ -364,38 +422,40 @@
 
 
     /**
-     * Concrete JeJoinIterator's must allow for item prefetching.  This method
-     * is called usually once on initialization, and once every time next() is
-     * invoked.
+     * JeSecondaryIterator's must allow for item prefetching.  This method
+     * is called once every time next() is invoked.
      *
-     * @return the a prefetched item from the iteration
-     * @throws com.sleepycat.je.DatabaseException if any failures accessing the database
-     * @throws com.sleepycat.je.DatabaseException if any failures occur while binding
+     * @throws com.sleepycat.je.DatabaseException if any failures accessing the
+     * database
+     * @throws com.sleepycat.je.DatabaseException if any failures occur while
+     * binding
      */
-    private final Object prefetch() throws DatabaseException, IOException
+    private final DatabaseEntry prefetch()
+            throws DatabaseException
     {
-        if ( data != null )
+        if ( this.isFirstFetch )
         {
-            setStatus( cursor.getNext( pk, data, LockMode.DEFAULT ) ) ;
-
-            if ( binding != null )
+            if ( fetchPk )
             {
-                return binding.entryToObject( data ) ;
+                setStatus( cursor.getSearchKey( key, pk, data,
+                        LockMode.DEFAULT ) ) ;
+                return pk ;
             }
 
+            setStatus( cursor.getSearchKey( key, data, LockMode.DEFAULT ) ) ;
+
+            this.isFirstFetch = false ;
             return data ;
         }
-        else
-        {
-            setStatus( cursor.getNext( pk, data, LockMode.DEFAULT ) ) ;
-
-            if ( binding != null )
-            {
-                return binding.entryToObject( pk ) ;
-            }
 
+        if ( fetchPk )
+        {
+            setStatus( cursor.getNextDup( key, pk, data, LockMode.DEFAULT ) ) ;
             return pk ;
         }
+
+        setStatus( cursor.getNextDup( key, data, LockMode.DEFAULT ) ) ;
+        return data ;
     }
 
 
@@ -405,7 +465,8 @@
      * work.  This should be overridden to close all the SecondaryCursors
      * used to construct the JoinCursor.
      *
-     * @throws com.sleepycat.je.DatabaseException on failures while closing the join cursor
+     * @throws com.sleepycat.je.DatabaseException on failures while closing
+     * the join cursor
      */
     private final void cleanup() throws DatabaseException
     {
@@ -420,14 +481,5 @@
                 throw e ;
             }
         }
-    }
-
-
-    /**
-     * Finalizes this JeJoinIterator by closing it.
-     */
-    public void finalize()
-    {
-        close() ;
     }
 }

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
Tue Jun  1 17:35:05 2004
@@ -61,7 +61,7 @@
     {
         try
         {
-            if ( ! db.getConfig().getAllowDuplicates() )
+            if ( ! db.getConfig().getSortedDuplicates() )
             {
                 throw new RmsException( "Duplicates must be enable for db "
                         + db.getDatabaseName() ) ;

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeProfileDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeProfileDAO.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeProfileDAO.java
Tue Jun  1 17:35:05 2004
@@ -27,11 +27,15 @@
 
 import org.apache.rms.je.JeUtils ;
 import org.apache.rms.je.JeRmsException ;
+import org.apache.rms.je.JeSecondaryIterator;
+import org.apache.rms.je.JeIterator;
 import org.apache.rms.je.sequence.Sequence ;
 
 import org.apache.commons.lang.Validate ;
 import org.apache.commons.lang.NotImplementedException ;
+import org.apache.commons.lang.exception.NestableRuntimeException;
 import org.apache.commons.collections.iterators.EmptyIterator ;
+import org.apache.commons.collections.Transformer;
 
 import java.util.List ;
 import java.util.Iterator ;
@@ -339,44 +343,47 @@
      * @throws org.apache.rms.RmsException if there is a failure accessing the
      * underlying database
      */
-    public Iterator listUserNames( String appName ) throws RmsException
+    public Iterator listUserNames( final String appName ) throws RmsException
     {
-        OperationStatus status = null ;
-        DatabaseEntry value = new DatabaseEntry() ;
-        DatabaseEntry appNameKey = new DatabaseEntry() ;
+        JeIterator iterator = null ;
+        SecondaryCursor appNameCursor = null ;
 
         try
         {
-            appNameKey.setData( appName.getBytes( "UTF-8" ) ) ;
+            // -o- setup the application name cursor -o-
+            appNameCursor = byAppName.openSecondaryCursor( null, null ) ;
+            iterator = new JeSecondaryIterator( appNameCursor, appName ) ;
         }
-        catch ( UnsupportedEncodingException e )
+        catch ( DatabaseException e )
         {
             monitor.failedOnListUserNames( this, appName, e ) ;
             throw new RmsException( e ) ;
         }
-
-        SecondaryCursor appNameCursor = null ;
-        try
-        {
-            // -o- setup the application name cursor -o-
-            appNameCursor = byAppName.openSecondaryCursor( null, null ) ;
-            status = appNameCursor
-                .getSearchKey( appNameKey, value, LockMode.DEFAULT ) ;
-
-            if ( status != OperationStatus.SUCCESS )
-            {
-                closeNoError( appNameCursor ) ;
-                return EmptyIterator.INSTANCE ;
-            }
-        }
-        catch ( DatabaseException e )
+        catch ( IOException e )
         {
             monitor.failedOnListUserNames( this, appName, e ) ;
             throw new RmsException( e ) ;
         }
 
-        // return new JeJoinIterator() ;
-        throw new NotImplementedException( "STUB" ) ;
+        iterator.setTransformer( new Transformer()
+        {
+            public Object transform( Object o )
+            {
+                try
+                {
+                    return binding.getUserName( ( DatabaseEntry ) o ) ;
+                }
+                catch ( IOException e )
+                {
+                    monitor.failedOnListUserNames( JeProfileDAO.this,
+                        appName, e ) ;
+                    throw new NestableRuntimeException(
+                        "JeIterator's transformer transform() failed", e ) ;
+                }
+            }
+        }) ;
+
+        return iterator ;
     }
 
 

Modified: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/application/JeApplicationDAOTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/application/JeApplicationDAOTest.java
(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/application/JeApplicationDAOTest.java
Tue Jun  1 17:35:05 2004
@@ -49,10 +49,10 @@
 
         SecondaryConfig sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeAppNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeApplicationDAO.APP_SECDB,
-                sconf, db ) ;
+               db, sconf ) ;
 
         JeSequenceDao seqDAO = new JeSequenceDao( getDb( "seqDb" ) ) ;
         JeSequenceFactory seqFactory = new JeSequenceFactory( seqDAO ) ;

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
Tue Jun  1 17:35:05 2004
@@ -65,7 +65,7 @@
 
         conf = new DatabaseConfig() ;
         conf.setAllowCreate( true ) ;
-        conf.setAllowDuplicates( true ) ;
+        conf.setSortedDuplicates( true ) ;
         setupDb( "indexDb", conf ) ;
 
         super.setUp() ;
@@ -96,27 +96,27 @@
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new
                 org.apache.rms.je.permission.JeAppNameKeyCreator() ) ;
-        env.openSecondaryDatabase( null, JeBitPermissionDAO.APP_SECDB, sconf,
-                permissionDb ) ;
+        env.openSecondaryDatabase( null, JeBitPermissionDAO.APP_SECDB,
+                permissionDb, sconf ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new
                 org.apache.rms.je.permission.JePermNameKeyCreator() ) ;
-        env.openSecondaryDatabase( null, JeBitPermissionDAO.PERM_SECDB, sconf,
-                permissionDb ) ;
+        env.openSecondaryDatabase( null, JeBitPermissionDAO.PERM_SECDB,
+                permissionDb, sconf ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new
                 org.apache.rms.je.permission.JeIndexKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeBitPermissionDAO.INDEX_SECDB,
-                sconf, permissionDb ) ;
+                permissionDb, sconf ) ;
 
         JeBitPermissionDAO permissionDAO =
                 new JeBitPermissionDAO( permissionDb, permissionSeq,
@@ -132,17 +132,17 @@
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeRoleAppNameKeyCreator() ) ;
         roleAppNameDb = env.openSecondaryDatabase( null, JeRoleDAO.APP_SECDB,
-                sconf, roleDb ) ;
+                roleDb, sconf ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeRoleNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeRoleDAO.ROLE_SECDB,
-                sconf, roleDb ) ;
+                roleDb, sconf ) ;
 
         Sequence roleSeq = seqFactory.create( "roleSeq" ) ;
         JeRoleDAO roleDAO = new JeRoleDAO( roleDb, roleSeq ) ;
@@ -154,10 +154,10 @@
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeAppNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeApplicationDAO.APP_SECDB,
-                sconf, db ) ;
+                db, sconf ) ;
 
         Sequence seq = seqFactory.create( "applicationSeq" ) ;
         dao = new JeApplicationDAO( db, seq ) ;

Modified: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionDAOTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionDAOTest.java
(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionDAOTest.java
Tue Jun  1 17:35:05 2004
@@ -49,7 +49,7 @@
     {
         DatabaseConfig conf = new DatabaseConfig() ;
         conf.setAllowCreate( true ) ;
-        conf.setAllowDuplicates( true ) ;
+        conf.setSortedDuplicates( true ) ;
         setupDb( "indexManDb", conf ) ;
         conf = new DatabaseConfig() ;
         conf.setAllowCreate( true ) ;
@@ -58,24 +58,24 @@
 
         SecondaryConfig sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeIndexKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeBitPermissionDAO.INDEX_SECDB,
-                sconf, db ) ;
+                db, sconf ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JePermNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeBitPermissionDAO.PERM_SECDB,
-                sconf, db ) ;
+                db, sconf ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeAppNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeBitPermissionDAO.APP_SECDB,
-                sconf, db ) ;
+                db, sconf ) ;
 
         JeBitPermissionIndexDAO indexDAO =
                 new JeBitPermissionIndexDAO( getDb( "indexManDb" ) ) ;

Modified: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionFactoryTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionFactoryTest.java
(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionFactoryTest.java
Tue Jun  1 17:35:05 2004
@@ -17,18 +17,18 @@
 package org.apache.rms.je.permission ;
 
 
-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 org.apache.rms.spi.LoggingBitPermissionIndexDAOMonitor;
-import com.sleepycat.je.*;
-import com.sleepycat.bind.EntryBinding;
+import org.apache.rms.je.AbstractJeTest ;
+import org.apache.rms.je.sequence.Sequence ;
+import org.apache.rms.je.sequence.JeSequenceDao ;
+import org.apache.rms.je.sequence.JeSequenceFactory ;
+
+import org.apache.rms.RmsException ;
+import org.apache.rms.BitPermission ;
+import org.apache.rms.spi.LoggingBitPermissionIndexDAOMonitor ;
 
-import java.util.Iterator;
-import java.util.List;
+import com.sleepycat.je.* ;
+
+import java.util.List ;
 
 
 /**
@@ -48,7 +48,7 @@
     {
         DatabaseConfig conf = new DatabaseConfig() ;
         conf.setAllowCreate( true ) ;
-        conf.setAllowDuplicates( true ) ;
+        conf.setSortedDuplicates( true ) ;
         setupDb( "indexManDb", conf ) ;
         conf = new DatabaseConfig() ;
         conf.setAllowCreate( true ) ;
@@ -57,24 +57,24 @@
 
         SecondaryConfig sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeIndexKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeBitPermissionDAO.INDEX_SECDB,
-                sconf, db ) ;
+                db, sconf ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JePermNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeBitPermissionDAO.PERM_SECDB,
-                sconf, db ) ;
+                db, sconf ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeAppNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeBitPermissionDAO.APP_SECDB,
-                sconf, db ) ;
+                db, sconf ) ;
 
         JeBitPermissionIndexDAO indexDAO =
                 new JeBitPermissionIndexDAO( getDb( "indexManDb" ) ) ;

Modified: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionIndexDAOTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionIndexDAOTest.java
(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionIndexDAOTest.java
Tue Jun  1 17:35:05 2004
@@ -39,7 +39,7 @@
      */
     protected void setUp() throws Exception
     {
-        super.dbConfig.setAllowDuplicates( true ) ;
+        super.dbConfig.setSortedDuplicates( true ) ;
         super.setUp() ;
         dao = new JeBitPermissionIndexDAO( db ) ;
     }

Modified: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionIndexManagerTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionIndexManagerTest.java
(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permission/JeBitPermissionIndexManagerTest.java
Tue Jun  1 17:35:05 2004
@@ -34,7 +34,7 @@
 
     protected void setUp() throws Exception
     {
-        dbConfig.setAllowDuplicates( true ) ;
+        dbConfig.setSortedDuplicates( true ) ;
         super.setUp() ;
         dao = new JeBitPermissionIndexDAO( db ) ;
         manager = new JeBitPermissionIndexManager( dao ) ;

Modified: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/profile/JeProfileDAOTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/profile/JeProfileDAOTest.java
(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/profile/JeProfileDAOTest.java
Tue Jun  1 17:35:05 2004
@@ -17,6 +17,9 @@
 package org.apache.rms.je.profile ;
 
 
+import java.util.HashSet ;
+import java.util.Iterator;
+
 import com.sleepycat.je.Database ;
 import com.sleepycat.je.SecondaryConfig ;
 
@@ -24,6 +27,7 @@
 import org.apache.rms.je.sequence.Sequence ;
 import org.apache.rms.je.sequence.JeSequenceDao ;
 import org.apache.rms.je.sequence.JeSequenceFactory ;
+import org.apache.commons.collections.CollectionUtils ;
 
 
 /**
@@ -65,25 +69,25 @@
         name = JeProfileRoleLinkDAO.APPNAME_SECDB ;
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeLinkAppNameKeyCreator() ) ;
-        env.openSecondaryDatabase( null, name, sconf, getDb( "roleLinkDb" ) ) ;
+        env.openSecondaryDatabase( null, name, getDb( "roleLinkDb" ), sconf ) ;
 
         // -o- create the userName secondary db -o-
         name = JeProfileRoleLinkDAO.USERNAME_SECDB ;
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeLinkUserNameKeyCreator() ) ;
-        env.openSecondaryDatabase( null, name, sconf, getDb( "roleLinkDb" ) ) ;
+        env.openSecondaryDatabase( null, name, getDb( "roleLinkDb" ), sconf ) ;
 
         // -o- create the roleName secondary db -o-
         name = JeProfileRoleLinkDAO.ROLENAME_SECDB ;
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeLinkRoleNameKeyCreator() ) ;
-        env.openSecondaryDatabase( null, name, sconf, getDb( "roleLinkDb" ) ) ;
+        env.openSecondaryDatabase( null, name, getDb( "roleLinkDb" ), sconf ) ;
 
         Database sqDb = getDb( "sqDb" ) ;
         JeSequenceDao sqDao = new JeSequenceDao( sqDb ) ;
@@ -99,17 +103,17 @@
         name = JeProfileDAO.APPNAME_SECDB ;
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeProfileAppNameKeyCreator( binding ) ) ;
-        env.openSecondaryDatabase( null, name, sconf, db ) ;
+        env.openSecondaryDatabase( null, name, db, sconf ) ;
 
         // -o- create the userName secondary db -o-
         name = JeProfileDAO.USERNAME_SECDB ;
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeProfileUserNameKeyCreator( binding ) ) ;
-        env.openSecondaryDatabase( null, name, sconf, db ) ;
+        env.openSecondaryDatabase( null, name, db, sconf ) ;
 
         sq = sqFactory.create( "profileDbSeq" ) ;
         dao = new JeProfileDAO( db, sq, binding, roleLinkDao ) ;
@@ -126,5 +130,36 @@
     public void testHas() throws Exception
     {
         assertFalse( dao.has( "app1", "user1" ) ) ;
+    }
+
+
+    public void testCreate() throws Exception
+    {
+        assertFalse( dao.has( "app1", "user1" ) ) ;
+        dao.create( "app1", "user1" ) ;
+        assertTrue( dao.has( "app1", "user1" ) ) ;
+    }
+
+
+    public void testListUserName() throws Exception
+    {
+        assertFalse( dao.listUserNames( "app1" ).hasNext() ) ;
+        dao.create( "app1", "user1" ) ;
+        dao.create( "app1", "user2" ) ;
+        dao.create( "app1", "user3" ) ;
+        dao.create( "app1", "user4" ) ;
+        dao.create( "app2", "user1" ) ;
+        dao.create( "app2", "user5" ) ;
+
+        HashSet set = new HashSet() ;
+        Iterator list = dao.listUserNames( "app1" ) ;
+        CollectionUtils.addAll( set, list ) ;
+        assertEquals( 4, set.size() ) ;
+        assertTrue( set.contains( "user1" ) ) ;
+        assertTrue( set.contains( "user2" ) ) ;
+        assertTrue( set.contains( "user3" ) ) ;
+        assertTrue( set.contains( "user4" ) ) ;
+        assertFalse( set.contains( "user5" ) ) ;
+        assertFalse( list.hasNext() ) ;
     }
 }

Modified: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/profile/JeProfileRoleLinkDAOTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/profile/JeProfileRoleLinkDAOTest.java
(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/profile/JeProfileRoleLinkDAOTest.java
Tue Jun  1 17:35:05 2004
@@ -53,25 +53,25 @@
         name = JeProfileRoleLinkDAO.APPNAME_SECDB ;
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeLinkAppNameKeyCreator() ) ;
-        env.openSecondaryDatabase( null, name, sconf, db ) ;
+        env.openSecondaryDatabase( null, name, db, sconf ) ;
 
         // -o- create the appName secondary db -o-
         name = JeProfileRoleLinkDAO.USERNAME_SECDB ;
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeLinkUserNameKeyCreator() ) ;
-        env.openSecondaryDatabase( null, name, sconf, db ) ;
+        env.openSecondaryDatabase( null, name, db, sconf ) ;
 
         // -o- create the appName secondary db -o-
         name = JeProfileRoleLinkDAO.ROLENAME_SECDB ;
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeLinkRoleNameKeyCreator() ) ;
-        env.openSecondaryDatabase( null, name, sconf, db ) ;
+        env.openSecondaryDatabase( null, name, db, sconf ) ;
 
         Database sqDb = getDb( "sqDb" ) ;
         JeSequenceDao sqDao = new JeSequenceDao( sqDb ) ;

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	Tue
Jun  1 17:35:05 2004
@@ -22,8 +22,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 ;
 
 import org.apache.rms.je.AbstractJeTest ;
 import org.apache.rms.je.sequence.Sequence ;
@@ -32,7 +30,6 @@
 import org.apache.rms.je.sequence.JeSequenceFactory ;
 
 import org.apache.commons.lang.ArrayUtils ;
-import org.apache.commons.lang.NotImplementedException ;
 
 import java.util.Iterator ;
 
@@ -57,17 +54,17 @@
 
         SecondaryConfig sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeRoleAppNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeRoleDAO.APP_SECDB,
-                sconf, db ) ;
+                db, sconf ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeRoleNameKeyCreator() ) ;
         env.openSecondaryDatabase( null, JeRoleDAO.ROLE_SECDB,
-                sconf, db ) ;
+                db, sconf ) ;
 
         JeSequenceDao seqDAO = new JeSequenceDao( getDb( "seqDb" ) ) ;
         JeSequenceFactory seqFactory = new JeSequenceFactory( seqDAO ) ;

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
Tue Jun  1 17:35:05 2004
@@ -59,15 +59,15 @@
 
         SecondaryConfig sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeRoleAppNameKeyCreator() ) ;
-        env.openSecondaryDatabase( null, JeRoleDAO.APP_SECDB, sconf, db ) ;
+        env.openSecondaryDatabase( null, JeRoleDAO.APP_SECDB, db, sconf ) ;
 
         sconf = new SecondaryConfig() ;
         sconf.setAllowCreate( true ) ;
-        sconf.setAllowDuplicates( true ) ;
+        sconf.setSortedDuplicates( true ) ;
         sconf.setKeyCreator( new JeRoleNameKeyCreator() ) ;
-        env.openSecondaryDatabase( null, JeRoleDAO.ROLE_SECDB, sconf, db ) ;
+        env.openSecondaryDatabase( null, JeRoleDAO.ROLE_SECDB, db, sconf ) ;
 
         JeSequenceDao seqDAO = new JeSequenceDao( getDb( "seqDb" ) ) ;
         JeSequenceFactory seqFactory = new JeSequenceFactory( seqDAO ) ;

Mime
View raw message