directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r504773 - in /directory/apacheds/trunk: 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/bootstrap...
Date Thu, 08 Feb 2007 03:01:52 GMT
Author: akarasulu
Date: Wed Feb  7 19:01:51 2007
New Revision: 504773

URL: http://svn.apache.org/viewvc?view=rev&rev=504773
Log:
changes for enabling comparators, normalizers, and syntaxCheckers in subschema:

 o added rendering capabilities for the subschemaSubentry which include
   normalizers, comparators, and syntaxCheckers now
 o changed the registries of these entities to store the descriptions of 
   these entities along with the entities to track information about them
 o fixed various classes to accomodate for registry changes 
 o corrected bug with OID used for the apacheSubschema objectClass


Modified:
    directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
    directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
    directory/apacheds/trunk/schema-bootstrap/src/main/schema/apache.schema
    directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/ComparatorRegistry.java
    directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultComparatorRegistry.java
    directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultNormalizerRegistry.java
    directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxCheckerRegistry.java
    directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/NormalizerRegistry.java
    directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SyntaxCheckerRegistry.java

Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java (original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java Wed Feb  7 19:01:51 2007
@@ -254,7 +254,10 @@
         // - nameForms
         // - objectClass
         // - objectClasses
-        assertEquals( 15, attrs.size() );
+        // - comparators
+        // - normalizers
+        // - syntaxCheckers
+        assertEquals( 18, attrs.size() );
         
         assertNotNull( attrs.get( "attributeTypes" ) );
         assertNotNull( attrs.get( "cn" ) );
@@ -358,9 +361,12 @@
         
         assertNotNull( attrs );
         
-        // We should have 14 attribute in the result :
+        // We should have 18 attribute in the result :
         // - nameForms
-        assertEquals( 15, attrs.size() );
+        // - comparators
+        // - normalizers
+        // - syntaxCheckers
+        assertEquals( 18, attrs.size() );
         
         assertNotNull( attrs.get( "attributeTypes" ) );
         assertNotNull( attrs.get( "cn" ) );
@@ -402,9 +408,12 @@
         
         assertNotNull( attrs );
         
-        // We should have 14 attribute in the result :
+        // We should have 18 attribute in the result :
         // - nameForms
-        assertEquals( 15, attrs.size() );
+        // - comparators
+        // - normalizers
+        // - syntaxCheckers
+        assertEquals( 18, attrs.size() );
         
         assertNotNull( attrs.get( "attributeTypes" ) );
         assertNotNull( attrs.get( "cn" ) );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java Wed Feb  7 19:01:51 2007
@@ -20,7 +20,9 @@
 package org.apache.directory.server.core.schema;
 
 
+import java.util.ArrayList;
 import java.util.Comparator;
+import java.util.List;
 
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -40,6 +42,7 @@
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.apache.directory.shared.ldap.util.Base64;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 
 
@@ -60,6 +63,9 @@
     private final ComparatorRegistry comparatorRegistry;
     private final MatchingRuleRegistry matchingRuleRegistry;
     private final AttributeType oidAT;
+    private final AttributeType byteCodeAT;
+    private final AttributeType descAT;
+    private final AttributeType fqcnAT;
 
     
 
@@ -71,6 +77,9 @@
         this.matchingRuleRegistry = targetRegistries.getMatchingRuleRegistry();
         this.factory = new SchemaEntityFactory( targetRegistries );
         this.oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
+        this.byteCodeAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_BYTECODE_AT );
+        this.descAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_DESCRIPTION_AT );
+        this.fqcnAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_FQCN_AT );
     }
 
 
@@ -100,10 +109,37 @@
         if ( ! schema.isDisabled() )
         {
             comparatorRegistry.unregister( oldOid );
-            comparatorRegistry.register( schema.getSchemaName(), getOid( targetEntry ), comparator );
+            ComparatorDescription description = getComparatorDescription( schema.getSchemaName(), targetEntry );
+            comparatorRegistry.register( description, comparator );
         }
     }
 
+    
+    private ComparatorDescription getComparatorDescription( String schemaName, Attributes entry ) throws NamingException
+    {
+        ComparatorDescription description = new ComparatorDescription();
+        description.setNumericOid( getOid( entry ) );
+        List<String> values = new ArrayList<String>();
+        values.add( schemaName );
+        description.addExtension( MetaSchemaConstants.X_SCHEMA, values );
+        description.setFqcn( ( String ) AttributeUtils.getAttribute( entry, fqcnAT ).get() );
+        
+        Attribute desc = AttributeUtils.getAttribute( entry, descAT );
+        if ( desc != null && desc.size() > 0 )
+        {
+            description.setDescription( ( String ) desc.get() );
+        }
+        
+        Attribute bytecode = AttributeUtils.getAttribute( entry, byteCodeAT );
+        if ( bytecode != null && bytecode.size() > 0 )
+        {
+            byte[] bytes = ( byte[] ) bytecode.get();
+            description.setBytecode( new String( Base64.encode( bytes ) ) );
+        }
+
+        return description;
+    }
+    
 
     public void modify( LdapDN name, int modOp, Attributes mods, Attributes entry, Attributes targetEntry )
         throws NamingException
@@ -126,12 +162,12 @@
         checkNewParent( parentDn );
         
         Comparator comparator = factory.getComparator( entry, targetRegistries );
-        String oid = getOid( entry );
         Schema schema = getSchema( name );
         
         if ( ! schema.isDisabled() )
         {
-            comparatorRegistry.register( schema.getSchemaName(), oid, comparator );
+            ComparatorDescription comparatorDescription = getComparatorDescription( schema.getSchemaName(), entry );
+            comparatorRegistry.register( comparatorDescription, comparator );
         }
     }
     
@@ -150,7 +186,7 @@
         
         if ( ! schema.isDisabled() )
         {
-            comparatorRegistry.register( schemaName, comparatorDescription.getNumericOid(), comparator );
+            comparatorRegistry.register( comparatorDescription, comparator );
         }
     }
 
