directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r414765 - in /directory/branches/shared/optimization/ldap/src: main/antlr/ main/java/org/apache/directory/shared/ldap/aci/ main/java/org/apache/directory/shared/ldap/name/ main/java/org/apache/directory/shared/ldap/subtree/ test/java/org/ap...
Date Fri, 16 Jun 2006 07:31:52 GMT
Author: elecharny
Date: Fri Jun 16 00:31:51 2006
New Revision: 414765

URL: http://svn.apache.org/viewvc?rev=414765&view=rev
Log:
Get rid of OIDS_MAP and replaced it with a parameter received from the server

Modified:
    directory/branches/shared/optimization/ldap/src/main/antlr/ACIItem.g
    directory/branches/shared/optimization/ldap/src/main/antlr/subtree-specification.g
    directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemParser.java
    directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
    directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParser.java
    directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
    directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
    directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java

Modified: directory/branches/shared/optimization/ldap/src/main/antlr/ACIItem.g
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/ldap/src/main/antlr/ACIItem.g?rev=414765&r1=414764&r2=414765&view=diff
==============================================================================
--- directory/branches/shared/optimization/ldap/src/main/antlr/ACIItem.g (original)
+++ directory/branches/shared/optimization/ldap/src/main/antlr/ACIItem.g Fri Jun 16 00:31:51
2006
@@ -120,6 +120,7 @@
     private int m_precedence;
     private Set m_grantsAndDenials;
     private Set m_userPermissions;
+    private Map oidsMap;
     
     private Set chopBeforeExclusions;
     private Set chopAfterExclusions;
@@ -138,8 +139,9 @@
      *
      * @return the DnParser to be used for parsing Names
      */
-    public void init()
+    public void init( Map oidsMap )
     {
+    	this.oidsMap = oidsMap;
     }
 
     /**
@@ -488,7 +490,7 @@
         // A Dn can be considered as a set of attributeTypeAndValues
         // So, parse the set as a Dn and extract each attributeTypeAndValue
         LdapDN attributeTypeAndValueSetAsDn = new LdapDN( token.getText() );
-        attributeTypeAndValueSetAsDn.normalize();
+        attributeTypeAndValueSetAsDn.normalize( oidsMap );
         Enumeration attributeTypeAndValueSet = attributeTypeAndValueSetAsDn.getAll();
         while ( attributeTypeAndValueSet.hasMoreElements() )
         {
@@ -1153,7 +1155,7 @@
     token:SAFEUTF8STRING
     {
         name = new LdapDN( token.getText() );
-        name.normalize();
+        name.normalize( oidsMap );
         log.debug( "recognized a DistinguishedName: " + token.getText() );
     }
     ;

Modified: directory/branches/shared/optimization/ldap/src/main/antlr/subtree-specification.g
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/ldap/src/main/antlr/subtree-specification.g?rev=414765&r1=414764&r2=414765&view=diff
==============================================================================
--- directory/branches/shared/optimization/ldap/src/main/antlr/subtree-specification.g (original)
+++ directory/branches/shared/optimization/ldap/src/main/antlr/subtree-specification.g Fri
Jun 16 00:31:51 2006
@@ -21,6 +21,7 @@
 package org.apache.directory.shared.ldap.subtree;
 
 import java.util.Set;
+import java.util.Map;
 import java.util.HashSet;
 import java.util.ArrayList;
 
@@ -80,25 +81,28 @@
 
     private SubtreeSpecificationModifier ssModifier = null;
     
+    private Map oidsMap;
+    
     private ComponentsMonitor subtreeSpecificationComponentsMonitor = null;
 
     /**
      * Does nothing.
      */
-    public void init()
+    public void init( Map oidsMap )
     {
+    	this.oidsMap = oidsMap;
     }
     
     
     public void setNormalizerMappingResolver( NormalizerMappingResolver resolver )
     {
-    	this.resolver = resolver;
+    	this.resolver = resolver;
     }
     
     
     public boolean isNormalizing()
     {
-    	return this.resolver != null;
+    	return this.resolver != null;
     }
     
 
