directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r931631 - in /directory/shared/trunk: ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/ ldap-schema/src/main/resources/schema/ou=schema/cn=apache/ou=attributetypes/ ldap/src/main/java/org/apache/director...
Date Wed, 07 Apr 2010 18:01:02 GMT
Author: kayyagari
Date: Wed Apr  7 18:01:01 2010
New Revision: 931631

URL: http://svn.apache.org/viewvc?rev=931631&view=rev
Log:
changes done as part of implementing DIRSERVER-1492
 o a new method was added to DN class to add normalized RDNs from left to right in that order
 o a new field parentId was added to RDN class
 o RdnSerializer was updated to persist the newly added parentId field's value
 o DefaultServerEntry's serialization was updated to store the RDN alone
 o added a new meta schema attribute type for representing RDN index's attribute id
 o upated the schema test cases

Added:
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=apache/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.50.ldif
Modified:
    directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerEnableDisableLoadTest.java
    directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerLoadTest.java
    directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerLoadWithDepsTest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnSerializer.java

Modified: directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerEnableDisableLoadTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerEnableDisableLoadTest.java?rev=931631&r1=931630&r2=931631&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerEnableDisableLoadTest.java
(original)
+++ directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerEnableDisableLoadTest.java
Wed Apr  7 18:01:01 2010
@@ -145,14 +145,14 @@ public class SchemaManagerEnableDisableL
         assertEquals( 0, disabled.size() );
 
         assertTrue( schemaManager.getErrors().isEmpty() );