@@ -198,7 +234,9 @@
         {
             Comparator comparator = factory.getComparator( entry, targetRegistries );
             comparatorRegistry.unregister( oldOid );
-            comparatorRegistry.register( schema.getSchemaName(), oid, comparator );
+            ComparatorDescription comparatorDescription = getComparatorDescription( schema.getSchemaName(), entry );
+            comparatorDescription.setNumericOid( oid );
+            comparatorRegistry.register( comparatorDescription, comparator );
         }
     }
 
@@ -231,7 +269,9 @@
 
         if ( ! newSchema.isDisabled() )
         {
-            comparatorRegistry.register( newSchema.getSchemaName(), oid, comparator );
+            ComparatorDescription comparatorDescription = getComparatorDescription( newSchema.getSchemaName(), entry );
+            comparatorDescription.setNumericOid( oid );
+            comparatorRegistry.register( comparatorDescription, comparator );
         }
     }
 
@@ -262,7 +302,8 @@
         
         if ( ! newSchema.isDisabled() )
         {
-            comparatorRegistry.register( newSchema.getSchemaName(), oid, comparator );
+            ComparatorDescription comparatorDescription = getComparatorDescription( newSchema.getSchemaName(), entry );
+            comparatorRegistry.register( comparatorDescription, comparator );
         }
     }
     

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java Wed Feb  7 19:01:51 2007
@@ -20,6 +20,9 @@
 package org.apache.directory.server.core.schema;
 
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -39,6 +42,7 @@
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.apache.directory.shared.ldap.util.Base64;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 
 
@@ -59,7 +63,9 @@
     private final NormalizerRegistry normalizerRegistry;
     private final MatchingRuleRegistry matchingRuleRegistry;
     private final AttributeType oidAT;
-
+    private final AttributeType byteCodeAT;
+    private final AttributeType descAT;
+    private final AttributeType fqcnAT;
     
 
     public MetaNormalizerHandler( Registries targetRegistries, PartitionSchemaLoader loader ) throws NamingException
@@ -70,9 +76,18 @@
         this.matchingRuleRegistry = targetRegistries.getMatchingRuleRegistry();
         this.factory = new SchemaEntityFactory( targetRegistries );
         this.oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
+        this.byteCodeAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_BYTECODE_AT );
+        this.descAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_DESCRIPTION_AT );
+        this.fqcnAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_FQCN_AT );
     }
 
 
+    private Schema getSchema( LdapDN name ) throws NamingException
+    {
+        return loader.getSchema( MetaSchemaUtils.getSchemaName( name ) );
+    }
+    
+    
     private String getOid( Attributes entry ) throws NamingException
     {
         Attribute oid = AttributeUtils.getAttribute( entry, oidAT );
@@ -84,9 +99,29 @@
     }
     
     
-    private Schema getSchema( LdapDN name ) throws NamingException
+    private NormalizerDescription getNormalizerDescription( String schemaName, Attributes entry ) throws NamingException
     {
-        return loader.getSchema( MetaSchemaUtils.getSchemaName( name ) );
+        NormalizerDescription description = new NormalizerDescription();
+        description.setNumericOid( getOid( entry ) );
+        List<String> values = new ArrayList<String>();
+        values.add( schemaName );
+        description.addExtension( MetaSchemaConstants.X_SCHEMA, values );
+        description.setFqcn( ( String ) AttributeUtils.getAttribute( entry, fqcnAT ).get() );
+        
+        Attribute desc = AttributeUtils.getAttribute( entry, descAT );
+        if ( desc != null && desc.size() > 0 )
+        {
+            description.setDescription( ( String ) desc.get() );
+        }
+        
+        Attribute bytecode = AttributeUtils.getAttribute( entry, byteCodeAT );
+        if ( bytecode != null && bytecode.size() > 0 )
+        {
+            byte[] bytes = ( byte[] ) bytecode.get();
+            description.setBytecode( new String( Base64.encode( bytes ) ) );
+        }
+
+        return description;
     }
     
     
@@ -99,7 +134,9 @@
         if ( ! schema.isDisabled() )
         {
             normalizerRegistry.unregister( oldOid );
-            normalizerRegistry.register( schema.getSchemaName(), getOid( targetEntry ), normalizer );
+            NormalizerDescription normalizerDescription = getNormalizerDescription( schema.getSchemaName(), 
+                targetEntry );
+            normalizerRegistry.register( normalizerDescription, normalizer );
         }
     }
 
@@ -125,12 +162,12 @@
         checkNewParent( parentDn );
         
         Normalizer normalizer = factory.getNormalizer( entry, targetRegistries );
-        String oid = getOid( entry );
         Schema schema = getSchema( name );
         
         if ( ! schema.isDisabled() )
         {
-            normalizerRegistry.register( schema.getSchemaName(), oid, normalizer );
+            NormalizerDescription normalizerDescription = getNormalizerDescription( schema.getSchemaName(), entry );
+            normalizerRegistry.register( normalizerDescription, normalizer );
         }
     }
 
@@ -149,7 +186,7 @@
         
         if ( ! schema.isDisabled() )
         {
-            normalizerRegistry.register( schemaName, normalizerDescription.getNumericOid(), normalizer );
+            normalizerRegistry.register( normalizerDescription, normalizer );
         }
     }
 
@@ -196,7 +233,10 @@
         {
             Normalizer normalizer = factory.getNormalizer( entry, targetRegistries );
             normalizerRegistry.unregister( oldOid );
-            normalizerRegistry.register( schema.getSchemaName(), oid, normalizer );
+            
+            NormalizerDescription normalizerDescription = getNormalizerDescription( schema.getSchemaName(), entry );
+            normalizerDescription.setNumericOid( oid );
+            normalizerRegistry.register( normalizerDescription, normalizer );
         }
     }
 
@@ -229,7 +269,9 @@
 
         if ( ! newSchema.isDisabled() )
         {
-            normalizerRegistry.register( newSchema.getSchemaName(), oid, normalizer );
+            NormalizerDescription normalizerDescription = getNormalizerDescription( newSchema.getSchemaName(), entry );
+            normalizerDescription.setNumericOid( oid );
+            normalizerRegistry.register( normalizerDescription, normalizer );
         }
     }
 