@@ -306,7 +310,7 @@
         name = new LdapDN( token.getText() );
         if ( isNormalizing() )
         {
-        	name.normalize();
+        	name.normalize( oidsMap );
         }
         log.debug( "recognized a DistinguishedName: " + token.getText() );
     }

Modified: directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemParser.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemParser.java?rev=414765&r1=414764&r2=414765&view=diff
==============================================================================
--- directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemParser.java
(original)
+++ directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemParser.java
Fri Jun 16 00:31:51 2006
@@ -20,6 +20,7 @@
 
 import java.io.StringReader;
 import java.text.ParseException;
+import java.util.Map;
 
 import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
 
@@ -49,12 +50,12 @@
     /**
      * Creates a ACIItem parser.
      */
-    public ACIItemParser()
+    public ACIItemParser( Map oidsMap )
     {
         this.lexer = new ReusableAntlrACIItemLexer( new StringReader( "" ) );
         this.parser = new ReusableAntlrACIItemParser( lexer );
 
-        this.parser.init(); // this method MUST be called while we cannot do
+        this.parser.init( oidsMap ); // this method MUST be called while we cannot do
         // constructor overloading for antlr generated parser
         this.isNormalizing = false;
     }
@@ -63,13 +64,13 @@
     /**
      * Creates a normalizing ACIItem parser.
      */
-    public ACIItemParser(NameComponentNormalizer normalizer)
+    public ACIItemParser(NameComponentNormalizer normalizer, Map oidsMap )
     {
         this.lexer = new ReusableAntlrACIItemLexer( new StringReader( "" ) );
         this.parser = new ReusableAntlrACIItemParser( lexer );
 
         this.parser.setNormalizer( normalizer );
-        this.parser.init(); // this method MUST be called while we cannot do
+        this.parser.init( oidsMap ); // this method MUST be called while we cannot do
         // constructor overloading for antlr generated parser
         this.isNormalizing = true;
     }

Modified: directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java?rev=414765&r1=414764&r2=414765&view=diff
==============================================================================
--- directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
(original)
+++ directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
Fri Jun 16 00:31:51 2006
@@ -92,10 +92,6 @@
     /** A null LdapDN */
     public static final LdapDN EMPTY_LDAPDN = new LdapDN();
     
-    /** The OIDs map container */
-    private static Map OIDS_MAP;
-
-
     // ~ Methods
     // ------------------------------------------------------------------------------------
 
@@ -1220,7 +1216,7 @@
     }
 
 
