You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/12/12 19:44:36 UTC

svn commit: r486272 - in /directory/branches/trunks/schema/apacheds: bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ core/src/main/java/org/apache/directory/server/core/schema/ core/src/main/java/org/apache/directory/s...

Author: akarasulu
Date: Tue Dec 12 10:44:35 2006
New Revision: 486272

URL: http://svn.apache.org/viewvc?view=rev&rev=486272
Log:
added code for loading in normalizers into bootstrap partition

Modified:
    directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java
    directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/NormalizerRegistry.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapNormalizerRegistry.java
    directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema

Modified: directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java?view=diff&rev=486272&r1=486271&r2=486272
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java (original)
+++ directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java Tue Dec 12 10:44:35 2006
@@ -46,6 +46,10 @@
  */
 public class AttributesFactory
 {
+    private static final String META_NORMALIZER_OC = "metaNormalizer";
+
+    private static final String META_SYNTAX_OC = "metaSyntax";
+
     private static final String META_SYNTAX_CHECKER_OC = "metaSyntaxChecker";
 
     private static final String OBJECT_CLASS_AT = "objectClass";
@@ -111,23 +115,10 @@
     }
 
     
-    private final String getBoolean( boolean value )
-    {
-        if ( value ) 
-        {
-            return "TRUE";
-        }
-        else
-        {
-            return "FALSE";
-        }
-    }
-    
-    
     public Attributes getAttributes( Syntax syntax )
     {
         BasicAttributes entry = new BasicAttributes( OBJECT_CLASS_AT, "top", true );
-        entry.get( OBJECT_CLASS_AT ).add( "metaSyntax" );
+        entry.get( OBJECT_CLASS_AT ).add( META_SYNTAX_OC );
         entry.put( M_OID_AT, syntax.getOid() );
         entry.put( M_OBSOLETE_AT, getBoolean( syntax.isObsolete() ) );
         entry.put( M_HUMAN_READIBLE_AT, getBoolean( syntax.isHumanReadible() ) );
@@ -141,15 +132,17 @@
     }
 
     
-    public Attributes getAttributes( Normalizer normalizer )
+    public Attributes getAttributes( String oid, Normalizer normalizer )
     {
         BasicAttributes entry = new BasicAttributes( OBJECT_CLASS_AT, "top", true );
-        entry.get( OBJECT_CLASS_AT ).add( "" );
+        entry.get( OBJECT_CLASS_AT ).add( META_NORMALIZER_OC );
+        entry.put( M_OID_AT, oid );
+        entry.put( M_FQCN_AT, normalizer.getClass().getName() );
         return entry;
     }
 
     
-    public Attributes getAttributes( Comparator<Object> comparator )
+    public Attributes getAttributes( String oid, Comparator<Object> comparator )
     {
         BasicAttributes entry = new BasicAttributes( OBJECT_CLASS_AT, "top", true );
         entry.get( OBJECT_CLASS_AT ).add( "" );
@@ -210,5 +203,18 @@
         BasicAttributes entry = new BasicAttributes( OBJECT_CLASS_AT, "top", true );
         entry.get( OBJECT_CLASS_AT ).add( "" );
         return entry;
+    }
+
+
+    private final String getBoolean( boolean value )
+    {
+        if ( value ) 
+        {
+            return "TRUE";
+        }
+        else
+        {
+            return "FALSE";
+        }
     }
 }

Modified: directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java?view=diff&rev=486272&r1=486271&r2=486272
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java (original)
+++ directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java Tue Dec 12 10:44:35 2006
@@ -35,6 +35,7 @@
 import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
 import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
+import org.apache.directory.server.core.schema.NormalizerRegistry;
 import org.apache.directory.server.core.schema.Registries;
 import org.apache.directory.server.core.schema.SyntaxCheckerRegistry;
 import org.apache.directory.server.core.schema.SyntaxRegistry;
@@ -49,6 +50,7 @@
 import org.apache.directory.shared.ldap.filter.PresenceNode;
 import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 import org.apache.maven.plugin.AbstractMojo;
@@ -125,6 +127,7 @@
 
             addSyntaxCheckers();
             addSyntaxes();
+            addNormalizers();
             
             listEntries();
         }
@@ -145,6 +148,31 @@
     }
 
     