@@ -260,7 +302,8 @@
         
         if ( ! newSchema.isDisabled() )
         {
-            normalizerRegistry.register( newSchema.getSchemaName(), oid, normalizer );
+            NormalizerDescription normalizerDescription = getNormalizerDescription( newSchema.getSchemaName(), entry );
+            normalizerRegistry.register( normalizerDescription, normalizer );
         }
     }
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java Wed Feb  7 19:01:51 2007
@@ -20,6 +20,9 @@
 package org.apache.directory.server.core.schema;
 
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -40,6 +43,7 @@
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.apache.directory.shared.ldap.util.Base64;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 
 
@@ -60,7 +64,9 @@
     private final SyntaxCheckerRegistry syntaxCheckerRegistry;
     private final SyntaxRegistry syntaxRegistry;
     private final AttributeType oidAT;
-
+    private final AttributeType byteCodeAT;
+    private final AttributeType descAT;
+    private final AttributeType fqcnAT;
     
 
     public MetaSyntaxCheckerHandler( Registries targetRegistries, PartitionSchemaLoader loader ) throws NamingException
@@ -71,6 +77,9 @@
         this.syntaxRegistry = targetRegistries.getSyntaxRegistry();
         this.factory = new SchemaEntityFactory( targetRegistries );
         this.oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
+        this.byteCodeAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_BYTECODE_AT );
+        this.descAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_DESCRIPTION_AT );
+        this.fqcnAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_FQCN_AT );
     }
 
 
@@ -85,6 +94,33 @@
     }
     
     
+    private SyntaxCheckerDescription getSyntaxCheckerDescription( String schemaName, Attributes entry ) 
+        throws NamingException
+    {
+        SyntaxCheckerDescription description = new SyntaxCheckerDescription();
+        description.setNumericOid( getOid( entry ) );
+        List<String> values = new ArrayList<String>();
+        values.add( schemaName );
+        description.addExtension( MetaSchemaConstants.X_SCHEMA, values );
+        description.setFqcn( ( String ) AttributeUtils.getAttribute( entry, fqcnAT ).get() );
+        
+        Attribute desc = AttributeUtils.getAttribute( entry, descAT );
+        if ( desc != null && desc.size() > 0 )
+        {
+            description.setDescription( ( String ) desc.get() );
+        }
+        
+        Attribute bytecode = AttributeUtils.getAttribute( entry, byteCodeAT );
+        if ( bytecode != null && bytecode.size() > 0 )
+        {
+            byte[] bytes = ( byte[] ) bytecode.get();
+            description.setBytecode( new String( Base64.encode( bytes ) ) );
+        }
+
+        return description;
+    }
+
+    
     private Schema getSchema( LdapDN name ) throws NamingException
     {
         return loader.getSchema( MetaSchemaUtils.getSchemaName( name ) );
@@ -100,7 +136,9 @@
         if ( ! schema.isDisabled() )
         {
             syntaxCheckerRegistry.unregister( oldOid );
-            syntaxCheckerRegistry.register( schema.getSchemaName(), syntaxChecker );
+            SyntaxCheckerDescription syntaxCheckerDescription = 
+                getSyntaxCheckerDescription( schema.getSchemaName(), targetEntry );
+            syntaxCheckerRegistry.register( syntaxCheckerDescription, syntaxChecker );
         }
     }
 
@@ -130,7 +168,9 @@
         
         if ( ! schema.isDisabled() )
         {
-            syntaxCheckerRegistry.register( schema.getSchemaName(), syntaxChecker );
+            SyntaxCheckerDescription syntaxCheckerDescription = 
+                getSyntaxCheckerDescription( schema.getSchemaName(), entry );
+            syntaxCheckerRegistry.register( syntaxCheckerDescription, syntaxChecker );
         }
     }
 
@@ -150,7 +190,7 @@
         
         if ( ! schema.isDisabled() )
         {
-            syntaxCheckerRegistry.register( syntaxCheckerDescription.getNumericOid(), syntaxChecker );
+            syntaxCheckerRegistry.register( syntaxCheckerDescription, syntaxChecker );
         }
     }
 
@@ -198,7 +238,10 @@
         {
             SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, targetRegistries );
             syntaxCheckerRegistry.unregister( oldOid );
-            syntaxCheckerRegistry.register( schema.getSchemaName(), syntaxChecker );
+            SyntaxCheckerDescription syntaxCheckerDescription = 
+                getSyntaxCheckerDescription( schema.getSchemaName(), entry );
+            syntaxCheckerDescription.setNumericOid( newOid );
+            syntaxCheckerRegistry.register( syntaxCheckerDescription, syntaxChecker );
         }
     }
 
@@ -231,7 +274,10 @@
 
         if ( ! newSchema.isDisabled() )
         {
-            syntaxCheckerRegistry.register( newSchema.getSchemaName(), syntaxChecker );
+            SyntaxCheckerDescription syntaxCheckerDescription = 
+                getSyntaxCheckerDescription( newSchema.getSchemaName(), entry );
+            syntaxCheckerDescription.setNumericOid( newOid );
+            syntaxCheckerRegistry.register( syntaxCheckerDescription, syntaxChecker );
         }
     }
 
@@ -262,7 +308,9 @@
         
         if ( ! newSchema.isDisabled() )
         {
-            syntaxCheckerRegistry.register( newSchema.getSchemaName(), syntaxChecker );
+            SyntaxCheckerDescription syntaxCheckerDescription = 
+                getSyntaxCheckerDescription( newSchema.getSchemaName(), entry );
+            syntaxCheckerRegistry.register( syntaxCheckerDescription, syntaxChecker );
         }
     }
     

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java Wed Feb  7 19:01:51 2007
@@ -20,12 +20,14 @@
 package org.apache.directory.server.core.schema;
 
 
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
@@ -51,8 +53,12 @@
 import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
