directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r486412 - 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...
Date Tue, 12 Dec 2006 23:33:02 GMT
Author: akarasulu
Date: Tue Dec 12 15:32:55 2006
New Revision: 486412

URL: http://svn.apache.org/viewvc?view=rev&rev=486412
Log:
got objectClass loading into the bootstrap schema partition working

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/ObjectClassRegistry.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapObjectClassRegistry.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapRegistries.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=486412&r1=486411&r2=486412
==============================================================================
--- 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 15:32:55 2006
@@ -36,6 +36,7 @@
 import org.apache.directory.shared.ldap.schema.NameForm;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 
@@ -49,6 +50,7 @@
  */
 public class AttributesFactory
 {
+    private static final String META_OBJECT_CLASS_OC = "metaObjectClass";
     private static final String META_ATTRIBUTE_TYPE_OC = "metaAttributeType";
     private static final String META_MATCHING_RULE_OC = "metaMatchingRule";
     private static final String META_NORMALIZER_OC = "metaNormalizer";
@@ -77,7 +79,6 @@
     private static final String M_NAME_AT = "m-name";
     private static final String M_DESC_AT = "m-description";
     private static final String M_OBSOLETE_AT = "m-obsolete";
-    private static final String M_SUB_OBJECT_CLASS_AT = "m-supObjectClass";
     private static final String M_MUST_AT = "m-must";
     private static final String M_MAY_AT = "m-may";
     private static final String M_TYPE_OBJECT_CLASS_AT = "m-typeObjectClass";
@@ -94,6 +95,7 @@
     private static final String M_SINGLE_VALUE_AT = "m-singleValue";
     private static final String M_USAGE_AT = "m-usage";
     // private static final String M_EXTENSION_ATTRIBUTE_TYPE_AT = "m-extensionAttributeType";
+    private static final String M_SUP_OBJECT_CLASS_AT = "m-supObjectClass";
     
     /*
     
@@ -120,15 +122,8 @@
     {
         BasicAttributes entry = new BasicAttributes( OBJECT_CLASS_AT, "top", true );
         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() ) );
-        
-        if ( syntax.getDescription() != null )
-        {
-            entry.put( M_DESC_AT, syntax.getDescription() );
-        }
-        
+        injectCommon( syntax, entry );
         return entry;
     }
 
@@ -163,25 +158,8 @@
     {
         BasicAttributes entry = new BasicAttributes( OBJECT_CLASS_AT, "top", true );
         entry.get( OBJECT_CLASS_AT ).add( META_MATCHING_RULE_OC );
-        entry.put( M_OID_AT, matchingRule.getOid() );
         entry.put( M_SYNTAX_AT, matchingRule.getSyntax().getOid() );
-        entry.put( M_OBSOLETE_AT, getBoolean( matchingRule.isObsolete() ) );
-        
-        if ( matchingRule.getName() != null )
-        {
-            Attribute attr = new BasicAttribute( M_NAME_AT );
-            for ( String name: matchingRule.getNames() )
-            {
-                attr.add( name );
-            }
-            entry.put( attr );
-        }
-        
-        if ( matchingRule.getDescription() != null )
-        {
-            entry.put( M_DESC_AT, matchingRule.getDescription() );
-        }
-
+        injectCommon( matchingRule, entry );
         return entry;
     }
 
@@ -240,14 +218,13 @@
     {
         BasicAttributes entry = new BasicAttributes( OBJECT_CLASS_AT, "top", true );
         entry.get( OBJECT_CLASS_AT ).add( META_ATTRIBUTE_TYPE_OC );
-        
-        entry.put( M_OID_AT, attributeType.getOid() );
         entry.put( M_SYNTAX_AT, attributeType.getSyntax().getOid() );
-        entry.put( M_OBSOLETE_AT, getBoolean( attributeType.isObsolete() ) );
         entry.put( M_COLLECTIVE_AT, getBoolean( attributeType.isCollective() ) );
         entry.put( M_NO_USER_MODIFICATION_AT, getBoolean( ! attributeType.isCanUserModify()
) );
         entry.put( M_SINGLE_VALUE_AT, getBoolean( attributeType.isSingleValue() ) );
         entry.put( M_USAGE_AT, attributeType.getUsage().toString() );
+
+        injectCommon( attributeType, entry );
         
         AttributeType superior = attributeType.getSuperior();
         if ( superior == null )
@@ -300,31 +277,116 @@
             
             entry.put( M_ORDERING_AT, ordering );
         }
+
+        return entry;
+    }
+
+    
+    /**
+     * Creates the attributes of an entry representing an objectClass.
+     * 
+     * <pre>
+     *  objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.2
+     *      NAME 'metaObjectclass'
+     *      DESC 'meta definition of the objectclass object'
+     *      SUP metaTop
+     *      STRUCTURAL
+     *      MUST m-oid
+     *      MAY ( m-name $ m-obsolete $ m-supObjectClass $ m-typeObjectClass $ m-must $ 
+     *            m-may $ m-extensionObjectClass )
+     *  )
+     * </pre>
+     * 
+     * @param objectClass the objectClass to produce a meta schema entry for
+     * @return the attributes of the metaSchema entry representing the objectClass
+     * @throws NamingException if there are any problems
+     */
+    public Attributes getAttributes( ObjectClass objectClass ) throws NamingException
+    {
+        BasicAttributes entry = new BasicAttributes( OBJECT_CLASS_AT, "top", true );
+        entry.get( OBJECT_CLASS_AT ).add( META_OBJECT_CLASS_OC );
+        entry.put( M_TYPE_OBJECT_CLASS_AT, objectClass.getType().toString() );
         
-        Attribute attr = new BasicAttribute( M_NAME_AT );
-        for ( String name: attributeType.getNames() )
+        injectCommon( objectClass, entry );
+
+        // handle the superior objectClasses 
+        if ( objectClass.getSuperClasses() != null && objectClass.getSuperClasses().length
!= 0 )
         {
-            attr.add( name );
+            Attribute attr = new BasicAttribute( M_SUP_OBJECT_CLASS_AT );
+            for ( ObjectClass superClass: objectClass.getSuperClasses() )
+            {
+                attr.add( getNameOrNumericoid( superClass ) ); 
+            }
+            entry.put( attr );
+        }
+
+        // add the must list
+        if ( objectClass.getMustList() != null && objectClass.getMustList().length
!= 0 )
+        {
+            Attribute attr = new BasicAttribute( M_MUST_AT );
+            for ( AttributeType mustAttribute: objectClass.getMustList() )
+            {
+                attr.add( getNameOrNumericoid( mustAttribute ) );
+            }
+            entry.put( attr );
         }
-        entry.put( attr );
         
-        if ( attributeType.getDescription() != null )
+        // add the may list
+        if ( objectClass.getMayList() != null && objectClass.getMayList().length
!= 0 )
         {
-            entry.put( M_DESC_AT, attributeType.getDescription() );
+            Attribute attr = new BasicAttribute( M_MAY_AT );
+            for ( AttributeType mayAttribute: objectClass.getMayList() )
+            {
+                attr.add( getNameOrNumericoid( mayAttribute ) );
+            }
+            entry.put( attr );
         }
-
+        
         return entry;
     }
 
     
-    public Attributes getAttributes( ObjectClass objectClass )
+    private final String getNameOrNumericoid( SchemaObject object )
     {
-        BasicAttributes entry = new BasicAttributes( OBJECT_CLASS_AT, "top", true );
-        entry.get( OBJECT_CLASS_AT ).add( "" );
-        return entry;
+        // first try to use userfriendly name if we can
+        if ( object.getName() != null )
+        {
+            return object.getName();
+        }
+        
+        return object.getOid();
+    }
+    
+    
+    private final void injectCommon( SchemaObject object, Attributes entry )
+    {
+        injectNames( object.getNames(), entry );
+        entry.put( M_OBSOLETE_AT, getBoolean( object.isObsolete() ) );
+        entry.put( M_OID_AT, object.getOid() );
+        
+        if ( object.getDescription() != null )
+        {
+            entry.put( M_DESC_AT, object.getDescription() );
+        }
+    }
+    
+    
+    private final void injectNames( String[] names, Attributes entry )
+    {
+        if ( names == null || names.length == 0 )
+        {
+            return;
+        }
+        
+        Attribute attr = new BasicAttribute( M_NAME_AT );
+        for ( String name: names )
+        {
+            attr.add( name );
+        }
+        entry.put( attr );
     }
 
-
+    
     private final String getBoolean( boolean value )
     {
         if ( value ) 

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=486412&r1=486411&r2=486412
==============================================================================
--- 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 15:32:55 2006
@@ -39,6 +39,7 @@
 import org.apache.directory.server.core.schema.ComparatorRegistry;
 import org.apache.directory.server.core.schema.MatchingRuleRegistry;
 import org.apache.directory.server.core.schema.NormalizerRegistry;
+import org.apache.directory.server.core.schema.ObjectClassRegistry;
 import org.apache.directory.server.core.schema.Registries;
 import org.apache.directory.server.core.schema.SyntaxCheckerRegistry;
 import org.apache.directory.server.core.schema.SyntaxRegistry;
@@ -55,6 +56,7 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 import org.apache.maven.plugin.AbstractMojo;
@@ -135,6 +137,7 @@
             addComparators();
             addMatchingRules();
             addAttributeTypes();
+            addObjectClasses();
             
             listEntries();
         }
@@ -174,6 +177,31 @@
             checkCreateContainer( dn );
             Attributes entry = attributesFactory.getAttributes( at );
             dn.add( "m-oid=" + at.getOid() );
+            dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+            partition.add( dn, entry );
+        }
+    }
+
+
+    private void addObjectClasses() throws NamingException
+    {
+        getLog().info( "------------------------------------------------------------------------"
);
+        getLog().info( " Adding objectClasses" );
+        getLog().info( "------------------------------------------------------------------------"
);
+
+        ObjectClassRegistry objectClassRegistry = registries.getObjectClassRegistry();
+        Iterator<ObjectClass> ii = objectClassRegistry.iterator();
+        while ( ii.hasNext() )
+        {
+            ObjectClass oc = ii.next();
+            getLog().info( "Adding objectClass with oid = " + oc.getOid() );
+            String schemaName = objectClassRegistry.getSchemaName( oc.getOid() );
+            LdapDN dn = checkCreateSchema( schemaName );
+            dn.add( "ou=objectClasses" );
+            dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+            checkCreateContainer( dn );
+            Attributes entry = attributesFactory.getAttributes( oc );
+            dn.add( "m-oid=" + oc.getOid() );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
             partition.add( dn, entry );
         }

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/ObjectClassRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/ObjectClassRegistry.java?view=diff&rev=486412&r1=486411&r2=486412
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/ObjectClassRegistry.java
(original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/ObjectClassRegistry.java
Tue Dec 12 15:32:55 2006
@@ -81,5 +81,5 @@
      *
      * @return an iterator over all ObjectClasses in registry
      */
-    Iterator list();
+    Iterator<ObjectClass> iterator();
 }

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?view=diff&rev=486412&r1=486411&r2=486412
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
(original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
Tue Dec 12 15:32:55 2006
@@ -279,10 +279,10 @@
         if ( returnAllOperationalAttributes || set.contains( "objectclasses" ) )
         {
             attr = new LockableAttributeImpl( "objectClasses" );
-            Iterator list = registries.getObjectClassRegistry().list();
+            Iterator<ObjectClass> list = registries.getObjectClassRegistry().iterator();
             while ( list.hasNext() )
             {
-                ObjectClass oc = ( ObjectClass ) list.next();
+                ObjectClass oc = list.next();
                 attr.add( SchemaUtils.render( oc ).toString() );
             }
             attrs.put( attr );

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapObjectClassRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapObjectClassRegistry.java?view=diff&rev=486412&r1=486411&r2=486412
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapObjectClassRegistry.java
(original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapObjectClassRegistry.java
Tue Dec 12 15:32:55 2006
@@ -44,9 +44,9 @@
     /** static class logger */
     private final static Logger log = LoggerFactory.getLogger( BootstrapObjectClassRegistry.class
);
     /** maps an OID to an ObjectClass */
-    private final Map byOid;
+    private final Map<String,ObjectClass> byOid;
     /** maps an OID to a schema name*/
-    private final Map oidToSchema;
+    private final Map<String,String> oidToSchema;
     /** the registry used to resolve names to OIDs */
     private final OidRegistry oidRegistry;
 
@@ -60,8 +60,8 @@
      */
     public BootstrapObjectClassRegistry(OidRegistry oidRegistry)
     {
-        this.byOid = new HashMap();
-        this.oidToSchema = new HashMap();
+        this.byOid = new HashMap<String,ObjectClass>();
+        this.oidToSchema = new HashMap<String,String>();
         this.oidRegistry = oidRegistry;
     }
 
@@ -139,7 +139,7 @@
     }
 
 
-    public Iterator list()
+    public Iterator<ObjectClass> iterator()
     {
         return byOid.values().iterator();
     }

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapRegistries.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapRegistries.java?view=diff&rev=486412&r1=486411&r2=486412
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapRegistries.java
(original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapRegistries.java
Tue Dec 12 15:32:55 2006
@@ -189,7 +189,7 @@
     {
         ArrayList errors = new ArrayList();
 
-        Iterator list = objectClassRegistry.list();
+        Iterator list = objectClassRegistry.iterator();
         while ( list.hasNext() )
         {
             ObjectClass oc = ( ObjectClass ) list.next();

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=486412&r1=486411&r2=486412
==============================================================================
--- 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 15:32:55 2006
@@ -476,9 +476,9 @@
     SINGLE-VALUE
 )
 
-# --- m-attributeTypeUusage AttributeType -------------------------------------
-attributetype ( 1.3.6.1.4.1.18060.0.4.0.2.18 NAME 'm-attributeTypeUsage'
-    DESC 'Type of operation'
+# --- m-usage AttributeType -------------------------------------
+attributetype ( 1.3.6.1.4.1.18060.0.4.0.2.18 NAME 'm-usage'
+    DESC 'Usage type of an attributeType'
     EQUALITY caseIgnoreMatch
     SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
     SINGLE-VALUE



Mime
View raw message