directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r744666 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/ core/src/main/java/org/apache/directory/server/core/operational/ core/src/test/java/org/apache/directory/server/core/authz/support/ core/src/test/j...
Date Sun, 15 Feb 2009 13:27:43 GMT
Author: elecharny
Date: Sun Feb 15 13:27:42 2009
New Revision: 744666

URL: http://svn.apache.org/viewvc?rev=744666&view=rev
Log:
o Injected UUID and CSN for every new entry in the OperationalAttributes interceptor
o Used the Java 5 UUID class to generate the UUID
o Added a CSNFactory in directoryService in order to be able to generate CSN accordingly to
the replicaId
o Added a replicaId info in the directoryService
o Fixed the tests to accept the previous modifications

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
    directory/apacheds/trunk/server-xml/src/main/resources/server.xml

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=744666&r1=744665&r2=744666&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Sun Feb 15 13:27:42 2009
@@ -166,6 +166,12 @@
     
     /** A flag to tell if the userPassword attribute's value must be hidden */
     private boolean passwordHidden = false;
+    
+    /** The service's CSN factory */
+    private CSNFactory csnFactory;
+    
+    /** The directory instance replication ID */
+    private int replicaId;
 
     /** remove me after implementation is completed */
     private static final String PARTIAL_IMPL_WARNING =
@@ -223,6 +229,8 @@
         }
         
         SerializableComparator.setRegistry( registries.getComparatorRegistry() );
+        
+        csnFactory = new CSNFactory();
     }
 
 
@@ -1608,4 +1616,32 @@
         
         return null;
     }
+
+
+    /**
+     * Get a new CSN
+     * @return The CSN generated for this directory service
+     */
+    public CSN getCSN()
+    {
+        return csnFactory.newInstance( replicaId );
+    }
+
+
+    /**
+     * @return the replicaId
+     */
+    public int getReplicaId()
+    {
+        return replicaId;
+    }
+
+
+    /**
+     * @param replicaId the replicaId to set
+     */
+    public void setReplicaId( int replicaId )
+    {
+        this.replicaId = replicaId;
+    }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=744666&r1=744665&r2=744666&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
Sun Feb 15 13:27:42 2009
@@ -430,4 +430,23 @@
      * @return
      */
     Interceptor getInterceptor( String interceptorName );
+    
+    
+    /**
+     * Get a new CSN
+     * @return The CSN generated for this directory service
+     */
+    CSN getCSN();
+
+
+    /**
+     * @return the replicaId
+     */
+    int getReplicaId();
+
+
+    /**
+     * @param replicaId the replicaId to set
+     */
+    void setReplicaId( int replicaId );
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java?rev=744666&r1=744665&r2=744666&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
Sun Feb 15 13:27:42 2009
@@ -25,6 +25,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.UUID;
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.constants.ServerDNConstants;
@@ -64,6 +65,7 @@
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.UsageEnum;
 import org.apache.directory.shared.ldap.util.DateUtils;
+import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
  
@@ -155,6 +157,12 @@
 
     /**
      * Adds extra operational attributes to the entry before it is added.
+     * 
+     * We add thos attributes :
+     * - creatorsName
+     * - createTimestamp
+     * - entryCSN
+     * - entryUUID 
      */
     public void add( NextInterceptor nextInterceptor, AddOperationContext opContext )
         throws Exception
@@ -165,9 +173,7 @@
 
         entry.put( SchemaConstants.CREATORS_NAME_AT, principal );
         
-        EntryAttribute createTimeStamp = new DefaultServerAttribute( CREATE_TIMESTAMP_ATTRIBUTE_TYPE
);
-        
-        if ( opContext.getEntry().contains( createTimeStamp ) )
+        if ( opContext.getEntry().containsAttribute( CREATE_TIMESTAMP_ATTRIBUTE_TYPE ) )
         {
             // As we already have a CreateTimeStamp value in the context, use it, but only
if
             // the principal is admin
@@ -188,6 +194,11 @@
             entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime()
);
         }
         
+        // Add the UUID and the entryCSN. The UUID is stored as a byte[] representation of