-        assertEquals( 341, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( 342, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 48, schemaManager.getComparatorRegistry().size() );
         assertEquals( 48, schemaManager.getMatchingRuleRegistry().size() );
         assertEquals( 48, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 111, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 66, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 71, schemaManager.getLdapSyntaxRegistry().size() );
-        assertEquals( 571, schemaManager.getGlobalOidRegistry().size() );
+        assertEquals( 572, schemaManager.getGlobalOidRegistry().size() );
 
         assertEquals( 11, schemaManager.getRegistries().getLoadedSchemas().size() );
         assertNull( schemaManager.getRegistries().getLoadedSchema( "nis" ) );
@@ -190,14 +190,14 @@ public class SchemaManagerEnableDisableL
         assertNotNull( schemaManager.lookupAttributeTypeRegistry( "gecos" ) );
 
         assertTrue( schemaManager.getErrors().isEmpty() );
-        assertEquals( 368, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( 369, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 49, schemaManager.getComparatorRegistry().size() );
         assertEquals( 49, schemaManager.getMatchingRuleRegistry().size() );
         assertEquals( 49, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 124, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 68, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 73, schemaManager.getLdapSyntaxRegistry().size() );
-        assertEquals( 614, schemaManager.getGlobalOidRegistry().size() );
+        assertEquals( 615, schemaManager.getGlobalOidRegistry().size() );
 
         assertEquals( 12, schemaManager.getRegistries().getLoadedSchemas().size() );
         assertNotNull( schemaManager.getRegistries().getLoadedSchema( "nis" ) );
@@ -230,14 +230,14 @@ public class SchemaManagerEnableDisableL
         }
 
         assertTrue( schemaManager.getErrors().isEmpty() );
-        assertEquals( 341, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( 342, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 48, schemaManager.getComparatorRegistry().size() );
         assertEquals( 48, schemaManager.getMatchingRuleRegistry().size() );
         assertEquals( 48, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 111, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 66, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 71, schemaManager.getLdapSyntaxRegistry().size() );
-        assertEquals( 571, schemaManager.getGlobalOidRegistry().size() );
+        assertEquals( 572, schemaManager.getGlobalOidRegistry().size() );
 
         assertEquals( 11, schemaManager.getRegistries().getLoadedSchemas().size() );
         assertNull( schemaManager.getRegistries().getLoadedSchema( "nis" ) );

Modified: directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerLoadTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerLoadTest.java?rev=931631&r1=931630&r2=931631&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerLoadTest.java
(original)
+++ directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerLoadTest.java
Wed Apr  7 18:01:01 2010
@@ -279,14 +279,14 @@ public class SchemaManagerLoadTest
         assertTrue( schemaManager.load( "apache" ) );
 
         assertTrue( schemaManager.getErrors().isEmpty() );
-        assertEquals( 145, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( 146, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 43, schemaManager.getComparatorRegistry().size() );
         assertEquals( 43, schemaManager.getMatchingRuleRegistry().size() );
         assertEquals( 43, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 53, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 62, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
-        assertEquals( 307, schemaManager.getGlobalOidRegistry().size() );
+        assertEquals( 308, schemaManager.getGlobalOidRegistry().size() );
 
         assertEquals( 3, schemaManager.getRegistries().getLoadedSchemas().size() );
         assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );

Modified: directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerLoadWithDepsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerLoadWithDepsTest.java?rev=931631&r1=931630&r2=931631&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerLoadWithDepsTest.java
(original)
+++ directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerLoadWithDepsTest.java
Wed Apr  7 18:01:01 2010
@@ -164,14 +164,14 @@ public class SchemaManagerLoadWithDepsTe
         schemaManager.loadWithDeps( "apache" );
 
         assertTrue( schemaManager.getErrors().isEmpty() );
-        assertEquals( 145, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( 146, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 43, schemaManager.getComparatorRegistry().size() );
         assertEquals( 43, schemaManager.getMatchingRuleRegistry().size() );
         assertEquals( 43, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 53, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 62, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
-        assertEquals( 307, schemaManager.getGlobalOidRegistry().size() );
+        assertEquals( 308, schemaManager.getGlobalOidRegistry().size() );
 
         assertEquals( 3, schemaManager.getRegistries().getLoadedSchemas().size() );
         assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );
@@ -248,14 +248,14 @@ public class SchemaManagerLoadWithDepsTe
         schemaManager.loadWithDeps( "other" );
 
         assertTrue( schemaManager.getErrors().isEmpty() );
-        assertEquals( 176, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( 177, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 48, schemaManager.getComparatorRegistry().size() );
         assertEquals( 48, schemaManager.getMatchingRuleRegistry().size() );
         assertEquals( 48, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 66, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 66, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 71, schemaManager.getLdapSyntaxRegistry().size() );
-        assertEquals( 361, schemaManager.getGlobalOidRegistry().size() );
+        assertEquals( 362, schemaManager.getGlobalOidRegistry().size() );
 
         assertEquals( 5, schemaManager.getRegistries().getLoadedSchemas().size() );
         assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );

Added: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=apache/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.50.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dapache/ou%3Dattributetypes/m-oid%3D1.3.6.1.4.1.18060.0.4.1.2.50.ldif?rev=931631&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=apache/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.50.ldif
(added)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=apache/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.50.ldif
Wed Apr  7 18:01:01 2010
@@ -0,0 +1,17 @@
+dn: m-oid=1.3.6.1.4.1.18060.0.4.1.2.50,ou=attributeTypes,cn=apache,ou=schema
+objectClass: metaAttributeType
+objectClass: metaTop
+objectClass: top
+m-collective: FALSE
+m-description: Index attribute RDN with values both user provided and normalized based on
schema
+m-equality: exactDnAsStringMatch
+m-name: apacheRdn
+m-nousermodification: TRUE
+m-obsolete: FALSE
+m-oid: 1.3.6.1.4.1.18060.0.4.1.2.50
+m-singlevalue: FALSE
+m-syntax: 1.3.6.1.4.1.1466.115.121.1.12
+m-usage: DSA_OPERATION
+createTimestamp: 20100401170751Z
+creatorsName: 0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
+entryCSN: 20100401200751.330000Z#000000#000#000000

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java?rev=931631&r1=931630&r2=931631&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java
Wed Apr  7 18:01:01 2010
@@ -34,7 +34,8 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.name.DN;
-import org.apache.directory.shared.ldap.name.DnSerializer;
+import org.apache.directory.shared.ldap.name.RDN;
+import org.apache.directory.shared.ldap.name.RdnSerializer;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -2298,8 +2299,8 @@ public final class DefaultServerEntry ex
      * Serialize a server entry.
      * 
      * The structure is the following :
-     * 
-     * <b>[DN]</b> : The entry DN. can be empty
+     * <b>[a byte] : if the DN is empty 0 will be written else 1
+     * <b>[RDN]</b> : The entry's RDN.
      * <b>[numberAttr]</b> : the bumber of attributes. Can be 0 
      * <b>[attribute's oid]*</b> : The attribute's OID to get back 
      * the attributeType on deserialization
@@ -2311,8 +2312,17 @@ public final class DefaultServerEntry ex
     public void serialize( ObjectOutput out ) throws IOException
     {
         // First, the DN
-        // Write the DN
-        DnSerializer.serialize( dn, out );
+        // Write the RDN of the DN
+        
+        if( dn.getRdn() == null )
+        {
+            out.writeByte( 0 );
+        }
+        else
+        {
+            out.writeByte( 1 );
+            RdnSerializer.serialize( dn.getRdn(), out );
+        }
         
         // Then the attributes.
         out.writeInt( attributes.size() );
@@ -2360,7 +2370,14 @@ public final class DefaultServerEntry ex
     public void deserialize( ObjectInput in ) throws IOException, ClassNotFoundException
     {
         // Read the DN
-        dn = DnSerializer.deserialize( in );
+        dn = new DN();
+
+        byte b = in.readByte();
+        if( b == 1 )
+        {
+            RDN rdn = RdnSerializer.deserialize( in );
+            dn.add( rdn );
+        }
         
         // Read the number of attributes
         int nbAttributes = in.readInt();

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java?rev=931631&r1=931630&r2=931631&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
Wed Apr  7 18:01:01 2010
@@ -1144,6 +1144,35 @@ public class DN implements Cloneable, Se
 
 
     /**
+     * Adds the RDNs in the left to right order
+     * i.e adding ou=users followed by ou=system forms the DN ou=users,ou=system 
+     * 
+     * @param newRdn the normalized RDN to be added
+     * @return the DN formed after adding the given RDN, this will already be in a normalized
form
+     *         cause of adding normalized RDNs
+     */
+    public DN addNormalizedInOrder( RDN newRdn )
+    {
+        rdns.add( newRdn );
+
+        if (rdns.size() == 1 )
+        {
+            normName = newRdn.getNormName();
+            upName = newRdn.getName();
+        }
+        else
+        {
+            normName = normName + "," + newRdn.getNormName();
+            upName = upName + "," + newRdn.getName();
+        }
+        
+        bytes = StringTools.getBytesUtf8( normName );
+
+        return this;
+    }
+    
+    
+    /**
      * Adds a single normalized RDN to the (leaf) end of this name.
      *
      * @param newRdn the RDN to add

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java?rev=931631&r1=931630&r2=931631&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java
Wed Apr  7 18:01:01 2010
@@ -112,7 +112,7 @@ public class RDN implements Cloneable, C
 {
     /** The LoggerFactory used by this class */
     protected static final Logger LOG = LoggerFactory.getLogger( RDN.class );
-    
+
     /** An empty RDN */
     public static final RDN EMPTY_RDN = new RDN();
 
@@ -184,6 +184,9 @@ public class RDN implements Cloneable, C
     /** Constant used in comparisons */
     public static final int EQUAL = 0;
 
+    /** parent RDN's id */
+    private long parentId = -1;
+
 
     /**
      * A empty constructor.
@@ -387,8 +390,8 @@ public class RDN implements Cloneable, C
                 break;
         }
     }
-    
-    
+
+
     /**
      * Transform a RDN by changing the value to its OID counterpart and
      * normalizing the value accordingly to its type.
@@ -404,12 +407,10 @@ public class RDN implements Cloneable, C
         normalize();
         this.upName = upName;
 
-        
         return this;
     }
 
 
-
     /**
      * Add a AttributeTypeAndValue to the current RDN
      *
@@ -975,7 +976,7 @@ public class RDN implements Cloneable, C
             return false;
         }
 
-        return compareTo( (RDN)rdn ) == EQUAL;
+        return compareTo( ( RDN ) rdn ) == EQUAL;
     }
 
 
@@ -1339,6 +1340,7 @@ public class RDN implements Cloneable, C
      * We should write all those ATAVs sequencially, following the 
      * structure :
      * 
+     * <li>parentId</li> The parent entry's Id
      * <li>nbAtavs</li> The number of ATAVs to write. Can't be 0.
      * <li>upName</li> The User provided RDN
      * <li>normName</li> The normalized RDN. It can be empty if the normalized
@@ -1355,6 +1357,9 @@ public class RDN implements Cloneable, C
      */
     public void writeExternal( ObjectOutput out ) throws IOException
     {
+        // write the parent Id first 
+        out.writeLong( parentId );
+
         out.writeInt( nbAtavs );
         out.writeUTF( upName );
 
@@ -1403,6 +1408,9 @@ public class RDN implements Cloneable, C
      */
     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
     {
+        // parent Id
+        parentId = in.readLong();
+
         // Read the ATAV number
         nbAtavs = in.readInt();
 
@@ -1459,4 +1467,25 @@ public class RDN implements Cloneable, C
     {
         return upName == null ? "" : upName;
     }
+
+
+    /**
+     * for INTERNAL use only
+     * @return long gives the parent ID of this RDN
+     */
+    public long _getParentId()
+    {
+        return parentId;
+    }
+
+
+    /**
+     * for INTERNAL use only
+     * @param parentId parent RDN's ID
+     */
+    public void _setParentId( long parentId )
+    {
+        this.parentId = parentId;
+    }
+
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnSerializer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnSerializer.java?rev=931631&r1=931630&r2=931631&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnSerializer.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnSerializer.java
Wed Apr  7 18:01:01 2010
@@ -62,6 +62,8 @@ public class RdnSerializer
      */
     public static void serialize( RDN rdn, ObjectOutput out ) throws IOException
     {
+        out.writeLong( rdn._getParentId() );
+        
         out.writeInt( rdn.getNbAtavs() );
         out.writeUTF( rdn.getName() );
         out.writeUTF( rdn.getNormName() );
@@ -101,6 +103,8 @@ public class RdnSerializer
      */
     public static RDN deserialize( ObjectInput in ) throws IOException
     {
+        long parentId = in.readLong();
+        
         // Read the ATAV number
         int nbAtavs = in.readInt();
         
@@ -121,6 +125,7 @@ public class RdnSerializer
         
         // Now creates the RDN
         RDN rdn = new RDN( length, start, upName, normName );
+        rdn._setParentId( parentId );
 
         // Read through the Atavs
         switch ( nbAtavs )



Mime
View raw message