You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2010/01/02 16:43:34 UTC

svn commit: r895208 - in /directory/apacheds/branches/apacheds-schema: core-annotations/src/main/java/org/apache/directory/server/core/annotations/ core-annotations/src/main/java/org/apache/directory/server/core/factory/ test-framework/src/main/java/or...

Author: kayyagari
Date: Sat Jan  2 15:43:33 2010
New Revision: 895208

URL: http://svn.apache.org/viewvc?rev=895208&view=rev
Log:
o added config option to enable ChangeLog in CreateDS annotation
o removed the default enabling of ChangeLog in DefaultDirectoryServiceFactory
o updated the FrameworkRunner code accordingly to get the revision and performing revert operations

Modified:
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateDS.java
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
    directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java

Modified: directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateDS.java?rev=895208&r1=895207&r2=895208&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateDS.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateDS.java Sat Jan  2 15:43:33 2010
@@ -47,6 +47,9 @@
     /** flag to enable/disable anonymous access, default is false */
     boolean allowAnonAccess() default false;
     
+    /** flag to enable/disable changelog */
+    boolean enableChangeLog() default true;
+    
     /** The list of partitions to create */
     CreatePartition[] partitions() default {};
 }

Modified: directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java?rev=895208&r1=895207&r2=895208&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java Sat Jan  2 15:43:33 2010
@@ -69,6 +69,7 @@
             DirectoryService service = dsf.getDirectoryService();
             service.setAccessControlEnabled( dsBuilder.enableAccessControl() );
             service.setAllowAnonymousAccess( dsBuilder.allowAnonAccess() );
+            service.getChangeLog().setEnabled( dsBuilder.enableChangeLog() );
             
             dsf.init( dsBuilder.name() );
             

Modified: directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java?rev=895208&r1=895207&r2=895208&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java Sat Jan  2 15:43:33 2010
@@ -140,12 +140,6 @@
     }
     
     
