directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r111642 - in incubator/directory/eve/trunk/dib/src: java/org/apache/eve/jndi/ibs test/org/apache/eve/jndi/ibs
Date Sun, 12 Dec 2004 06:01:26 GMT
Author: akarasulu
Date: Sat Dec 11 22:01:22 2004
New Revision: 111642

URL: http://svn.apache.org/viewcvs?view=rev&rev=111642
Log:
Changes ...

 o clarified calc of target entry to move to in OpAttrSvc 
 o added check for existance of target in modifyRdn ops
 o added check for existance of target in both overloads of move ops
 o added test cases that trigger the new exceptions added


Modified:
   incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/EveExceptionService.java
   incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java
   incubator/directory/eve/trunk/dib/src/test/org/apache/eve/jndi/ibs/EveExceptionServiceTest.java

Modified: incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/EveExceptionService.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/EveExceptionService.java?view=diff&rev=111642&p1=incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/EveExceptionService.java&r1=111641&p2=incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/EveExceptionService.java&r2=111642
==============================================================================
--- incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/EveExceptionService.java
(original)
+++ incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/EveExceptionService.java
Sat Dec 11 22:01:22 2004
@@ -301,6 +301,18 @@
             // check if entry to rename exists
             String msg = "Attempt to rename non-existant entry: ";
             assertHasEntry( msg, dn, invocation );
+
+            // check to see if target entry exists
+            Name target = dn.getSuffix( 1 ).add( newRdn );
+            if ( nexus.hasEntry( target ) )
+            {
+                LdapNameAlreadyBoundException e = null;
+                e = new LdapNameAlreadyBoundException( "target entry " + target
+                    + " already exists!" );
+                invocation.setBeforeFailure( e );
+                e.setResolvedName( target );
+                throw e;
+            }
         }
     }
 
@@ -322,6 +334,20 @@
             // check if parent to move to exists
             msg = "Attempt to move to non-existant parent: ";
             assertHasEntry( msg, newParentName, invocation );
+
+            // check to see if target entry exists
+            String rdn = oriChildName.get( oriChildName.size() - 1 );
+            Name target = ( Name ) newParentName.clone();
+            target.add( rdn );
+            if ( nexus.hasEntry( target ) )
+            {
+                LdapNameAlreadyBoundException e = null;
+                e = new LdapNameAlreadyBoundException( "target entry " + target
+                    + " already exists!" );
+                invocation.setBeforeFailure( e );
+                e.setResolvedName( target );
+                throw e;
+            }
         }
     }
 
@@ -343,6 +369,19 @@
             // check if parent to move to exists
             msg = "Attempt to move to non-existant parent: ";
             assertHasEntry( msg, newParentName, invocation );
+
+            // check to see if target entry exists
+            Name target = ( Name ) newParentName.clone();
+            target.add( newRdn );
+            if ( nexus.hasEntry( target ) )
+            {
+                LdapNameAlreadyBoundException e = null;
+                e = new LdapNameAlreadyBoundException( "target entry " + target
+                    + " already exists!" );
+                invocation.setBeforeFailure( e );
+                e.setResolvedName( target );
+                throw e;
+            }
         }
     }
 

Modified: incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java?view=diff&rev=111642&p1=incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java&r1=111641&p2=incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java&r2=111642
==============================================================================
--- incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java
(original)
+++ incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java
Sat Dec 11 22:01:22 2004
@@ -201,9 +201,7 @@
             attribute.add( DateUtils.getGeneralizedTime( System.currentTimeMillis() ) );
             attributes.put( attribute );
 
-            Name newDn = ( Name ) dn.clone();
-            newDn.remove( newDn.size() - 1 );
-            newDn.add( newRdn );
+            Name newDn = dn.getSuffix( 1 ).add( newRdn );
             nexus.modify( newDn, DirContext.REPLACE_ATTRIBUTE, attributes );
         }
     }

Modified: incubator/directory/eve/trunk/dib/src/test/org/apache/eve/jndi/ibs/EveExceptionServiceTest.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/dib/src/test/org/apache/eve/jndi/ibs/EveExceptionServiceTest.java?view=diff&rev=111642&p1=incubator/directory/eve/trunk/dib/src/test/org/apache/eve/jndi/ibs/EveExceptionServiceTest.java&r1=111641&p2=incubator/directory/eve/trunk/dib/src/test/org/apache/eve/jndi/ibs/EveExceptionServiceTest.java&r2=111642
==============================================================================
--- incubator/directory/eve/trunk/dib/src/test/org/apache/eve/jndi/ibs/EveExceptionServiceTest.java
(original)
+++ incubator/directory/eve/trunk/dib/src/test/org/apache/eve/jndi/ibs/EveExceptionServiceTest.java
Sat Dec 11 22:01:22 2004
@@ -87,6 +87,40 @@
     // Move Operation Tests
     // ------------------------------------------------------------------------
 
+
+    /**
+     * Test move operation failure when the object moved is non-existant.
+     */
+    public void testFailMoveEntryAlreadyExists() throws NamingException
+    {
+        try
+        {
+            sysRoot.createSubcontext( "ou=users,ou=groups" );
+            sysRoot.rename( "ou=users", "ou=users,ou=groups" );
+            fail( "Execution should never get here due to exception!" );
+        }
+        catch( LdapNameAlreadyBoundException e )
+        {
+            assertEquals( "ou=users,ou=groups,ou=system", e.getResolvedName().toString()
);
+            assertEquals( ResultCodeEnum.ENTRYALREADYEXISTS, e.getResultCode() );
+        }
+
+        try
+        {
+            sysRoot.createSubcontext( "ou=uzerz,ou=groups" );
+            sysRoot.addToEnvironment( "java.naming.ldap.deleteRDN", "false" );
+            sysRoot.rename( "ou=users", "ou=uzerz,ou=groups" );
+            sysRoot.removeFromEnvironment( "java.naming.ldap.deleteRDN" );
+            fail( "Execution should never get here due to exception!" );
+        }
+        catch( LdapNameAlreadyBoundException e )
+        {
+            assertEquals( "ou=uzerz,ou=groups,ou=system", e.getResolvedName().toString()
);
+            assertEquals( ResultCodeEnum.ENTRYALREADYEXISTS, e.getResultCode() );
+        }
+    }
+
+
     /**
      * Test move operation failure when the object moved is non-existant.
      */
@@ -143,6 +177,24 @@
     // ------------------------------------------------------------------------
     // ModifyRdn Operation Tests
     // ------------------------------------------------------------------------
+
+    /**
+     * Test modifyRdn operation failure when the object renamed is non-existant.
+     */
+    public void testFailModifyRdnEntryAlreadyExists() throws NamingException
+    {
+        try
+        {
+            sysRoot.rename( "ou=users", "ou=groups" );
+            fail( "Execution should never get here due to exception!" );
+        }
+        catch( LdapNameAlreadyBoundException e )
+        {
+            assertEquals( "ou=groups,ou=system", e.getResolvedName().toString() );
+            assertEquals( ResultCodeEnum.ENTRYALREADYEXISTS, e.getResultCode() );
+        }
+    }
+
 
     /**
      * Test modifyRdn operation failure when the object renamed is non-existant.

Mime
View raw message