+import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.apache.directory.shared.ldap.util.Base64;
     
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -76,6 +82,9 @@
     private final AttributeType mOidAT;
     private final AttributeType mNameAT;
     private final AttributeType cnAT;
+    private final AttributeType byteCodeAT;
+    private final AttributeType descAT;
+    private final AttributeType fqcnAT;
 
     
     public PartitionSchemaLoader( Partition partition, Registries bootstrapRegistries ) throws NamingException
@@ -84,10 +93,13 @@
         this.partition = partition;
         this.attrRegistry = bootstrapRegistries.getAttributeTypeRegistry();
         
-        dao = new SchemaPartitionDao( this.partition, bootstrapRegistries );
-        mOidAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
-        mNameAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_NAME_AT );
-        cnAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( SystemSchemaConstants.CN_AT );
+        this.dao = new SchemaPartitionDao( this.partition, bootstrapRegistries );
+        this.mOidAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
+        this.mNameAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_NAME_AT );
+        this.cnAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( SystemSchemaConstants.CN_AT );
+        this.byteCodeAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_BYTECODE_AT );
+        this.descAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_DESCRIPTION_AT );
+        this.fqcnAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_FQCN_AT );
     }
     
     
@@ -582,7 +594,9 @@
             resultDN.normalize( attrRegistry.getNormalizerMapping() );
             Attributes attrs = partition.lookup( resultDN );
             SyntaxChecker sc = factory.getSyntaxChecker( attrs, targetRegistries );
-            targetRegistries.getSyntaxCheckerRegistry().register( schema.getSchemaName(), sc );
+            SyntaxCheckerDescription syntaxCheckerDescription = 
+                getSyntaxCheckerDescription( schema.getSchemaName(), attrs );
+            targetRegistries.getSyntaxCheckerRegistry().register( syntaxCheckerDescription, sc );
         }
     }
 
@@ -607,12 +621,49 @@
             resultDN.normalize( attrRegistry.getNormalizerMapping() );
             Attributes attrs = partition.lookup( resultDN );
             Normalizer normalizer = factory.getNormalizer( attrs, targetRegistries );
-            String oid = ( String ) attrs.get( "m-oid" ).get();
-            targetRegistries.getNormalizerRegistry().register( schema.getSchemaName(), oid, normalizer );
+            NormalizerDescription normalizerDescription = getNormalizerDescription( schema.getSchemaName(), attrs );
+            targetRegistries.getNormalizerRegistry().register( normalizerDescription, normalizer );
         }
     }
 
 
+    private String getOid( Attributes entry ) throws NamingException
+    {
+        Attribute oid = AttributeUtils.getAttribute( entry, mOidAT );
+        if ( oid == null )
+        {
+            return null;
+        }
+        return ( String ) oid.get();
+    }
+
+    
+    private NormalizerDescription getNormalizerDescription( String schemaName, Attributes entry ) throws NamingException
+    {
+        NormalizerDescription description = new NormalizerDescription();
+        description.setNumericOid( getOid( entry ) );
+        List<String> values = new ArrayList<String>();
+        values.add( schemaName );
+        description.addExtension( MetaSchemaConstants.X_SCHEMA, values );
+        description.setFqcn( ( String ) AttributeUtils.getAttribute( entry, fqcnAT ).get() );
+        
+        Attribute desc = AttributeUtils.getAttribute( entry, descAT );
+        if ( desc != null && desc.size() > 0 )
+        {
+            description.setDescription( ( String ) desc.get() );
+        }
+        
+        Attribute bytecode = AttributeUtils.getAttribute( entry, byteCodeAT );
+        if ( bytecode != null && bytecode.size() > 0 )
+        {
+            byte[] bytes = ( byte[] ) bytecode.get();
+            description.setBytecode( new String( Base64.encode( bytes ) ) );
+        }
+
+        return description;
+    }
+
+    
     private void loadComparators( Schema schema, Registries targetRegistries ) throws NamingException
     {
         LdapDN dn = new LdapDN( "ou=comparators,cn=" + schema.getSchemaName() + ",ou=schema" );
@@ -633,12 +684,65 @@
             resultDN.normalize( attrRegistry.getNormalizerMapping() );
             Attributes attrs = partition.lookup( resultDN );
             Comparator comparator = factory.getComparator( attrs, targetRegistries );
-            String oid = ( String ) attrs.get( "m-oid" ).get();
-            targetRegistries.getComparatorRegistry().register( schema.getSchemaName(), oid, comparator );
+            ComparatorDescription comparatorDescription = getComparatorDescription( schema.getSchemaName(), attrs );
+            targetRegistries.getComparatorRegistry().register( comparatorDescription, comparator );
         }
     }
 
 