-    private void initChangeLog()
-    {
-        directoryService.getChangeLog().setEnabled( true );
-    }
-    
-    
     private void initSystemPartition() throws Exception
     {
         // change the working directory to something that is unique
@@ -195,7 +189,6 @@
         
         // Init the service now
         initSchema();
-        initChangeLog();
         initSystemPartition();
         
         directoryService.startup();

Modified: directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java?rev=895208&r1=895207&r2=895208&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java (original)
+++ directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java Sat Jan  2 15:43:33 2010
@@ -25,6 +25,7 @@
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.changelog.ChangeLog;
 import org.apache.directory.server.core.factory.DSAnnotationProcessor;
 import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory;
 import org.apache.directory.server.core.factory.DirectoryServiceFactory;
@@ -120,8 +121,7 @@
                     if ( directoryService != null )
                     {
                         // yes : apply the class LDIFs only, and tag for reversion
-                        revision = directoryService.getChangeLog().getCurrentRevision();
-                        LOG.debug( "Create revision {}", revision );
+                        revision = getCurrentRevision( directoryService );
 
                         // apply the class LDIFs
                         DSAnnotationProcessor.applyLdifs( getDescription(), directoryService );
@@ -130,8 +130,12 @@
                     {
                         // No : define a default DS for the suite then
                         DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.DEFAULT;
-                        dsf.init( "default" + UUID.randomUUID().toString() );
+                        
                         directoryService = dsf.getDirectoryService();
+                        // enable CL explicitly cause we are not using DSAnnotationProcessor
+                        directoryService.getChangeLog().setEnabled( true );
+
+                        dsf.init( "default" + UUID.randomUUID().toString() );
                         
                         // Stores it into the suite
                         suite.setDirectoryService( directoryService );
@@ -140,8 +144,7 @@
                         DSAnnotationProcessor.applyLdifs( suite.getDescription(), directoryService );
                         
                         // Then tag for reversion and apply the class LDIFs
-                        revision = directoryService.getChangeLog().getCurrentRevision();
-                        LOG.debug( "Create revision {}", revision );
+                        revision = getCurrentRevision( directoryService );
                         
                         DSAnnotationProcessor.applyLdifs( getDescription(), directoryService );
                     }
@@ -150,8 +153,12 @@
                 {
                     // No : define a default class DS then
                     DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.DEFAULT;
-                    dsf.init( "default" + UUID.randomUUID().toString() );
+                    
                     directoryService = dsf.getDirectoryService();
+                    // enable CL explicitly cause we are not using DSAnnotationProcessor
+                    directoryService.getChangeLog().setEnabled( true );
+
+                    dsf.init( "default" + UUID.randomUUID().toString() );
                     
                     // Stores the defaultDS in the classDS
                     classDS = directoryService;
@@ -209,12 +216,11 @@
                 classDS.shutdown();
                 FileUtils.deleteDirectory( classDS.getWorkingDirectory() );
             }
-            else if ( revision < directoryService.getChangeLog().getCurrentRevision() )
+            else
             {
                 // Revert the ldifs
-                LOG.debug( "Revert revision {}", revision );
                 // We use a class or suite DS, just revert the current test's modifications
-                directoryService.revert( revision );
+                revert( directoryService, revision );
             }
         }
         catch ( Exception e )
@@ -268,8 +274,7 @@
             {
                 directoryService = classLdapServer.getDirectoryService();
                 
-                revision = directoryService.getChangeLog().getCurrentRevision();
-                LOG.debug( "Create revision {}", revision );
+                revision = getCurrentRevision( directoryService );
                 
                 DSAnnotationProcessor.applyLdifs( methodDescription, directoryService );
             }
@@ -287,8 +292,7 @@
                 directoryService = classDS;
                 
                 // apply the method LDIFs, and tag for reversion
-                revision = directoryService.getChangeLog().getCurrentRevision();
-                LOG.debug( "Create revision {}", revision );
+                revision = getCurrentRevision( directoryService );
                 
                 DSAnnotationProcessor.applyLdifs( methodDescription, directoryService );
             }
@@ -297,8 +301,7 @@
                 directoryService = suite.getDirectoryService();
                 
                 // apply the method LDIFs, and tag for reversion
-                revision = directoryService.getChangeLog().getCurrentRevision();
-                LOG.debug( "Create revision {}", revision );
+                revision = getCurrentRevision( directoryService );
                 
                 DSAnnotationProcessor.applyLdifs( methodDescription, directoryService );
             }
@@ -333,10 +336,10 @@
                 methodDS.shutdown();
                 FileUtils.deleteDirectory( methodDS.getWorkingDirectory() );
             }
-            else if ( ( revision < directoryService.getChangeLog().getCurrentRevision() ) )
+            else
             {
                 // We use a class or suite DS, just revert the current test's modifications
-                directoryService.revert( revision );
+                revert( directoryService, revision );
             }
         }
         catch ( Exception e )
@@ -366,4 +369,34 @@
     {
         return suite;
     }
+    
+    
+    private long getCurrentRevision( DirectoryService dirService ) throws Exception
+    {
+        if( ( dirService != null ) && ( dirService.getChangeLog().isEnabled() ) )
+        {
+            long revision = dirService.getChangeLog().getCurrentRevision(); 
+            LOG.debug( "Create revision {}", revision );
+
+            return revision;
+        }
+        
+        return 0;
+    }
+    
+    
+    private void revert( DirectoryService dirService, long revision ) throws Exception
+    {
+        if ( dirService == null )
+        {
+            return;
+        }
+
+        ChangeLog cl = dirService.getChangeLog();
+        if ( cl.isEnabled() && ( revision < cl.getCurrentRevision() ) )
+        {
+            LOG.debug( "Revert revision {}", revision );
+            dirService.revert( revision );
+        }
+    }
 }