directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r599167 - in /directory/apacheds/branches/bigbang: core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Date Wed, 28 Nov 2007 22:24:10 GMT
Author: akarasulu
Date: Wed Nov 28 14:24:10 2007
New Revision: 599167

URL: http://svn.apache.org/viewvc?rev=599167&view=rev
Log:
making reverts work with moddn and modify

Modified:
    directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java

Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java?rev=599167&r1=599166&r2=599167&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java
(original)
+++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java
Wed Nov 28 14:24:10 2007
@@ -119,6 +119,28 @@
     }
 
 
+    public void testRevertRenameOperations() throws NamingException
+    {
+        AttributesImpl attrs = new AttributesImpl( "objectClass", "organizationalUnit", true
);
+        attrs.put( "ou", "oldname" );
+        sysRoot.createSubcontext( "ou=oldname", attrs );
+
+        // tag after the addition before rename
+        Tag t0 = service.getChangeLog().tag();
+        assertNotNull( sysRoot.getAttributes( "ou=oldname" ) );
+
+        // rename the test entry and test that the rename occurred
+        sysRoot.rename( "ou=oldname", "ou=newname" );
+        assertNotPresent( sysRoot, "ou=oldname" );
+        assertNotNull( sysRoot.getAttributes( "ou=newname" ) );
+
+        // now revert and assert that the rename was reversed
+        service.revert( t0.getRevision() );
+        assertNotPresent( sysRoot, "ou=newname" );
+        assertNotNull( sysRoot.getAttributes( "ou=oldname" ) );
+    }
+
+
     private void assertNotPresent( DirContext ctx, String dn ) throws NamingException
     {
         try

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=599167&r1=599166&r2=599167&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Wed Nov 28 14:24:10 2007
@@ -592,6 +592,9 @@
          * needs to synchronize on all changes while the revert is in progress.
          *
          * How about making this operation transactional?
+         *
+         * First of all just stop using JNDI and construct the operations to
+         * feed into the interceptor pipeline.
          */
 
         try
@@ -610,6 +613,23 @@
                         break;
                     case( ChangeType.DELETE_ORDINAL ):
                         ctx.destroySubcontext( reverse.getDn() );
+                        break;
+                    case( ChangeType.MODIFY_ORDINAL ):
+                        ctx.modifyAttributes( reverse.getDn(), reverse.getModificationItemsArray()
);
+                        break;
+                    case( ChangeType.MODDN_ORDINAL ):
+                        // NOT BREAK - both ModDN and ModRDN handling is the same
+                    case( ChangeType.MODRDN_ORDINAL ):
+                        if ( reverse.isDeleteOldRdn() )
+                        {
+                            ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" );
+                        }
+                        else
+                        {
+                            ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" );
+                        }
+
+                        ctx.rename( reverse.getDn(), event.getForwardLdif().getDn() );
                         break;
                     default:
                         throw new NotImplementedException( "Reverts of change type " + reverse.getChangeType()



Mime
View raw message