directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r411456 - in /directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema: AttributeTypeRegistry.java GlobalAttributeTypeRegistry.java bootstrap/BootstrapAttributeTypeRegistry.java
Date Sat, 03 Jun 2006 19:09:48 GMT
Author: akarasulu
Date: Sat Jun  3 12:09:48 2006
New Revision: 411456

URL: http://svn.apache.org/viewvc?rev=411456&view=rev
Log:
adding new method to access a map of attributeType equality normalizers: this is used for
normalization of distinguished names

Modified:
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/GlobalAttributeTypeRegistry.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java?rev=411456&r1=411455&r2=411456&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java
Sat Jun  3 12:09:48 2006
@@ -18,6 +18,7 @@
 
 
 import java.util.Iterator;
+import java.util.Map;
 
 import javax.naming.NamingException;
 
@@ -80,4 +81,11 @@
      * @return an iterator over all AttributeTypes in registry
      */
     Iterator list();
+    
+    
+    /**
+     * Gets an oid/name to normalizer mapping used to normalize distinguished 
+     * names.
+     */
+    Map getNormalizerMapping() throws NamingException; 
 }

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/GlobalAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/GlobalAttributeTypeRegistry.java?rev=411456&r1=411455&r2=411456&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/GlobalAttributeTypeRegistry.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/GlobalAttributeTypeRegistry.java
Sat Jun  3 12:09:48 2006
@@ -17,6 +17,7 @@
 package org.apache.directory.server.core.schema;
 
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -25,6 +26,7 @@
 
 import org.apache.directory.server.core.schema.bootstrap.BootstrapAttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.util.JoinIterator;
 
 
@@ -46,6 +48,8 @@
     private AttributeTypeRegistryMonitor monitor;
     /** the underlying bootstrap registry to delegate on misses to */
     private BootstrapAttributeTypeRegistry bootstrap;
+    /** cached normalizer mapping */
+    private transient Map mapping;
 
 
     // ------------------------------------------------------------------------
@@ -113,6 +117,11 @@
         oidToSchema.put( attributeType.getOid(), schema );
         byOid.put( attributeType.getOid(), attributeType );
         monitor.registered( attributeType );
+        
+        // update the cached normalizer mapping
+        Normalizer normalizer = attributeType.getEquality().getNormalizer();
+        mapping.put( attributeType.getOid(), normalizer );
+        mapping.put( attributeType.getName(), normalizer );
     }
 
 
@@ -179,5 +188,24 @@
     {
         return new JoinIterator( new Iterator[]
             { byOid.values().iterator(), bootstrap.list() } );
+    }
+    
+    
+    public Map getNormalizerMapping() throws NamingException
+    {
+        if ( mapping == null )
+        {
+            Map bootstrapMapping = bootstrap.getNormalizerMapping();
+            Map mapping = new HashMap( ( byOid.size() << 1 ) + bootstrapMapping.size()
);
+            mapping.putAll( bootstrapMapping );
+            for ( Iterator ii = byOid.values().iterator(); ii.hasNext(); /**/ )
+            {
+                AttributeType type = ( AttributeType ) ii.next();
+                Normalizer normalizer = type.getEquality().getNormalizer();
+                mapping.put( type.getOid(), normalizer );
+                mapping.put( type.getName(), normalizer );
+            }
+        }
+        return Collections.unmodifiableMap( mapping );
     }
 }

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java?rev=411456&r1=411455&r2=411456&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java
Sat Jun  3 12:09:48 2006
@@ -17,6 +17,7 @@
 package org.apache.directory.server.core.schema.bootstrap;
 
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -28,6 +29,7 @@
 import org.apache.directory.server.core.schema.AttributeTypeRegistryMonitorAdapter;
 import org.apache.directory.server.core.schema.OidRegistry;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.Normalizer;
 
 
 /**
@@ -46,7 +48,9 @@
     private final OidRegistry oidRegistry;
     /** monitor notified via callback events */
     private AttributeTypeRegistryMonitor monitor;
-
+    /** cached normalizer mapping */
+    private transient Map mapping;
+    
 
     // ------------------------------------------------------------------------
     // C O N S T R U C T O R S
@@ -98,6 +102,11 @@
         oidToSchema.put( attributeType.getOid(), schema );
         byOid.put( attributeType.getOid(), attributeType );
         monitor.registered( attributeType );
+
+        // update the cached normalizer mapping
+        Normalizer normalizer = attributeType.getEquality().getNormalizer();
+        mapping.put( attributeType.getOid(), normalizer );
+        mapping.put( attributeType.getName(), normalizer );
     }
 
 
@@ -151,5 +160,23 @@
     public Iterator list()
     {
         return byOid.values().iterator();
+    }
+    
+    
+    public Map getNormalizerMapping() throws NamingException
+    {
+        if ( mapping == null )
+        {
+            mapping = new HashMap( byOid.size() << 1 );
+            for ( Iterator ii = byOid.values().iterator(); ii.hasNext(); /**/ )
+            {
+                AttributeType type = ( AttributeType ) ii.next();
+                Normalizer normalizer = type.getEquality().getNormalizer();
+                mapping.put( type.getOid(), normalizer );
+                mapping.put( type.getName(), normalizer );
+            }
+        }
+        
+        return Collections.unmodifiableMap( mapping );
     }
 }



Mime
View raw message