directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r895505 - in /directory/shared/branches/shared-schema/ldap/src: main/antlr/ main/java/org/apache/directory/shared/ldap/name/ test/java/org/apache/directory/shared/ldap/name/
Date Sun, 03 Jan 2010 23:13:59 GMT
Author: elecharny
Date: Sun Jan  3 23:13:57 2010
New Revision: 895505

URL: http://svn.apache.org/viewvc?rev=895505&view=rev
Log:
Fixed some issues with AVAs

Modified:
    directory/shared/branches/shared-schema/ldap/src/main/antlr/distinguishedName.g
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/ComplexLdapDnParser.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
    directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java

Modified: directory/shared/branches/shared-schema/ldap/src/main/antlr/distinguishedName.g
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/antlr/distinguishedName.g?rev=895505&r1=895504&r2=895505&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/antlr/distinguishedName.g (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/antlr/distinguishedName.g Sun Jan
 3 23:13:57 2010
@@ -148,6 +148,7 @@
     }
     static class UpAndNormValue
     {
+        String name = "";
         String upValue = "";
         Object normValue = "";
         String trailingSpaces = "";
@@ -299,19 +300,31 @@
         {
             try
             {
+                upName += value.name;
+                AttributeTypeAndValue ava = null;
+            
                 if ( value.normValue instanceof String )
                 {
-                    rdn.addAttributeTypeAndValue( type, type, 
+                    ava = new AttributeTypeAndValue(
+                        type,
+                        type,
                         new ClientStringValue( value.upValue ), 
-                        new ClientStringValue( (String)value.normValue ) );
+                        new ClientStringValue( (String)value.normValue ),
+                        upName
+                    );
                 }
                 else
                 {
-                    rdn.addAttributeTypeAndValue( type, type, 
+                    ava = new AttributeTypeAndValue(
+                        type,
+                        type,
                         new ClientStringValue( value.upValue ), 
-                        new ClientBinaryValue( (byte[])value.normValue ) );
+                        new ClientBinaryValue( (byte[])value.normValue ),
+                        upName
+                    );
                 }
-                { upName += value.upValue + value.trailingSpaces; }
+           
+                rdn.addAttributeTypeAndValue( ava );
             }
             catch ( InvalidNameException e )
             {
@@ -502,12 +515,14 @@
             tmp = lutf1 
             { 
                 value.upValue += tmp;
+                value.name += tmp;
                 bb.append( StringTools.getBytesUtf8( tmp ) ); 
             }
             |
             tmp = utfmb 
             {
                 value.upValue += tmp;
+                value.name += tmp;
                 bb.append( StringTools.getBytesUtf8( tmp ) );
             }
             |
@@ -517,12 +532,14 @@
             tmp = sutf1
             {
                 value.upValue += tmp;
+                value.name += tmp;
                 bb.append( StringTools.getBytesUtf8( tmp ) ); 
             }
             |
             tmp = utfmb 
             {
                 value.upValue += tmp;
+                value.name += tmp;
                 bb.append( StringTools.getBytesUtf8( tmp ) ); 
             }
             |
@@ -658,7 +675,8 @@
     (
         ESCESC 
         { 
-            value.upValue += "\\\\";
+            value.upValue += "\\";
+            value.name += "\\\\";
             pair = StringTools.getBytesUtf8( "\\" );
         } 
     )
@@ -666,16 +684,18 @@
     (
         ESCSHARP 
         { 
-            value.upValue += "\\#";
+            value.upValue += "#";
+            value.name += "\\#";
             pair = StringTools.getBytesUtf8( "#" );
         } 
     )
     |
     ( 
-        ESC { value.upValue += "\\"; }
+        ESC
         tmp = special 
         { 
             value.upValue += tmp;
+            value.name += "\\" + tmp;
             pair = StringTools.getBytesUtf8( tmp ); 
         }
     )
@@ -683,7 +703,8 @@
     ( 
         hexpair:HEXPAIR 
         { 
-            value.upValue += "\\" + hexpair.getText(); 
+            value.upValue += hexpair.getText();
+            value.name += "\\" + hexpair.getText();
             pair = StringTools.toByteArray( hexpair.getText() ); 
         } 
     )
@@ -724,11 +745,3 @@
     )
     ;
 
-
-
-
-
-
-    
-    
-    

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/ComplexLdapDnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/ComplexLdapDnParser.java?rev=895505&r1=895504&r2=895505&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/ComplexLdapDnParser.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/ComplexLdapDnParser.java
Sun Jan  3 23:13:57 2010
@@ -46,6 +46,7 @@
     public void parseDn( String name, List<Rdn> rdns ) throws InvalidNameException
     {
         AntlrDnParser dnParser = new AntlrDnParser( new AntlrDnLexer( new StringReader( name
) ) );
+        
         try
         {
             dnParser.relativeDistinguishedNames( rdns );

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java?rev=895505&r1=895504&r2=895505&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java
Sun Jan  3 23:13:57 2010
@@ -82,7 +82,7 @@
     
     void parseDn( String name, List<Rdn> rdns ) throws InvalidNameException
     {
-        if ( name == null || name.trim().length() == 0 )
+        if ( ( name == null ) || ( name.trim().length() == 0 ) )
         {
             // We have an empty DN, just get out of the function.
             return;

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java?rev=895505&r1=895504&r2=895505&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
Sun Jan  3 23:13:57 2010
@@ -402,7 +402,7 @@
                     sb.append( ',' );
                 }
 
-                sb.append( rdn );
+                sb.append( rdn.getNormName() );
             }
 
             String newNormName = sb.toString();
@@ -1462,13 +1462,16 @@
             }
             else
             {
-                OidNormalizer oidNormalizer = oidsMap.get( type );
+                OidNormalizer oidNormalizer = oidsMap.get( type.toLowerCase() );
 
                 if ( oidNormalizer != null )
                 {
-                    return new AttributeTypeAndValue( atav.getUpType(), oidNormalizer.getAttributeTypeOid(),

-                            atav.getUpValue(),
-                            oidNormalizer.getNormalizer().normalize( atav.getNormValue()
) );
+                    return new AttributeTypeAndValue( 
+                        atav.getUpType(), 
+                        oidNormalizer.getAttributeTypeOid(), 
+                        atav.getUpValue(),
+                        oidNormalizer.getNormalizer().normalize( atav.getNormValue() ),
+                        atav.getUpName() );
 
                 }
                 else
@@ -1530,7 +1533,7 @@
             for ( AttributeTypeAndValue val:rdnCopy )
             {
                 AttributeTypeAndValue newAtav = atavOidToName( val, oidsMap );
-                rdn.addAttributeTypeAndValue( val.getUpType(), newAtav.getNormType(), val.getUpValue(),
newAtav.getNormValue() );
+                rdn.addAttributeTypeAndValue( newAtav );
             }
 
         }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java?rev=895505&r1=895504&r2=895505&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
Sun Jan  3 23:13:57 2010
@@ -490,7 +490,7 @@
         {
             case 0:
                 // This is the first AttributeTypeAndValue. Just stores it.
-                this.atav = value;
+                atav = value;
                 nbAtavs = 1;
                 atavType = normalizedType;
                 return;
@@ -502,9 +502,9 @@
                 atavs = new TreeSet<AttributeTypeAndValue>();
 
                 // and store the existing AttributeTypeAndValue into it.
-                atavs.add( this.atav );
+                atavs.add( atav );
                 atavTypes = new MultiValueMap();
-                atavTypes.put( atavType, this.atav );
+                atavTypes.put( atavType, atav );
 
                 this.atav = null;
 

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=895505&r1=895504&r2=895505&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Sun Jan  3 23:13:57 2010
@@ -3400,7 +3400,7 @@
         assertEquals( " cn = Amos\\,Tori ", dn1.getRdn().getUpName() );
         AttributeTypeAndValue atav1 = dn1.getRdn().getAtav();
         assertEquals( "cn", atav1.getUpType() );
-        assertEquals( "Amos\\,Tori", atav1.getUpValue().getString() );
+        assertEquals( "Amos,Tori", atav1.getUpValue().getString() );
 
         // antlr parser: hexstring with trailing spaces
         LdapDN dn3 = new LdapDN( " cn = #414243 , ou=system " );
@@ -3564,8 +3564,7 @@
         assertEquals( "ou", atav.getUpType() );
         assertEquals( "Example", atav.getUpValue().get() );
         
-        // Wrong !!! TODO : fix me
-        assertEquals( "  ou =  Example ", atav.getUpName() );
+        assertEquals( "ou  =  Example ", atav.getUpName() );
         
         assertEquals( 2, rdn.getNbAtavs() );
         
@@ -3603,7 +3602,7 @@
         assertEquals( "ex+mple",rdn.getNormValue() );
         assertEquals( "2.5.4.11=ex\\+mple", rdn.getNormName() );
         assertEquals( "ou", rdn.getUpType() );
-        assertEquals( "Ex\\+mple",rdn.getUpValue() );
+        assertEquals( "Ex+mple",rdn.getUpValue() );
         assertEquals( "  ou  =  Ex\\+mple ", rdn.getUpName() );
         
         AttributeTypeAndValue atav = rdn.getAtav();
@@ -3613,10 +3612,10 @@
         assertEquals( "ex+mple", atav.getNormValue().get() );
         
         assertEquals( "ou", atav.getUpType() );
-        assertEquals( "Ex\\+mple", atav.getUpValue().get() );
+        assertEquals( "Ex+mple", atav.getUpValue().get() );
         
         // Wrong !!! TODO : fix me
-        assertEquals( "  ou =  Ex\\+mple ", atav.getUpName() );
+        assertEquals( "ou  =  Ex\\+mple", atav.getUpName() );
     }
 
     
@@ -3625,11 +3624,25 @@
     {
         LdapDN dn = new LdapDN( "  OU  =  Ex\\+mple + ou = T\\+ST ,  ou  =  COM " );
         
+        // Before normalization
+        assertEquals( "  OU  =  Ex\\+mple + ou = T\\+ST ,  ou  =  COM ", dn.getName() );
+        assertEquals( "ou=Ex\\+mple+ou=T\\+ST,ou=COM", dn.getNormName() );
+        
+        // Check the first RDN
+        Rdn rdn = dn.getRdn();
+        assertEquals( "OU", rdn.getUpType() );
+        assertEquals( "ou", rdn.getNormType() );
+        
+        assertEquals( "Ex+mple",rdn.getUpValue() );
+        assertEquals( "Ex+mple",rdn.getNormValue() );
+        
+        // Now normalize the DN
         dn.normalize( oidOids );
+        
         assertEquals( "  OU  =  Ex\\+mple + ou = T\\+ST ,  ou  =  COM ", dn.getName() );
         assertEquals( "2.5.4.11=ex\\+mple+2.5.4.11=t\\+st,2.5.4.11=com", dn.getNormName()
);
         
-        Rdn rdn = dn.getRdn();
+        rdn = dn.getRdn();
         assertEquals( "  OU  =  Ex\\+mple + ou = T\\+ST ", rdn.getUpName() );
         assertEquals( "2.5.4.11=ex\\+mple+2.5.4.11=t\\+st", rdn.getNormName() );
 
@@ -3637,22 +3650,19 @@
         assertEquals( "OU", rdn.getUpType() );
         assertEquals( "2.5.4.11", rdn.getNormType() );
         
-        // TODO : Wrong, fix me
-        //assertEquals( "Ex+mple",rdn.getUpValue() );
+        assertEquals( "Ex+mple",rdn.getUpValue() );
         assertEquals( "ex+mple",rdn.getNormValue() );
         
         // The first ATAV
         AttributeTypeAndValue atav = rdn.getAtav();
         
-        // TODO : Wrong, fix me
-        //assertEquals( "  OU  =  Ex\\+mple ", atav.getUpName() );
+        assertEquals( "OU  =  Ex\\+mple ", atav.getUpName() );
         assertEquals( "2.5.4.11=ex\\+mple", atav.getNormName() );
         
         assertEquals( "2.5.4.11", atav.getNormType() );
         assertEquals( "OU", atav.getUpType() );
         
-        // TODO : Wrong, fix me
-        //assertEquals( "Ex+mple", atav.getUpValue().get() );
+        assertEquals( "Ex+mple", atav.getUpValue().get() );
         assertEquals( "ex+mple", atav.getNormValue().get() );
         
         assertEquals( 2, rdn.getNbAtavs() );
@@ -3666,7 +3676,7 @@
                 continue;
             }
             
-            assertEquals( " ou = T\\+ST ", atav.getUpName() );
+            assertEquals( "ou = T\\+ST ", atav.getUpName() );
             assertEquals( "2.5.4.11=t\\+st", atav.getNormName() );
 
             assertEquals( "ou", atav.getUpType() );



Mime
View raw message