+    private ComparatorDescription getComparatorDescription( String schemaName, Attributes entry ) throws NamingException
+    {
+        ComparatorDescription description = new ComparatorDescription();
+        description.setNumericOid( getOid( entry ) );
+        List<String> values = new ArrayList<String>();
+        values.add( schemaName );
+        description.addExtension( MetaSchemaConstants.X_SCHEMA, values );
+        description.setFqcn( ( String ) AttributeUtils.getAttribute( entry, fqcnAT ).get() );
+        
+        Attribute desc = AttributeUtils.getAttribute( entry, descAT );
+        if ( desc != null && desc.size() > 0 )
+        {
+            description.setDescription( ( String ) desc.get() );
+        }
+        
+        Attribute bytecode = AttributeUtils.getAttribute( entry, byteCodeAT );
+        if ( bytecode != null && bytecode.size() > 0 )
+        {
+            byte[] bytes = ( byte[] ) bytecode.get();
+            description.setBytecode( new String( Base64.encode( bytes ) ) );
+        }
+
+        return description;
+    }
+
+    
+    private SyntaxCheckerDescription getSyntaxCheckerDescription( String schemaName, Attributes entry ) 
+        throws NamingException
+    {
+        SyntaxCheckerDescription description = new SyntaxCheckerDescription();
+        description.setNumericOid( getOid( entry ) );
+        List<String> values = new ArrayList<String>();
+        values.add( schemaName );
+        description.addExtension( MetaSchemaConstants.X_SCHEMA, values );
+        description.setFqcn( ( String ) AttributeUtils.getAttribute( entry, fqcnAT ).get() );
+        
+        Attribute desc = AttributeUtils.getAttribute( entry, descAT );
+        if ( desc != null && desc.size() > 0 )
+        {
+            description.setDescription( ( String ) desc.get() );
+        }
+        
+        Attribute bytecode = AttributeUtils.getAttribute( entry, byteCodeAT );
+        if ( bytecode != null && bytecode.size() > 0 )
+        {
+            byte[] bytes = ( byte[] ) bytecode.get();
+            description.setBytecode( new String( Base64.encode( bytes ) ) );
+        }
+
+        return description;
+    }
+
+    
     public void loadWithDependencies( Schema schema, Registries registries ) throws NamingException
     {
         HashMap<String,Schema> notLoaded = new HashMap<String,Schema>();

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Wed Feb  7 19:01:51 2007
@@ -76,6 +76,9 @@
 import org.apache.directory.shared.ldap.schema.SchemaUtils;
 import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
+import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.apache.directory.shared.ldap.util.EmptyEnumeration;
@@ -540,6 +543,49 @@
         // operational attributes.  Due to RFC 3673, and issue DIREVE-228 in JIRA
         boolean returnAllOperationalAttributes = set.contains( "+" );
 
+        if ( returnAllOperationalAttributes || set.contains( "comparators" ) )
+        {
+            attr = new AttributeImpl( "comparators" );
+            Iterator<ComparatorDescription> list = registries.getComparatorRegistry().comparatorDescriptionIterator();
+            
+            while ( list.hasNext() )
+            {
+                ComparatorDescription description = list.next();
+                attr.add( SchemaUtils.render( description ).toString() );
+            }
+            
+            attrs.put( attr );
+        }
+        
+        if ( returnAllOperationalAttributes || set.contains( "normalizers" ) )
+        {
+            attr = new AttributeImpl( "normalizers" );
+            Iterator<NormalizerDescription> list = registries.getNormalizerRegistry().normalizerDescriptionIterator();
+            
+            while ( list.hasNext() )
+            {
+                NormalizerDescription normalizer = list.next();
+                attr.add( SchemaUtils.render( normalizer ).toString() );
+            }
+            
+            attrs.put( attr );
+        }
+
+        if ( returnAllOperationalAttributes || set.contains( "syntaxCheckers" ) )
+        {
+            attr = new AttributeImpl( "syntaxCheckers" );
+            Iterator<SyntaxCheckerDescription> list = 
+                registries.getSyntaxCheckerRegistry().syntaxCheckerDescriptionIterator();
+            
+            while ( list.hasNext() )
+            {
+                SyntaxCheckerDescription syntaxCheckerDescription = list.next();
+                attr.add( SchemaUtils.render( syntaxCheckerDescription ).toString() );
+            }
+            
+            attrs.put( attr );
+        }
+
         if ( returnAllOperationalAttributes || set.contains( "objectclasses" ) )
         {
             attr = new AttributeImpl( "objectClasses" );
@@ -713,6 +759,7 @@
             attr.add( "top" );
             attr.add( "subschema" );
             attr.add( "subentry" );
+            attr.add( "apacheSubschema" );
             attrs.put( attr );
         }
 

Modified: directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java (original)
+++ directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java Wed Feb  7 19:01:51 2007
@@ -20,16 +20,19 @@
 package org.apache.directory.server.schema.bootstrap;
 
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Stack;
 
 import javax.naming.NamingException;
 
+import org.apache.directory.server.constants.MetaSchemaConstants;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
 import org.apache.directory.server.schema.bootstrap.ProducerTypeEnum;
@@ -52,7 +55,10 @@
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.Syntax;
+import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
+import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -198,6 +204,8 @@
     {
         BootstrapSchema schema = ( BootstrapSchema ) this.schemas.get();
         DefaultRegistries registries = ( DefaultRegistries ) this.registries.get();
+        List<String> values = new ArrayList<String>(1);
+        values.add( schema.getSchemaName() );
 
         switch ( type )
         {
@@ -205,21 +213,39 @@
                 Normalizer normalizer = ( Normalizer ) schemaObject;
                 NormalizerRegistry normalizerRegistry;
                 normalizerRegistry = registries.getNormalizerRegistry();
-                normalizerRegistry.register( schema.getSchemaName(), id, normalizer );
+                
+                NormalizerDescription normalizerDescription = new NormalizerDescription();
+                normalizerDescription.setNumericOid( id );
+                normalizerDescription.setFqcn( normalizer.getClass().getName() );
+                normalizerDescription.addExtension( MetaSchemaConstants.X_SCHEMA, values );
+                
+                normalizerRegistry.register( normalizerDescription, normalizer );
                 break;
                 
             case COMPARATOR_PRODUCER :
                 Comparator comparator = ( Comparator ) schemaObject;
                 ComparatorRegistry comparatorRegistry;
                 comparatorRegistry = registries.getComparatorRegistry();
-                comparatorRegistry.register( schema.getSchemaName(), id, comparator );
+                
+                ComparatorDescription comparatorDescription = new ComparatorDescription();
+                comparatorDescription.addExtension( MetaSchemaConstants.X_SCHEMA, values );
+                comparatorDescription.setFqcn( comparator.getClass().getName() );
+                comparatorDescription.setNumericOid( id );
+                
+                comparatorRegistry.register( comparatorDescription, comparator );
                 break;
                 
             case SYNTAX_CHECKER_PRODUCER :
                 SyntaxChecker syntaxChecker = ( SyntaxChecker ) schemaObject;
                 SyntaxCheckerRegistry syntaxCheckerRegistry;
                 syntaxCheckerRegistry = registries.getSyntaxCheckerRegistry();
-                syntaxCheckerRegistry.register( schema.getSchemaName(), syntaxChecker );
+                
+                SyntaxCheckerDescription syntaxCheckerDescription = new SyntaxCheckerDescription();
+                syntaxCheckerDescription.addExtension( MetaSchemaConstants.X_SCHEMA, values );
+                syntaxCheckerDescription.setFqcn( syntaxChecker.getClass().getName() );
+                syntaxCheckerDescription.setNumericOid( id );
+                
+                syntaxCheckerRegistry.register( syntaxCheckerDescription, syntaxChecker );
                 break;
                 
             case SYNTAX_PRODUCER :

Modified: directory/apacheds/trunk/schema-bootstrap/src/main/schema/apache.schema
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-bootstrap/src/main/schema/apache.schema?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/schema-bootstrap/src/main/schema/apache.schema (original)
+++ directory/apacheds/trunk/schema-bootstrap/src/main/schema/apache.schema Wed Feb  7 19:01:51 2007
@@ -325,7 +325,7 @@
     USAGE directoryOperation
 )
 
-objectclass ( 2.5.20.1 NAME 'apacheSubschema'
+objectclass ( 1.3.6.1.4.1.18060.0.4.1.3.9 NAME 'apacheSubschema'
     DESC 'RFC2252 extension for controlling subschema (sub)entry in ApacheDS'
     SUP subschema
     AUXILIARY

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/ComparatorRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/ComparatorRegistry.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/ComparatorRegistry.java (original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/ComparatorRegistry.java Wed Feb  7 19:01:51 2007
@@ -25,6 +25,8 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
+
 
 /**
  * Comparator registry component's service interface.
@@ -47,13 +49,12 @@
     /**
      * Registers a Comparator with this registry.
      * 
-     * @param schema the name of the schema the comparator is associated with
-     * @param oid the object identifier
+     * @param description the comparatorDescription for the comparator to register
      * @param comparator the Comparator to register
      * @throws NamingException if the Comparator is already registered or the 
      *      registration operation is not supported
      */
-    void register( String schema, String oid, Comparator comparator ) throws NamingException;
+    void register( ComparatorDescription description, Comparator comparator ) throws NamingException;
 
 
     /**
@@ -84,6 +85,14 @@
      * @return Iterator of numeric OID strings 
      */
     Iterator<String> oidIterator();
+
+    
+    /**
+     * Iterates over the numeric OID strings of this registry.
+     * 
+     * @return Iterator of numeric OID strings 
+     */
+    Iterator<ComparatorDescription> comparatorDescriptionIterator();
 
     
     /**

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultComparatorRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultComparatorRegistry.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultComparatorRegistry.java (original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultComparatorRegistry.java Wed Feb  7 19:01:51 2007
@@ -29,6 +29,7 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,8 +46,8 @@
     private final static Logger log = LoggerFactory.getLogger( DefaultComparatorRegistry.class );
     /** the comparators in this registry */
     private final Map<String,Comparator> byOid;
-    /** maps an OID to a schema name*/
-    private final Map<String,String> oidToSchema;
+    /** maps oids to a comparator description */
+    private final Map<String,ComparatorDescription> oidToDescription;
 
 
     // ------------------------------------------------------------------------
@@ -59,8 +60,8 @@
      */
     public DefaultComparatorRegistry()
     {
-        this.oidToSchema = new HashMap<String,String>();
         this.byOid = new HashMap<String, Comparator>();
+        this.oidToDescription = new HashMap<String,ComparatorDescription>();
     }
 
 
@@ -69,22 +70,36 @@
     // ------------------------------------------------------------------------
 
     
-    public void register( String schema, String oid, Comparator comparator ) throws NamingException
+    public void register( ComparatorDescription description, Comparator comparator ) throws NamingException
     {
-        if ( byOid.containsKey( oid ) )
+        if ( byOid.containsKey( description.getNumericOid() ) )
         {
-            NamingException e = new NamingException( "Comparator with OID " + oid + " already registered!" );
+            NamingException e = new NamingException( "Comparator with OID " + description.getNumericOid() 
+                + " already registered!" );
             throw e;
         }
 
-        oidToSchema.put( oid, schema );
-        byOid.put( oid, comparator );
+        oidToDescription.put( description.getNumericOid(), description );
+        byOid.put( description.getNumericOid(), comparator );
         if ( log.isDebugEnabled() )
         {
-            log.debug( "registed comparator with OID: " + oid );
+            log.debug( "registed comparator with OID: " + description.getNumericOid() );
         }
     }
 
+    
+    private static String getSchema( ComparatorDescription desc )
+    {
+        List values = desc.getExtensions().get( "X-SCHEMA" );
+        
+        if ( values == null || values.size() == 0 )
+        {
+            return "other";
+        }
+        
+        return ( String ) desc.getExtensions().get( "X-SCHEMA" ).get( 0 );
+    }
+    
 
     public Comparator lookup( String oid ) throws NamingException
     {
@@ -116,12 +131,12 @@
             throw new NamingException( "OID " + oid + " is not a numeric OID" );
         }
 
-        if ( oidToSchema.containsKey( oid ) )
+        if ( oidToDescription.containsKey( oid ) )
         {
-            return ( String ) oidToSchema.get( oid );
+            return getSchema( oidToDescription.get( oid ) );
         }
 
-        throw new NamingException( "OID " + oid + " not found in oid to " + "schema name map!" );
+        throw new NamingException( "OID " + oid + " not found in oid to " + "description map!" );
     }
 
 
@@ -139,7 +154,7 @@
         }
 
         this.byOid.remove( oid );
-        this.oidToSchema.remove( oid );
+        this.oidToDescription.remove( oid );
     }
     
     
@@ -148,11 +163,12 @@
         List<String> oids = new ArrayList<String>( byOid.keySet() );
         for ( String oid : oids )
         {
-            String schemaNameForOid = oidToSchema.get( oid );
+            ComparatorDescription description = oidToDescription.get( oid );
+            String schemaNameForOid = getSchema( description );
             if ( schemaNameForOid.equalsIgnoreCase( schemaName ) )
             {
                 byOid.remove( oid );
-                oidToSchema.remove( oid );
+                oidToDescription.remove( oid );
             }
         }
     }
@@ -163,12 +179,20 @@
         List<String> oids = new ArrayList<String>( byOid.keySet() );
         for ( String oid : oids )
         {
-            String schemaNameForOid = oidToSchema.get( oid );
+            ComparatorDescription description = oidToDescription.get( oid );
+            String schemaNameForOid = getSchema( description );
             if ( schemaNameForOid.equalsIgnoreCase( originalSchemaName ) )
             {
-                oidToSchema.remove( oid );
-                oidToSchema.put( oid, newSchemaName );
+                List<String> schemaExt = description.getExtensions().get( "X-SCHEMA" );
+                schemaExt.clear();
+                schemaExt.add( newSchemaName );
             }
         }
+    }
+
+
+    public Iterator<ComparatorDescription> comparatorDescriptionIterator()
+    {
+        return oidToDescription.values().iterator();
     }
 }

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultNormalizerRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultNormalizerRegistry.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultNormalizerRegistry.java (original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultNormalizerRegistry.java Wed Feb  7 19:01:51 2007
@@ -29,6 +29,8 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,9 +46,9 @@
     /** static class logger */
     private final static Logger log = LoggerFactory.getLogger( DefaultNormalizerRegistry.class );
     /** a map of Normalizers looked up by OID */
-    private final Map<String, Normalizer> byOid;
-    /** maps an OID to a schema name*/
-    private final Map<String, String> oidToSchema;
+    private final Map<String,Normalizer> byOid;
+    /** maps an OID to a normalizerDescription */
+    private final Map<String,NormalizerDescription> oidToDescription;
 
 
     // ------------------------------------------------------------------------
@@ -59,7 +61,7 @@
     public DefaultNormalizerRegistry()
     {
         this.byOid = new HashMap<String, Normalizer>();
-        this.oidToSchema = new HashMap<String, String>();
+        this.oidToDescription = new HashMap<String, NormalizerDescription>();
     }
 
 
@@ -68,15 +70,16 @@
     // ------------------------------------------------------------------------
 
     
-    public void register( String schema, String oid, Normalizer normalizer ) throws NamingException
+    public void register( NormalizerDescription description, Normalizer normalizer ) throws NamingException
     {
+        String oid = description.getNumericOid();
         if ( byOid.containsKey( oid ) )
         {
             NamingException e = new NamingException( "Normalizer already " + "registered for OID " + oid );
             throw e;
         }
 
-        oidToSchema.put( oid, schema );
+        oidToDescription.put( oid, description );
         byOid.put( oid, normalizer );
         if ( log.isDebugEnabled() )
         {
@@ -115,15 +118,28 @@
             throw new NamingException( "Looks like the arg is not a numeric OID" );
         }
 
-        if ( oidToSchema.containsKey( oid ) )
+        if ( oidToDescription.containsKey( oid ) )
         {
-            return ( String ) oidToSchema.get( oid );
+            return getSchema( oidToDescription.get( oid ) );
         }
 
         throw new NamingException( "OID " + oid + " not found in oid to " + "schema name map!" );
     }
 
 
+    private static String getSchema( NormalizerDescription desc )
+    {
+        List values = desc.getExtensions().get( "X-SCHEMA" );
+        
+        if ( values == null || values.size() == 0 )
+        {
+            return "other";
+        }
+        
+        return ( String ) desc.getExtensions().get( "X-SCHEMA" ).get( 0 );
+    }
+    
+
     public Iterator<String> oidIterator()
     {
         return byOid.keySet().iterator();
@@ -138,7 +154,7 @@
         }
 
         this.byOid.remove( oid );
-        this.oidToSchema.remove( oid );
+        this.oidToDescription.remove( oid );
     }
     
     
