directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r810134 - in /directory: apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/apacheds-schema/core-entry/src/test/resources/ apacheds/branches/apacheds-schema/core/src/test/jav...
Date Tue, 01 Sep 2009 17:24:41 GMT
Author: elecharny
Date: Tue Sep  1 17:24:41 2009
New Revision: 810134

URL: http://svn.apache.org/viewvc?rev=810134&view=rev
Log:
o Fixed a bug in StringTools.toLowerCase() method 
o Trimming and lowercase data injected into the SchemaObjectRegistries
o Throwing a NoSuchAttributeException for AttributeTypeRegistry operation
o other minor fixes

Modified:
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/resources/log4j.properties
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
    directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
    directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java?rev=810134&r1=810133&r2=810134&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
Tue Sep  1 17:24:41 2009
@@ -1180,7 +1180,7 @@
     {
         try
         {
-            return get( atRegistry.lookup( alias ) );
+            return get( atRegistry.lookup( StringTools.trim( StringTools.toLowerCase( alias
) ) ) );
         }
         catch ( NamingException ne )
         {

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/resources/log4j.properties?rev=810134&r1=810133&r2=810134&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/resources/log4j.properties
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/resources/log4j.properties
Tue Sep  1 17:24:41 2009
@@ -16,6 +16,14 @@
 #############################################################################
 log4j.rootCategory=DEBUG, stdout
 
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout=org.apache.log4j.RollingFileAppender
+log4j.appender.stdout.File=apacheds-rolling.log
+
+log4j.appender.stdout.MaxFileSize=1024KB
+# Keep some backup files
+log4j.appender.stdout.MaxBackupIndex=5
+
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+
+log4j.logger.org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor=ERROR
\ No newline at end of file

Modified: directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java?rev=810134&r1=810133&r2=810134&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
Tue Sep  1 17:24:41 2009
@@ -105,7 +105,7 @@
     }
 
 
-    public Map<String,OidNormalizer> getNormalizerMapping() throws NamingException
+    public Map<String,OidNormalizer> getNormalizerMapping()
     {
         return null;
     }

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java?rev=810134&r1=810133&r2=810134&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
Tue Sep  1 17:24:41 2009
@@ -36,6 +36,7 @@
 import org.apache.directory.shared.ldap.schema.registries.AbstractSchemaLoader;
 import org.apache.directory.shared.ldap.schema.registries.Schema;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.AcceptAllSyntaxChecker;
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.Entry;
@@ -58,6 +59,8 @@
 import java.util.Map;
 import java.util.Stack;
 
+import javax.naming.NamingException;
+
 
 /**
  * Loads schema data from an LDIF files containing entries representing schema
@@ -430,6 +433,7 @@
         }
         
         File[] syntaxCheckerFiles = syntaxCheckersDirectory.listFiles( ldifFilter );
+        
         for ( File ldifFile : syntaxCheckerFiles )
         {
             LdifReader reader = new LdifReader( ldifFile );
@@ -468,6 +472,7 @@
         }
         
         File[] normalizerFiles = normalizersDirectory.listFiles( ldifFilter );
+        
         for ( File ldifFile : normalizerFiles )
         {
             LdifReader reader = new LdifReader( ldifFile );
@@ -499,6 +504,7 @@
         }
         
         File[] matchingRuleFiles = matchingRulesDirectory.listFiles( ldifFilter );
+        
         for ( File ldifFile : matchingRuleFiles )
         {
             LdifReader reader = new LdifReader( ldifFile );
@@ -530,6 +536,7 @@
         }
         
         File[] syntaxFiles = syntaxesDirectory.listFiles( ldifFilter );
+        
         for ( File ldifFile : syntaxFiles )
         {
             LdifReader reader = new LdifReader( ldifFile );
@@ -537,6 +544,20 @@
             LdapSyntax syntax = factory.getSyntax( 
                 entry.getEntry(), registries, schema.getSchemaName() );
             registries.getLdapSyntaxRegistry().register( syntax );
+
+            /*
+            // Update the SyntaxChecker link
+            try
+            {
+                SyntaxChecker syntaxChecker = registries.getSyntaxCheckerRegistry().lookup(
syntax.getOid() );
+                
+                syntax.setSyntaxChecker( syntaxChecker );
+            }
+            catch ( NamingException ne )
+            {
+                syntax.setSyntaxChecker( new  AcceptAllSyntaxChecker( syntax.getOid() ) );
+            }
+            */
         }
     }
 
