From directory-cvs-return-2475-apmail-incubator-directory-cvs-archive=incubator.apache.org@incubator.apache.org Sun Dec 12 06:01:28 2004 Return-Path: Delivered-To: apmail-incubator-directory-cvs-archive@www.apache.org Received: (qmail 59020 invoked from network); 12 Dec 2004 06:01:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 12 Dec 2004 06:01:28 -0000 Received: (qmail 73226 invoked by uid 500); 12 Dec 2004 06:01:28 -0000 Delivered-To: apmail-incubator-directory-cvs-archive@incubator.apache.org Received: (qmail 73177 invoked by uid 500); 12 Dec 2004 06:01:28 -0000 Mailing-List: contact directory-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: directory-dev@incubator.apache.org Delivered-To: mailing list directory-cvs@incubator.apache.org Received: (qmail 73164 invoked by uid 99); 12 Dec 2004 06:01:28 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sat, 11 Dec 2004 22:01:27 -0800 Received: (qmail 59008 invoked by uid 65534); 12 Dec 2004 06:01:26 -0000 Date: 12 Dec 2004 06:01:26 -0000 Message-ID: <20041212060126.59005.qmail@minotaur.apache.org> From: akarasulu@apache.org To: directory-cvs@incubator.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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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.