@@ -147,11 +163,12 @@
         List<String> oids = new ArrayList<String>( byOid.keySet() );
         for ( String oid : oids )
         {
-            String schemaNameForOid = oidToSchema.get( oid );
+            NormalizerDescription description = oidToDescription.get( oid );
+            String schemaNameForOid = getSchema( description );
             if ( schemaNameForOid.equalsIgnoreCase( schemaName ) )
             {
                 byOid.remove( oid );
-                oidToSchema.remove( oid );
+                oidToDescription.remove( oid );
             }
         }
     }
@@ -162,12 +179,20 @@
         List<String> oids = new ArrayList<String>( byOid.keySet() );
         for ( String oid : oids )
         {
-            String schemaNameForOid = oidToSchema.get( oid );
+            NormalizerDescription description = oidToDescription.get( oid );
+            String schemaNameForOid = getSchema( description );
             if ( schemaNameForOid.equalsIgnoreCase( originalSchemaName ) )
             {
-                oidToSchema.remove( oid );
-                oidToSchema.put( oid, newSchemaName );
+                List<String> schemaExt = description.getExtensions().get( "X-SCHEMA" );
+                schemaExt.clear();
+                schemaExt.add( newSchemaName );
             }
         }
+    }
+
+
+    public Iterator<NormalizerDescription> normalizerDescriptionIterator()
+    {
+        return oidToDescription.values().iterator();
     }
 }

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxCheckerRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxCheckerRegistry.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxCheckerRegistry.java (original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxCheckerRegistry.java Wed Feb  7 19:01:51 2007
@@ -29,6 +29,7 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,8 +46,8 @@
     private final static Logger log = LoggerFactory.getLogger( DefaultSyntaxCheckerRegistry.class );
     /** a map by OID of SyntaxCheckers */
     private final Map<String, SyntaxChecker> byOid;
-    /** maps an OID to a schema name*/
-    private final Map<String, String> oidToSchema;
+    /** maps an OID to a syntaxCheckerDescription */
+    private final Map<String, SyntaxCheckerDescription> oidToDescription;
 
 
     // ------------------------------------------------------------------------
@@ -59,7 +60,7 @@
     public DefaultSyntaxCheckerRegistry()
     {
         this.byOid = new HashMap<String, SyntaxChecker>();
-        this.oidToSchema = new HashMap<String, String>();
+        this.oidToDescription = new HashMap<String, SyntaxCheckerDescription>();
     }
 
 
@@ -68,7 +69,7 @@
     // ------------------------------------------------------------------------
 
     
-    public void register( String schema, SyntaxChecker syntaxChecker ) throws NamingException
+    public void register( SyntaxCheckerDescription syntaxCheckerDescription, SyntaxChecker syntaxChecker ) throws NamingException
     {
         if ( byOid.containsKey( syntaxChecker.getSyntaxOid() ) )
         {
@@ -78,7 +79,7 @@
         }
 
         byOid.put( syntaxChecker.getSyntaxOid(), syntaxChecker );
-        oidToSchema.put( syntaxChecker.getSyntaxOid(), schema );
+        oidToDescription.put( syntaxChecker.getSyntaxOid(), syntaxCheckerDescription );
         if ( log.isDebugEnabled() )
         {
             log.debug( "registered syntaxChecher for OID " + syntaxChecker.getSyntaxOid() );
@@ -116,13 +117,26 @@
             throw new NamingException( "Looks like the arg is not a numeric OID" );
         }
 
-        if ( oidToSchema.containsKey( oid ) )
+        if ( oidToDescription.containsKey( oid ) )
         {
-            return ( String ) oidToSchema.get( oid );
+            return getSchema( oidToDescription.get( oid ) );
         }
 
         throw new NamingException( "OID " + oid + " not found in oid to " + "schema name map!" );
     }
+    
+    
+    private static String getSchema( SyntaxCheckerDescription desc ) 
+    {
+        List<String> ext = desc.getExtensions().get( "X-SCHEMA" );
+        
+        if ( ext == null || ext.size() == 0 )
+        {
+            return "other";
+        }
+        
+        return ext.get( 0 );
+    }
 
 
     public Iterator<SyntaxChecker> iterator()
@@ -139,7 +153,7 @@
         }
 
         byOid.remove( numericOid );
