directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 20748 - in incubator/directory/rms/trunk: je/src/java/org/apache/rms/je/profile je/src/test/org/apache/rms/je/profile spi/src/java/org/apache/rms/spi
Date Wed, 02 Jun 2004 02:08:37 GMT
Author: akarasulu
Date: Tue Jun  1 19:08:36 2004
New Revision: 20748

Modified:
   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/profile/JeProfileDAOTest.java
   incubator/directory/rms/trunk/spi/src/java/org/apache/rms/spi/ProfileDAOMonitor.java
   incubator/directory/rms/trunk/spi/src/java/org/apache/rms/spi/ProfileDAOMonitorAdapter.java
Log:
Commit changes ...

 o implemented update() in JeProfileDAO
 o created update test and all passed
 o added new methods methods to monitor interface for update
 o implemened noop monitor adapter method for update monitoring



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 19:08:36 2004
@@ -22,8 +22,8 @@
 import org.apache.rms.RmsException ;
 import org.apache.rms.spi.ProfileDAO ;
 import org.apache.rms.spi.ProfileDAOMonitor ;
-import org.apache.rms.spi.ProfileDAOMonitorAdapter ;
 import org.apache.rms.spi.ProfileRoleLinkDAO ;
+import org.apache.rms.spi.ProfileDAOMonitorAdapter ;
 
 import org.apache.rms.je.JeUtils ;
 import org.apache.rms.je.JeIterator ;
@@ -33,7 +33,6 @@
 
 import org.apache.commons.lang.Validate ;
 import org.apache.commons.collections.Transformer ;
-import org.apache.commons.lang.NotImplementedException ;
 import org.apache.commons.lang.exception.NestableRuntimeException ;
 
 import java.util.List ;
@@ -227,7 +226,8 @@
 
         try
         {
-            binding.membersToEntry( data, appName, userName, null, null, null ) ;
+            binding.membersToEntry( data, appName, userName, null, null,
+                    null ) ;
         }
         catch ( IOException e )
         {
@@ -456,7 +456,36 @@
                         byte[] denials, byte[] permissions )
             throws RmsException
     {
-        throw new NotImplementedException( "STUB" ) ;
+        DatabaseEntry pk = null ;
+        DatabaseEntry entry = new DatabaseEntry() ;
+        OperationStatus status = null ;
+
+        try
+        {
+            pk = getRow( appName, userName, true ) ;
+            binding.membersToEntry( entry, appName, userName, grants, denials,
+                    permissions ) ;
+            status = db.put( null, pk, entry ) ;
+        }
+        catch ( IOException e )
+        {
+            monitor.failedOnUpdate( this, appName, userName, grants, denials,
+                    permissions, e ) ;
+            throw new RmsException( e ) ;
+        }
+        catch ( DatabaseException e )
+        {
+            monitor.failedOnUpdate( this, appName, userName, grants, denials,
+                    permissions, e ) ;
+            throw new RmsException( e ) ;
+        }
+
+        if ( status != OperationStatus.SUCCESS )
+        {
+            throw new JeRmsException( status,
+                    "Update operation did not succeed due to status of "
+                    + status.toString() ) ;
+        }
     }
 
 
@@ -544,9 +573,10 @@
             status = cursor.getNext( key, row, LockMode.DEFAULT ) ;
             if ( status != OperationStatus.SUCCESS )
             {
-                throw new JeRmsException( status, "profile for user " + userName
-                    + " in application " + appName
-                    + " not found due to join status of " + status )  ;
+                throw new JeRmsException( status, "profile for user "
+                        + userName
+                        + " in application " + appName
+                        + " not found due to join status of " + status )  ;
             }
             return row ;
         }

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 19:08:36 2004
@@ -31,6 +31,7 @@
 import org.apache.rms.je.sequence.JeSequenceFactory ;
 import org.apache.rms.*;
 import org.apache.commons.collections.CollectionUtils ;
+import org.apache.commons.lang.ArrayUtils;
 
 
 /**
@@ -195,6 +196,35 @@
         profile = dao.get( app2, "user5" ) ;
         assertEquals( "app2", profile.getApplicationName() ) ;
         assertEquals( "user5", profile.getUserName() ) ;
+    }
+
+
+    public void testUpdate() throws Exception
+    {
+        assertFalse( dao.has( "app1", "user1" ) ) ;
+        assertFalse( dao.has( "app1", "user2" ) ) ;
+        assertFalse( dao.has( "app1", "user3" ) ) ;
+        assertFalse( dao.has( "app1", "user4" ) ) ;
+        assertFalse( dao.has( "app2", "user1" ) ) ;
+        assertFalse( dao.has( "app2", "user5" ) ) ;
+
+        dao.create( "app1", "user1" ) ;
+        assertTrue( dao.has( "app1", "user1" ) ) ;
+
+        byte[] grants = { 0x1 } ;
+        byte[] denials = { 0x2 } ;
+        byte[] permissions = { 0x3 } ;
+        dao.update( "app1", "user1", grants, denials, permissions ) ;
+
+        Application app1 = new DefaultApplication( "app1", new HashMap(),
+                new ArrayList() ) {} ;
+        JeProfile profile = ( JeProfile ) dao.get( app1, "user1" ) ;
+        assertEquals( "app1", profile.getApplicationName() ) ;
+        assertEquals( "user1", profile.getUserName() ) ;
+        assertTrue( ArrayUtils.isEquals( grants, profile.getGrantBits() ) ) ;
+        assertTrue( ArrayUtils.isEquals( denials, profile.getDenialBits() ) ) ;
+        assertTrue( ArrayUtils.isEquals( permissions, 
+                profile.getEffectiveBits() ) ) ;
     }
 
 

Modified: incubator/directory/rms/trunk/spi/src/java/org/apache/rms/spi/ProfileDAOMonitor.java
==============================================================================
--- incubator/directory/rms/trunk/spi/src/java/org/apache/rms/spi/ProfileDAOMonitor.java	(original)
+++ incubator/directory/rms/trunk/spi/src/java/org/apache/rms/spi/ProfileDAOMonitor.java	Tue
Jun  1 19:08:36 2004
@@ -18,6 +18,7 @@
 
 
 import java.io.UnsupportedEncodingException;
+import java.io.IOException;
 
 
 /**
@@ -71,5 +72,10 @@
 
     void failedOnListApplicationNames( ProfileDAO dao, 
                                        String userName, Throwable fault ) ;
+
+
+    void failedOnUpdate( ProfileDAO dao, String appName, String userName,
+                         byte[] grants, byte[] denials, byte[] permissions,
+                         Throwable fault ) ;
 
 }

Modified: incubator/directory/rms/trunk/spi/src/java/org/apache/rms/spi/ProfileDAOMonitorAdapter.java
==============================================================================
--- incubator/directory/rms/trunk/spi/src/java/org/apache/rms/spi/ProfileDAOMonitorAdapter.java
(original)
+++ incubator/directory/rms/trunk/spi/src/java/org/apache/rms/spi/ProfileDAOMonitorAdapter.java
Tue Jun  1 19:08:36 2004
@@ -132,4 +132,16 @@
             fault.printStackTrace() ;
         }
     }
+
+
+    public void failedOnUpdate( ProfileDAO dao, String appName,
+                                String userName, byte[] grants,
+                                byte[] denials, byte[] permissions,
+                                Throwable fault )
+    {
+        if ( fault != null )
+        {
+            fault.printStackTrace() ;
+        }
+    }
 }

Mime
View raw message