-    private static AttributeTypeAndValue atavOidToName( AttributeTypeAndValue atav )
+    private static AttributeTypeAndValue atavOidToName( AttributeTypeAndValue atav, Map oidsMap
)
         throws InvalidNameException, NamingException
     {
         String type = StringTools.trim( atav.getType() );
@@ -1232,13 +1228,13 @@
 
         if ( StringTools.isNotEmpty( StringTools.lowerCase( type ) ) )
         {
-            if ( OIDS_MAP == null )
+            if ( oidsMap == null )
             {
                 return atav;
             }
             else
             {
-                OidNormalizer oidNormalizer = ( OidNormalizer ) OIDS_MAP.get( type );
+                OidNormalizer oidNormalizer = ( OidNormalizer ) oidsMap.get( type );
     
                 if ( oidNormalizer != null )
                 {
@@ -1275,7 +1271,7 @@
      *             If
      * @throws NamingException
      */
-    private static void rdnOidToName( Rdn rdn ) throws InvalidNameException, NamingException
+    private static void rdnOidToName( Rdn rdn, Map oidsMap ) throws InvalidNameException,
NamingException
     {
         if ( rdn.getNbAtavs() > 1 )
         {
@@ -1289,7 +1285,7 @@
             while ( atavs.hasNext() )
             {
                 Object val = atavs.next();
-                AttributeTypeAndValue newAtav = atavOidToName( ( AttributeTypeAndValue )
val );
+                AttributeTypeAndValue newAtav = atavOidToName( ( AttributeTypeAndValue )
val, oidsMap );
                 rdn.addAttributeTypeAndValue( newAtav.getType(), newAtav.getValue() );
             }
 
@@ -1305,13 +1301,13 @@
 
             if ( StringTools.isNotEmpty( StringTools.lowerCase( type ) ) )
             {
-                if ( OIDS_MAP == null )
+                if ( oidsMap == null )
                 {
                     return;
                 }
                 else
                 {
-                    OidNormalizer oidNormalizer = ( OidNormalizer ) OIDS_MAP.get( type );
+                    OidNormalizer oidNormalizer = ( OidNormalizer ) oidsMap.get( type );
     
                     if ( oidNormalizer != null )
                     {
@@ -1358,9 +1354,9 @@
      * @throws InvalidNameException
      *             If the DN is invalid
      */
-    public static LdapDN normalize( LdapDN dn ) throws InvalidNameException, NamingException
+    public static LdapDN normalize( LdapDN dn, Map oidsMap ) throws InvalidNameException,
NamingException
     {
-        if ( ( dn == null ) || ( dn.size() == 0 ) || ( OIDS_MAP == null ) || ( OIDS_MAP.size()
== 0 ) )
+        if ( ( dn == null ) || ( dn.size() == 0 ) || ( oidsMap == null ) || ( oidsMap.size()
== 0 ) )
         {
             return dn;
         }
@@ -1374,7 +1370,7 @@
         {
             Rdn rdn = ( Rdn ) rdns.nextElement();
             String upName = rdn.getUpName();
-            rdnOidToName( rdn );
+            rdnOidToName( rdn, oidsMap );
             rdn.normalizeString();
             rdn.setUpName( upName );
         }
@@ -1402,9 +1398,9 @@
      * @throws InvalidNameException
      *             If the DN is invalid
      */
-    public void normalize() throws InvalidNameException, NamingException
+    public void normalize( Map oidsMap ) throws InvalidNameException, NamingException
     {
-        if ( ( OIDS_MAP == null ) || ( OIDS_MAP.size() == 0 ) )
+        if ( ( oidsMap == null ) || ( oidsMap.size() == 0 ) )
         {
             return;
         }
@@ -1416,21 +1412,11 @@
         {
             Rdn rdn = ( Rdn ) rdns.nextElement();
             String upName = rdn.getUpName();
-            rdnOidToName( rdn );
+            rdnOidToName( rdn, oidsMap );
             rdn.normalizeString();
             rdn.setUpName( upName );
         }
 
         normalizeInternal();
-    }
-    
-    /**
-     * Set the static OIDs map with the values.
-     * 
-     * @param oidsMap The HashMap which contains <oid, normalizer> pairs
-     */
-    public static synchronized void setOidsMap( Map oidsMap )
-    {
-        OIDS_MAP = oidsMap;
     }
 }

Modified: directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParser.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParser.java?rev=414765&r1=414764&r2=414765&view=diff
==============================================================================
--- directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParser.java
(original)
+++ directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParser.java
Fri Jun 16 00:31:51 2006
@@ -20,6 +20,7 @@
 
 import java.io.StringReader;
 import java.text.ParseException;
+import java.util.Map;
 
 import org.apache.directory.shared.ldap.schema.NormalizerMappingResolver;
 
@@ -51,13 +52,13 @@
     /**
      * Creates a subtree specification parser.
      */
-    public SubtreeSpecificationParser()
+    public SubtreeSpecificationParser( Map oidsMap )
     {
         StringReader in = new StringReader( "" ); // place holder for the
                                                     // first input
         this.lexer = new ReusableAntlrSubtreeSpecificationLexer( in );
         this.parser = new ReusableAntlrSubtreeSpecificationParser( lexer );
-        this.parser.init(); // this method MUST be called while we cannot do
+        this.parser.init( oidsMap ); // this method MUST be called while we cannot do
         // constructor overloading for antlr generated parser
         this.isNormalizing = false;
     }
@@ -66,14 +67,14 @@
     /**
      * Creates a normalizing subtree specification parser.
      */
-    public SubtreeSpecificationParser( NormalizerMappingResolver resolver )
+    public SubtreeSpecificationParser( NormalizerMappingResolver resolver, Map oidsMap  )
     {
         StringReader in = new StringReader( "" ); // place holder for the
                                                     // first input
         this.lexer = new ReusableAntlrSubtreeSpecificationLexer( in );
         this.parser = new ReusableAntlrSubtreeSpecificationParser( lexer );
         this.parser.setNormalizerMappingResolver( resolver );
-        this.parser.init(); // this method MUST be called while we cannot do
+        this.parser.init( oidsMap ); // this method MUST be called while we cannot do
         // constructor overloading for antlr generated parser
         this.isNormalizing = true;
     }

Modified: directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java?rev=414765&r1=414764&r2=414765&view=diff
==============================================================================
--- directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
(original)
+++ directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
Fri Jun 16 00:31:51 2006
@@ -47,7 +47,7 @@
     public ACIItemParserTest()
     {
         super();
-        parser = new ACIItemParser();
+        parser = new ACIItemParser( null );
     }
 
 
@@ -57,7 +57,7 @@
     public ACIItemParserTest(String s)
     {
         super( s );
-        parser = new ACIItemParser();
+        parser = new ACIItemParser( null );
     }
 
 

Modified: directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=414765&r1=414764&r2=414765&view=diff
==============================================================================
--- directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
(original)
+++ directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Fri Jun 16 00:31:51 2006
@@ -2093,8 +2093,7 @@
         oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer()
) );
         oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() )
);
 
-        LdapDN.setOidsMap( oids );
-        Name result = LdapDN.normalize( name );
+        Name result = LdapDN.normalize( name, oids );
 
         assertTrue( result.toString().equals( "ou=some people,dc=example,dc=com" ) );
         assertTrue( ( ( LdapDN ) result ).toUpName().equals( "ou= Some   People   ,dc = eXample,dc=
cOm" ) );
@@ -2117,8 +2116,7 @@
         oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer()
) );
         oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() )
);
 
-        LdapDN.setOidsMap( oids );
-        Name result = LdapDN.normalize( name );
+        Name result = LdapDN.normalize( name, oids );
         assertTrue( result.toString().equals( "" ) );
     }
 
@@ -2140,8 +2138,7 @@
         oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer()
) );
         oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() )
);
 