-        oidToSchema.remove( numericOid );
+        oidToDescription.remove( numericOid );
     }
     
     
@@ -148,11 +162,12 @@
         List<String> oids = new ArrayList<String>( byOid.keySet() );
         for ( String oid : oids )
         {
-            String schemaNameForOid = oidToSchema.get( oid );
+            SyntaxCheckerDescription description = oidToDescription.get( oid );
+            String schemaNameForOid = getSchema( description );
             if ( schemaNameForOid.equalsIgnoreCase( schemaName ) )
             {
                 byOid.remove( oid );
-                oidToSchema.remove( oid );
+                oidToDescription.remove( oid );
             }
         }
     }
@@ -163,12 +178,20 @@
         List<String> oids = new ArrayList<String>( byOid.keySet() );
         for ( String oid : oids )
         {
-            String schemaNameForOid = oidToSchema.get( oid );
+            SyntaxCheckerDescription description = oidToDescription.get( oid );
+            String schemaNameForOid = getSchema( description );
             if ( schemaNameForOid.equalsIgnoreCase( originalSchemaName ) )
             {
-                oidToSchema.remove( oid );
-                oidToSchema.put( oid, newSchemaName );
+                List<String> values = description.getExtensions().get( "X-SCHEMA" );
+                values.clear();
+                values.add( newSchemaName );
             }
         }