@@ -575,6 +596,7 @@
 
     	// check that the attributeTypes directory exists for the schema
         File attributeTypesDirectory = new File ( getSchemaDirectory( schema ), ATTRIBUTE_TYPES_DIRNAME
);
+        
         if ( ! attributeTypesDirectory.exists() )
         {
             return;
@@ -582,6 +604,7 @@
         
         // get list of attributeType LDIF schema files in attributeTypes
         File[] attributeTypeFiles = attributeTypesDirectory.listFiles( ldifFilter );
+        
         for ( File ldifFile : attributeTypeFiles )
         {
             LdifReader reader = new LdifReader( ldifFile );
@@ -632,6 +655,7 @@
     {
         // get superior name and if exists check if loaded, defer if not
         EntryAttribute superior = entry.getEntry().get( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT
);
+        
         if ( superior != null )
         {
         	String superiorName = superior.getString().toLowerCase();
@@ -639,6 +663,7 @@
         	if ( ! registries.getAttributeTypeRegistry().containsName( superiorName ) )
         	{
         		List<LdifEntry> dependents = deferredEntries.get( superiorName );
+        		
         		if ( dependents == null )
         		{
         			dependents = new ArrayList<LdifEntry>();
@@ -662,6 +687,7 @@
         		{
         			List<LdifEntry> deferredList = deferredEntries.get( name.toLowerCase() );
         			List<LdifEntry> copiedList = new ArrayList<LdifEntry>( deferredList
);
+        			
         			for ( LdifEntry deferred : copiedList )
         			{
         				if ( loadAttributeType( schema, deferredEntries, deferred, registries ) )
@@ -702,6 +728,7 @@
         }
         
         File[] matchingRuleUseFiles = matchingRuleUsesDirectory.listFiles( ldifFilter );
+        
         for ( File ldifFile : matchingRuleUseFiles )
         {
             LdifReader reader = new LdifReader( ldifFile );
@@ -740,6 +767,7 @@
         }
         
         File[] nameFormFiles = nameFormsDirectory.listFiles( ldifFilter );
+        
         for ( File ldifFile : nameFormFiles )
         {
             LdifReader reader = new LdifReader( ldifFile );
@@ -778,6 +806,7 @@
         }
         
         File[] ditContentRuleFiles = ditContentRulesDirectory.listFiles( ldifFilter );
+        
         for ( File ldifFile : ditContentRuleFiles )
         {
             LdifReader reader = new LdifReader( ldifFile );
@@ -816,6 +845,7 @@
         }
         
         File[] ditStructureRuleFiles = ditStructureRulesDirectory.listFiles( ldifFilter );
+        
         for ( File ldifFile : ditStructureRuleFiles )
         {
             LdifReader reader = new LdifReader( ldifFile );
@@ -868,13 +898,15 @@
 
     	// get objectClasses directory, check if exists, return if not
     	File objectClassesDirectory = new File( getSchemaDirectory( schema ), OBJECT_CLASSES_DIRNAME
);
-        if ( ! objectClassesDirectory.exists() )
+        
+    	if ( ! objectClassesDirectory.exists() )
         {
             return;
         }
         
         // get list of objectClass LDIF files from directory and load
         File[] objectClassFiles = objectClassesDirectory.listFiles( ldifFilter );
+       
         for ( File ldifFile : objectClassFiles )
         {
             LdifReader reader = new LdifReader( ldifFile );
@@ -924,14 +956,17 @@
 	{
         // get superior name and if exists check if loaded, defer if not
         EntryAttribute superiors = entry.getEntry().get( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT
);
+        
         if ( superiors != null )
         {
         	for ( Value<?> value : superiors )
         	{
         		String superiorName = value.getString().toLowerCase();
-            	if ( ! registries.getObjectClassRegistry().containsName( superiorName ) )
+            	
+        		if ( ! registries.getObjectClassRegistry().containsName( superiorName ) )
             	{
             		List<LdifEntry> dependents = deferredEntries.get( superiorName );
+            		
             		if ( dependents == null )
             		{
             			dependents = new ArrayList<LdifEntry>();
@@ -956,6 +991,7 @@
         		{
         			List<LdifEntry> deferredList = deferredEntries.get( name.toLowerCase() );
         			List<LdifEntry> copiedList = new ArrayList<LdifEntry>( deferredList
);
+        			
         			for ( LdifEntry deferred : copiedList )
         			{
         				if ( loadObjectClass( schema, deferredEntries, deferred, registries ) )

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java?rev=810134&r1=810133&r2=810134&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
Tue Sep  1 17:24:41 2009
@@ -386,6 +386,7 @@
         String oid = entry.get( MetaSchemaConstants.M_OID_AT ).getString();
         LdapSyntax syntax = new LdapSyntax( oid );
         syntax.setSchemaName( schema );
+        syntax.applyRegistries( targetRegistries );
         
         if ( entry.get( MetaSchemaConstants.X_HUMAN_READABLE_AT ) != null )
         {

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java?rev=810134&r1=810133&r2=810134&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
Tue Sep  1 17:24:41 2009
@@ -22,6 +22,9 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.AcceptAllSyntaxChecker;
+
 
 /**
  * A syntax definition. Each attribute stored in a directory has a defined
@@ -171,4 +174,27 @@
     {
         return DescriptionUtils.getDescription( this );
     }
+
+
+    /**
+     * Inject the registries into this Object, updating the references to
+     * other SchemaObject
+     *
+     * @param registries The Registries
+     */
+    public void applyRegistries( Registries registries ) throws NamingException
+    {
+        if ( registries != null )
+        {
+            try
+            {
+                // Gets the associated C 
+                syntaxChecker = registries.getSyntaxCheckerRegistry().lookup( oid );
+            }
+            catch ( NamingException ne )
+            {
+                syntaxChecker = new  AcceptAllSyntaxChecker( oid );
+            }
+        }
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java?rev=810134&r1=810133&r2=810134&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
Tue Sep  1 17:24:41 2009
@@ -22,6 +22,8 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.schema.comparators.ComparableComparator;
+import org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 
 
@@ -115,14 +117,25 @@
     {
         if ( registries != null )
         {
-            // Gets the associated C 
-            ldapComparator = (LdapComparator<? super Object>)registries.getComparatorRegistry().lookup(
oid );
-
-            // Gets the associated N 
-            normalizer = registries.getNormalizerRegistry().lookup( oid );
-
-            // Gets the associated SC 
-            ldapSyntax = registries.getLdapSyntaxRegistry().lookup( ldapSyntaxOid );
+            try
+            {
+                // Gets the associated C 
+                ldapComparator = (LdapComparator<? super Object>)registries.getComparatorRegistry().lookup(
oid );
+            }
+            catch ( NamingException ne )
+            {
+                ldapComparator = new ComparableComparator( oid );
+            }
+    
+            try
+            {
+                // Gets the associated N 
+                normalizer = registries.getNormalizerRegistry().lookup( oid );
+            }
+            catch ( NamingException ne )
+            {
+                normalizer = new NoOpNormalizer( oid );
+            }
         }
     }
     

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java?rev=810134&r1=810133&r2=810134&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java
Tue Sep  1 17:24:41 2009
@@ -30,6 +30,7 @@
 import org.slf4j.LoggerFactory;
 
 import javax.naming.NamingException;
+import javax.naming.directory.NoSuchAttributeException;
 
 import java.util.Collections;
 import java.util.HashSet;
@@ -76,9 +77,8 @@
      * names.
      *
      * @return a map of OID Strings to OidNormalizer instances
-     * @throws NamingException if for some reason this information cannot be returned
      */
-    public Map<String, OidNormalizer> getNormalizerMapping() throws NamingException
+    public Map<String, OidNormalizer> getNormalizerMapping()
     {
         return Collections.unmodifiableMap( oidNormalizerMap );
     }
@@ -95,9 +95,16 @@
      */
     public boolean hasDescendants( String ancestorId ) throws NamingException
     {
-        String oid = getOidByName( ancestorId );
-        Set<AttributeType> descendants = oidToDescendantSet.get( oid );
-        return (descendants != null) && !descendants.isEmpty();
+        try
+        {
+            String oid = getOidByName( ancestorId );
+            Set<AttributeType> descendants = oidToDescendantSet.get( oid );
+            return (descendants != null) && !descendants.isEmpty();
+        }
+        catch ( NamingException ne )
+        {
+            throw new NoSuchAttributeException( ne.getMessage() );
+        }
     }
     
     
@@ -114,15 +121,22 @@
     @SuppressWarnings("unchecked")
     public Iterator<AttributeType> descendants( String ancestorId ) throws NamingException
     {
-        String oid = getOidByName( ancestorId );
-        Set<AttributeType> descendants = oidToDescendantSet.get( oid );
-        
-        if ( descendants == null )
+        try
         {
-            return Collections.EMPTY_SET.iterator();
+            String oid = getOidByName( ancestorId );
+            Set<AttributeType> descendants = oidToDescendantSet.get( oid );
+            
+            if ( descendants == null )
+            {
+                return Collections.EMPTY_SET.iterator();
+            }
+            
+            return descendants.iterator();
+        }
+        catch ( NamingException ne )
+        {
+            throw new NoSuchAttributeException( ne.getMessage() );
         }
-        
-        return descendants.iterator();
     }
     
     
@@ -135,18 +149,25 @@
      */
     public void register( AttributeType attributeType ) throws NamingException
     {
-        super.register( attributeType );
-        
-        // Inject the attributeType into the oid/normalizer map
-        addMappingFor( attributeType );
-
-        // Register this AttributeType into the Descendant map
-        registerDescendants( attributeType, attributeType.getSuperior() );
-        
-        // Internally associate the OID to the registered AttributeType
-        if ( IS_DEBUG )
+        try
+        {
+            super.register( attributeType );
+            
+            // Inject the attributeType into the oid/normalizer map
+            addMappingFor( attributeType );
+    
+            // Register this AttributeType into the Descendant map
+            registerDescendants( attributeType, attributeType.getSuperior() );
+            
+            // Internally associate the OID to the registered AttributeType
+            if ( IS_DEBUG )
+            {
+                LOG.debug( "registred attributeType: {}", attributeType );
+            }
+        }
+        catch ( NamingException ne )
         {
-            LOG.debug( "registred attributeType: {}", attributeType );
+            throw new NoSuchAttributeException( ne.getMessage() );
         }
     }
 
@@ -158,7 +179,8 @@
      * @param attributeType The attributeType to register
      * @throws NamingException If something went wrong
      */
-    public void registerDescendants( AttributeType attributeType, AttributeType ancestor
) throws NamingException
+    public void registerDescendants( AttributeType attributeType, AttributeType ancestor
) 
+        throws NamingException
     {
         // add this attribute to descendant list of other attributes in superior chain
         if ( ancestor == null )
@@ -179,8 +201,15 @@
         // Add the current type as a descendant
         descendants.add( attributeType );
         
-        // And recurse until we reach the top of the hierarchy
-        registerDescendants( attributeType, ancestor.getSuperior() );
+        try
+        {
+            // And recurse until we reach the top of the hierarchy
+            registerDescendants( attributeType, ancestor.getSuperior() );
+        }
+        catch ( NamingException ne )
+        {
+            throw new NoSuchAttributeException( ne.getMessage() );
+        }
     }
     
     
@@ -192,12 +221,19 @@
      */
     public AttributeType unregister( String numericOid ) throws NamingException
     {
-        AttributeType removed = super.unregister( numericOid );
-
-        removeMappingFor( removed );
-        oidToDescendantSet.remove( numericOid );
-        
-        return removed;
+        try
+        {
+            AttributeType removed = super.unregister( numericOid );
+    
+            removeMappingFor( removed );
+            oidToDescendantSet.remove( numericOid );
+            
+            return removed;
+        }
+        catch ( NamingException ne )
+        {
+            throw new NoSuchAttributeException( ne.getMessage() );
+        }
     }
 
     
@@ -206,26 +242,33 @@
      */
     private void addMappingFor( AttributeType attributeType ) throws NamingException
     {
-        MatchingRule matchingRule = attributeType.getEquality();
-        OidNormalizer oidNormalizer;
-        String oid = attributeType.getOid();
-
-        if ( matchingRule == null )
+        try
         {
-            LOG.debug( "Attribute {} does not have normalizer : using NoopNormalizer", attributeType.getName()
);
-            oidNormalizer = new OidNormalizer( oid, new NoOpNormalizer( attributeType.getOid()
) );
+            MatchingRule matchingRule = attributeType.getEquality();
+            OidNormalizer oidNormalizer;
+            String oid = attributeType.getOid();
+    
+            if ( matchingRule == null )
+            {
+                LOG.debug( "Attribute {} does not have normalizer : using NoopNormalizer",
attributeType.getName() );
+                oidNormalizer = new OidNormalizer( oid, new NoOpNormalizer( attributeType.getOid()
) );
+            }
+            else
+            {
+                oidNormalizer = new OidNormalizer( oid, matchingRule.getNormalizer() );
+            }
+    
+            oidNormalizerMap.put( oid, oidNormalizer );
+            
+            // Also inject the attributeType's short names in the map
+            for ( String name : attributeType.getNames() )
+            {
+                oidNormalizerMap.put( name.toLowerCase(), oidNormalizer );
+            }
         }
-        else
-        {
-            oidNormalizer = new OidNormalizer( oid, matchingRule.getNormalizer() );
-        }
-
-        oidNormalizerMap.put( oid, oidNormalizer );
-        
-        // Also inject the attributeType's short names in the map
-        for ( String name : attributeType.getNames() )
+        catch ( NamingException ne )
         {
-            oidNormalizerMap.put( name.toLowerCase(), oidNormalizer );
+            throw new NoSuchAttributeException( ne.getMessage() );
         }
     }
 
@@ -233,7 +276,7 @@
     /**
      * Remove the AttributeType normalizer from the OidNormalizer map 
      */
-    private void removeMappingFor( SchemaObject attributeType ) throws NamingException
+    private void removeMappingFor( SchemaObject attributeType )
     {
         if ( attributeType == null )
         {
@@ -248,4 +291,20 @@
             oidNormalizerMap.remove( name.toLowerCase() );
         }
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public AttributeType lookup( String oid ) throws NamingException
+    {
+        try
+        {
+           return  super.lookup( oid );
+        }
+        catch ( NamingException ne )
+        {
+            throw new NoSuchAttributeException( ne.getMessage() );
+        }
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java?rev=810134&r1=810133&r2=810134&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
Tue Sep  1 17:24:41 2009
@@ -25,6 +25,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.naming.NamingException;
+import javax.naming.directory.NoSuchAttributeException;
 
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
@@ -178,12 +179,13 @@
             return null;
         }
         
-        if ( ! OID.isOID( oid ) )
+        T schemaObject = byName.get( oid );
+        
+        if ( schemaObject == null )
         {
-        	oid = getOidByName( oid );
+            // let's try with trimming and lowercasing now
+            schemaObject = byName.get( StringTools.trim( StringTools.toLowerCase( oid ) )
);
         }
-        
-        T schemaObject = byName.get( oid );
 
         if ( schemaObject == null )
         {
@@ -227,7 +229,7 @@
          */
         for ( String name : schemaObject.getNames() )
         {
-        	byName.put( name.toLowerCase(), schemaObject );
+        	byName.put( StringTools.trim( StringTools.toLowerCase( name ) ), schemaObject );
         }
         
         if ( LOG.isDebugEnabled() )
@@ -350,9 +352,8 @@
      * @param name The name we are looking for
      * @return true if the name or it's cannonical form is mapped to a 
      * schemaObject in this registry, false otherwise.
-     * @throws NamingException If the OID can't be found
      */
-    public boolean containsName( String name ) throws NamingException
+    public boolean containsName( String name )
     {
     	if ( ! byName.containsKey( name ) )
     	{

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=810134&r1=810133&r2=810134&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Tue Sep  1 17:24:41 2009
@@ -642,7 +642,7 @@
         
         for ( int i = 0; i < chars.length; i++ )
         {
-            chars[i] = LOWER_CASE[ chars[i] ];
+            chars[i] = TO_LOWER_CASE[ chars[i] ];
         }
         
         return new String( chars );



Mime
View raw message