+        // its String value
+        entry.put( ApacheSchemaConstants.ENTRY_UUID_AT, StringTools.getBytesUtf8( UUID.randomUUID().toString()
) );
+        entry.put( ApacheSchemaConstants.ENTRY_CSN_AT, service.getCSN().getBytes() );
+        
         nextInterceptor.add( opContext );
     }
 

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java?rev=744666&r1=744665&r2=744666&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
Sun Feb 15 13:27:42 2009
@@ -20,6 +20,7 @@
 package org.apache.directory.server.core.authz.support;
 
 
+import org.apache.directory.server.core.CSN;
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DefaultCoreSession;
 import org.apache.directory.server.core.DefaultDirectoryService;
@@ -842,6 +843,24 @@
         {
             return null;
         }
+        
+        
+        public CSN getCSN()
+        {
+            return null;
+        }
+        
+        
+        public int getReplicaId()
+        {
+            return 0;
+        }
+        
+        
+        public void setReplicaId( int replicaId )
+        {
+            
+        }
     }
 
     

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java?rev=744666&r1=744665&r2=744666&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
Sun Feb 15 13:27:42 2009
@@ -22,6 +22,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.directory.server.core.CSN;
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DefaultCoreSession;
 import org.apache.directory.server.core.DirectoryService;
@@ -651,5 +652,23 @@
         {
             return null;
         }
+        
+        
+        public CSN getCSN()
+        {
+            return null;
+        }
+        
+        
+        public int getReplicaId()
+        {
+            return 0;
+        }
+        
+        
+        public void setReplicaId( int replicaId )
+        {
+            
+        }
     }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java?rev=744666&r1=744665&r2=744666&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
Sun Feb 15 13:27:42 2009
@@ -29,7 +29,6 @@
 import static org.junit.Assert.fail;
 
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -1169,7 +1168,7 @@
         
         // ensure that all operational attributes are returned
         // and no user attributes
-        assertEquals( 2, attrs.size() );
+        assertEquals( 4, attrs.size() );
         assertNull( attrs.get( "cn" ) );
         assertNull( attrs.get( "sn" ) );
         assertNull( attrs.get( "objectClass" ) );
@@ -1177,6 +1176,8 @@
         assertNull( attrs.get( "description" ) );
         assertNotNull( attrs.get( "createtimestamp" ) );
         assertNotNull( attrs.get( "creatorsname" ) );
+        assertNotNull( attrs.get( "entryuuid" ) );
+        assertNotNull( attrs.get( "entrycsn" ) );
     }
     
 
@@ -1201,7 +1202,7 @@
         Attributes attrs = result.getAttributes();
         
         // ensure that all user attributes are returned
-        assertEquals( 8, attrs.size() );
+        assertEquals( 10, attrs.size() );
         assertNotNull( attrs.get( "cn" ) );
         assertNotNull( attrs.get( "sn" ) );
         assertNotNull( attrs.get( "objectClass" ) );
@@ -1210,6 +1211,8 @@
         assertNotNull( attrs.get( "description" ) );
         assertNotNull( attrs.get( "createtimestamp" ) );
         assertNotNull( attrs.get( "creatorsname" ) );
+        assertNotNull( attrs.get( "entryuuid" ) );
+        assertNotNull( attrs.get( "entrycsn" ) );
     }
 
 
@@ -1402,7 +1405,6 @@
             { "(description=*\\28*)", "(description=*\\29*)", "(description=*\\2A*)", "(description=*\\5C*)"
};
         for ( String filter : filters )
         {
-            HashMap<String, Attributes> map = new HashMap<String, Attributes>();
             NamingEnumeration<SearchResult> res = ctx.search( "", filter, controls
);
             assertTrue( res.hasMore() );
             SearchResult result = res.next();

Modified: directory/apacheds/trunk/server-xml/src/main/resources/server.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-xml/src/main/resources/server.xml?rev=744666&r1=744665&r2=744666&view=diff
==============================================================================
--- directory/apacheds/trunk/server-xml/src/main/resources/server.xml (original)
+++ directory/apacheds/trunk/server-xml/src/main/resources/server.xml Sun Feb 15 13:27:42
2009
@@ -25,6 +25,7 @@
               xmlns="http://apacheds.org/config/1.0">
 
   <defaultDirectoryService id="directoryService" instanceId="default"
+                           replicaId="1"
                            workingDirectory="example.com"
                            allowAnonymousAccess="true"
                            accessControlEnabled="false"



Mime
View raw message