directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r493295 - in /directory/trunks/apacheds: core-unit/src/test/java/org/apache/directory/server/core/schema/ core/src/main/java/org/apache/directory/server/core/schema/ schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstra...
Date Sat, 06 Jan 2007 04:06:46 GMT
Author: akarasulu
Date: Fri Jan  5 20:06:45 2007
New Revision: 493295

URL: http://svn.apache.org/viewvc?view=rev&rev=493295
Log:
fixing various bugs to make the integration tests for syntax update handling work

Modified:
    directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerITest.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
    directory/trunks/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/NameOrNumericIdNormalizer.java
    directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultOidRegistry.java
    directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxRegistry.java

Modified: directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerITest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerITest.java?view=diff&rev=493295&r1=493294&r2=493295
==============================================================================
--- directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerITest.java
(original)
+++ directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerITest.java
Fri Jan  5 20:06:45 2007
@@ -58,7 +58,7 @@
      */
     private final LdapDN getSyntaxContainer( String schemaName ) throws NamingException
     {
-        return new LdapDN( "ou=normalizers,cn=" + schemaName );
+        return new LdapDN( "ou=syntaxes,cn=" + schemaName );
     }
     
     

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java?view=diff&rev=493295&r1=493294&r2=493295
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
Fri Jan  5 20:06:45 2007
@@ -81,6 +81,7 @@
     private final String CN_OID;
     private final String M_OID_OID;
     private final String OBJECTCLASS_OID;
+    private final String META_SYNTAX_OID;
     
     private final AttributeType disabledAttributeType;
     
@@ -104,6 +105,7 @@
         this.disabledAttributeType = attrRegistry.lookup( MetaSchemaConstants.M_DISABLED_AT
);
         this.M_OID_OID = oidRegistry.getOid( MetaSchemaConstants.M_OID_AT );
         this.OBJECTCLASS_OID = oidRegistry.getOid( SystemSchemaConstants.OBJECT_CLASS_AT
);
+        this.META_SYNTAX_OID = oidRegistry.getOid( MetaSchemaConstants.M_SYNTAX_AT );
     }
     
     
@@ -289,7 +291,10 @@
         }
         finally
         {
-            ne.close();
+            if ( ne != null )
+            {
+                ne.close();
+            }
         }
     }
 
@@ -336,13 +341,13 @@
         
         // subfilter for (| (objectClass=metaMatchingRule) (objectClass=metaAttributeType))
 
         BranchNode or = new BranchNode( AssertionEnum.OR );
-        or.addNode( new SimpleNode( SystemSchemaConstants.OBJECT_CLASS_AT, 
-            MetaSchemaConstants.META_MATCHING_RULE_OC, AssertionEnum.EQUALITY ) );
-        or.addNode( new SimpleNode( SystemSchemaConstants.OBJECT_CLASS_AT, 
-            MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC, AssertionEnum.EQUALITY ) );
+        or.addNode( new SimpleNode( OBJECTCLASS_OID, 
+            MetaSchemaConstants.META_MATCHING_RULE_OC.toLowerCase(), AssertionEnum.EQUALITY
) );
+        or.addNode( new SimpleNode( OBJECTCLASS_OID, 
+            MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC.toLowerCase(), AssertionEnum.EQUALITY
) );
         
         filter.addNode( or );
-        filter.addNode( new SimpleNode( MetaSchemaConstants.M_SYNTAX_AT, 
+        filter.addNode( new SimpleNode( META_SYNTAX_OID, 
             numericOid.toLowerCase(), AssertionEnum.EQUALITY ) );
 
         SearchControls searchControls = new SearchControls();
@@ -359,7 +364,10 @@
         }
         finally
         {
-            ne.close();
+            if ( ne != null )
+            {
+                ne.close();
+            }
         }
         
         return set;

Modified: directory/trunks/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/NameOrNumericIdNormalizer.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/NameOrNumericIdNormalizer.java?view=diff&rev=493295&r1=493294&r2=493295
==============================================================================
--- directory/trunks/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/NameOrNumericIdNormalizer.java
(original)
+++ directory/trunks/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/NameOrNumericIdNormalizer.java
Fri Jan  5 20:06:45 2007
@@ -27,6 +27,8 @@
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.syntax.NumericOidSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntax.OidSyntaxChecker;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 
@@ -42,7 +44,7 @@
 public class NameOrNumericIdNormalizer implements Normalizer
 {
     private static final long serialVersionUID = 1L;
-
+    private NumericOidSyntaxChecker checker = new NumericOidSyntaxChecker();
     private transient OidRegistry registry;
     
     
@@ -87,12 +89,21 @@
             return "";
         }
         
+        // if value is a numeric id then return it as is
+        if ( checker.isValidSyntax( strValue ) )
+        {
+            return value;
+        }
+        
+        // if it is a name we need to do a lookup
         if ( registry.hasOid( strValue ) )
         {
             return registry.getOid( strValue );
         }
         
-        throw new LdapNamingException( ResultCodeEnum.OTHER );
+        // if all else fails
+        throw new LdapNamingException( "Encountered name based id of " + value 
+            + " which was not found in the OID registry" , ResultCodeEnum.OTHER );
     }
     
     

Modified: directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultOidRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultOidRegistry.java?view=diff&rev=493295&r1=493294&r2=493295
==============================================================================
--- directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultOidRegistry.java
(original)
+++ directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultOidRegistry.java
Fri Jan  5 20:06:45 2007
@@ -303,13 +303,19 @@
     {
         byOid.remove( numericOid );
         Iterator<String> names = byName.keySet().iterator();
+        List<String> namesToRemove = new ArrayList<String>(); 
         while ( names.hasNext() )
         {
             String name = names.next();
             if ( numericOid.equals( byName.get( name ) ) )
             {
-                byName.remove( name );
+                namesToRemove.add( name );
             }
+        }
+        
+        for ( String name : namesToRemove )
+        {
+            byName.remove( name );
         }
     }
 }

Modified: directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxRegistry.java?view=diff&rev=493295&r1=493294&r2=493295
==============================================================================
--- directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxRegistry.java
(original)
+++ directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxRegistry.java
Fri Jan  5 20:06:45 2007
@@ -102,6 +102,10 @@
         {
             oidRegistry.register( syntax.getName(), syntax.getOid() );
         }
+        else
+        {
+            oidRegistry.register( syntax.getOid(), syntax.getOid() );
+        }
 
         byOid.put( syntax.getOid(), syntax );
         oidToSchema.put( syntax.getOid(), schema );



Mime
View raw message