+    private void addNormalizers() throws NamingException
+    {
+        getLog().info( "------------------------------------------------------------------------" );
+        getLog().info( " Adding normalizers" );
+        getLog().info( "------------------------------------------------------------------------" );
+
+        NormalizerRegistry normalizerRegistry = registries.getNormalizerRegistry();
+        Iterator<String> ii = normalizerRegistry.oidIterator();
+        while ( ii.hasNext() )
+        {
+            String oid = ii.next();
+            getLog().info( "Adding normalizer with oid = " + oid );
+            String schemaName = normalizerRegistry.getSchemaName( oid );
+            LdapDN dn = checkCreateSchema( schemaName );
+            dn.add( "ou=normalizers" );
+            dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+            checkCreateContainer( dn );
+            Attributes entry = attributesFactory.getAttributes( oid, normalizerRegistry.lookup( oid ) );
+            dn.add( "m-oid=" + oid );
+            dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+            partition.add( dn, entry );
+        }
+    }
+
+
     private void addSyntaxes() throws NamingException
     {
         getLog().info( "------------------------------------------------------------------------" );

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/NormalizerRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/NormalizerRegistry.java?view=diff&rev=486272&r1=486271&r2=486272
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/NormalizerRegistry.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/NormalizerRegistry.java Tue Dec 12 10:44:35 2006
@@ -20,6 +20,8 @@
 package org.apache.directory.server.core.schema;
 
 
+import java.util.Iterator;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.Normalizer;
@@ -74,4 +76,13 @@
      *      otherwise
      */
     boolean hasNormalizer( String oid );
+    
+    /**
+     * Used to iterate through all normalizers.  We have to iterate over the
+     * OID String keys because these objects do not associate a matchingRule OID
+     * with them as a class member.
+     *  
+     * @return an Iterator over the set of OID Strings in this registry
+     */
+    Iterator<String> oidIterator();
 }

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapNormalizerRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapNormalizerRegistry.java?view=diff&rev=486272&r1=486271&r2=486272
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapNormalizerRegistry.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapNormalizerRegistry.java Tue Dec 12 10:44:35 2006
@@ -21,6 +21,7 @@
 
 
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 
 import javax.naming.NamingException;
@@ -42,9 +43,9 @@
     /** static class logger */
     private final static Logger log = LoggerFactory.getLogger( BootstrapNormalizerRegistry.class );
     /** a map of Normalizers looked up by OID */
-    private final Map byOid;
+    private final Map<String, Normalizer> byOid;
     /** maps an OID to a schema name*/
-    private final Map oidToSchema;
+    private final Map<String, String> oidToSchema;
 
 
     // ------------------------------------------------------------------------
@@ -56,8 +57,8 @@
      */
     public BootstrapNormalizerRegistry()
     {
-        this.byOid = new HashMap();
-        this.oidToSchema = new HashMap();
+        this.byOid = new HashMap<String, Normalizer>();
+        this.oidToSchema = new HashMap<String, String>();
     }
 
 
@@ -108,7 +109,7 @@
 
     public String getSchemaName( String oid ) throws NamingException
     {
-        if ( Character.isDigit( oid.charAt( 0 ) ) )
+        if ( ! Character.isDigit( oid.charAt( 0 ) ) )
         {
             throw new NamingException( "Looks like the arg is not a numeric OID" );
         }
@@ -119,5 +120,11 @@
         }
 
         throw new NamingException( "OID " + oid + " not found in oid to " + "schema name map!" );
+    }
+
+
+    public Iterator<String> oidIterator()
+    {
+        return byOid.keySet().iterator();
     }
 }

Modified: directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema?view=diff&rev=486272&r1=486271&r2=486272
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema Tue Dec 12 10:44:35 2006
@@ -93,6 +93,7 @@
 #         | 1.3.6.1.4.1.18060.0.4.0.3.9  | metaDITContentRule          |
 #         | 1.3.6.1.4.1.18060.0.4.0.3.10 | metaSyntaxChecker           |
 #         | 1.3.6.1.4.1.18060.0.4.0.3.11 | metaSchema                  |
+#         | 1.3.6.1.4.1.18060.0.4.0.3.12 | metaNormalizer              |
 #         +------------------------------+-----------------------------+
 #
 # =============================================================================
@@ -209,6 +210,16 @@
     SUP metaTop
     STRUCTURAL
     MUST cn
+)
+
+# --- metaNormalizer objectclass ------------------------------------------
+objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.12
+    NAME 'metaNormalizer'
+    DESC 'Meta definition of a Normalizer object'
+    SUP metaTop
+    STRUCTURAL
+    MUST ( m-oid $ m-fqcn )
+    MAY m-bytecode
 )
 
 # =============================================================================