-        LdapDN.setOidsMap( oids );
-        Name result = LdapDN.normalize( name );
+        Name result = LdapDN.normalize( name, oids );
 
         assertTrue( result.toString().equals( "dc=and some animals+ou=some people,dc=example,dc=com"
) );
         assertTrue( ( ( LdapDN ) result )
@@ -2168,8 +2165,7 @@
         oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer()
) );
         oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() )
);
 
-        LdapDN.setOidsMap( oids );
-        LdapDN result = LdapDN.normalize( name );
+        LdapDN result = LdapDN.normalize( name, oids );
 
         assertTrue( result.toString().equals( "dc=and some animals+ou=some people,dc=example,dc=com"
) );
         assertTrue( ( ( LdapDN ) result )

Modified: directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java?rev=414765&r1=414764&r2=414765&view=diff
==============================================================================
--- directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
(original)
+++ directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
Fri Jun 16 00:31:51 2006
@@ -100,7 +100,7 @@
     public SubtreeSpecificationParserTest()
     {
         super();
-        parser = new SubtreeSpecificationParser();
+        parser = new SubtreeSpecificationParser( null );
     }
 
 
@@ -110,7 +110,7 @@
     public SubtreeSpecificationParserTest(String s)
     {
         super( s );
-        parser = new SubtreeSpecificationParser();
+        parser = new SubtreeSpecificationParser( null );
     }
 
 



Mime
View raw message