+    }
+
+
+    public Iterator<SyntaxCheckerDescription> syntaxCheckerDescriptionIterator()
+    {
+        return oidToDescription.values().iterator();
     }
 }

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/NormalizerRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/NormalizerRegistry.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/NormalizerRegistry.java (original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/NormalizerRegistry.java Wed Feb  7 19:01:51 2007
@@ -25,6 +25,7 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
 
 
 /**
@@ -43,7 +44,7 @@
      * @throws NamingException if the Normalizer is already registered or the
      *      registration operation is not supported
      */
-    void register( String schema, String oid, Normalizer normalizer ) throws NamingException;
+    void register( NormalizerDescription description, Normalizer normalizer ) throws NamingException;
 
 
     /**
@@ -86,6 +87,14 @@
      * @return an Iterator over the set of OID Strings in this registry
      */
     Iterator<String> oidIterator();
+
+    
+    /**
+     * Used to iterate through all normalizerDescriptions.
+     *  
+     * @return an Iterator over the set of NormalizerDescriptions in this registry
+     */
+    Iterator<NormalizerDescription> normalizerDescriptionIterator();
 
     
     /**

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SyntaxCheckerRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SyntaxCheckerRegistry.java?view=diff&rev=504773&r1=504772&r2=504773
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SyntaxCheckerRegistry.java (original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SyntaxCheckerRegistry.java Wed Feb  7 19:01:51 2007
@@ -25,6 +25,7 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
 
 
 /**
@@ -38,12 +39,12 @@
     /**
      * Registers a SyntaxChecker with this registry.
      * 
-     * @param schema the name of the schema the SyntaxChecker is associated with
+     * @param description the syntaxCheckerDescription for this syntaxChecker
      * @param syntaxChecker the SyntaxChecker to register
      * @throws NamingException if the SyntaxChecker is already registered or the
      *      registration operation is not supported
      */
-    void register( String schema, SyntaxChecker syntaxChecker ) throws NamingException;
+    void register( SyntaxCheckerDescription description, SyntaxChecker syntaxChecker ) throws NamingException;
 
 
     /**
@@ -84,6 +85,14 @@
      * @return an Iterator over all the syntaxCheckers
      */
     Iterator<SyntaxChecker> iterator();
+
+
+    /**
+     * Get's an iterator over all the syntaxCheckerDescriptions associated with this registry.
+     * 
+     * @return an Iterator over all the syntaxCheckerDescriptions
+     */
+    Iterator<SyntaxCheckerDescription> syntaxCheckerDescriptionIterator();
 
 
     /**



Mime
View raw message