directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r191498 - in /directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition: DefaultContextPartitionNexus.java SystemPartition.java store/impl/btree/BTreeContextPartition.java
Date Mon, 20 Jun 2005 15:57:00 GMT
Author: trustin
Date: Mon Jun 20 08:57:00 2005
New Revision: 191498

URL: http://svn.apache.org/viewcvs?rev=191498&view=rev
Log:
Extracted custom initialization code in SystemPartition into DefaultContextPartitionNexus.initializeSystemPartition().
Now SystemPartition is just a static class that provides constants.

Modified:
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/SystemPartition.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/store/impl/btree/BTreeContextPartition.java

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java?rev=191498&r1=191497&r2=191498&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java
(original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java
Mon Jun 20 08:57:00 2005
@@ -32,6 +32,7 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
@@ -46,6 +47,8 @@
 import org.apache.ldap.common.message.LockableAttributes;
 import org.apache.ldap.common.message.LockableAttributesImpl;
 import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.common.util.DateUtils;
+import org.apache.ldap.common.util.NamespaceTools;
 import org.apache.ldap.common.util.SingletonEnumeration;
 import org.apache.ldap.server.configuration.ContextPartitionConfiguration;
 import org.apache.ldap.server.configuration.MutableContextPartitionConfiguration;
@@ -122,34 +125,15 @@
     public void init( ContextFactoryConfiguration factoryCfg, ContextPartitionConfiguration
cfg ) throws NamingException
     {
         // NOTE: We ignore ContextPartitionConfiguration parameter here.
-        
         if( initialized )
         {
             return;
         }
         
         List initializedPartitions = new ArrayList();
-        
-        // initialize system partition first
-        MutableContextPartitionConfiguration systemCfg = new MutableContextPartitionConfiguration();
-        system = new SystemPartition();
-        systemCfg.setName( "system" );
-        systemCfg.setSuffix( SystemPartition.SUFFIX );
-        systemCfg.setContextPartition( system );
-        Set indexedSystemAttrs = new HashSet();
-        indexedSystemAttrs.add( SystemPartition.ALIAS_OID );
-        indexedSystemAttrs.add( SystemPartition.EXISTANCE_OID );
-        indexedSystemAttrs.add( SystemPartition.HIERARCHY_OID );
-        indexedSystemAttrs.add( SystemPartition.NDN_OID );
-        indexedSystemAttrs.add( SystemPartition.ONEALIAS_OID );
-        indexedSystemAttrs.add( SystemPartition.SUBALIAS_OID );
-        indexedSystemAttrs.add( SystemPartition.UPDN_OID );
-        systemCfg.setIndexedAttributes( indexedSystemAttrs );
-        
-        system.init( factoryCfg, systemCfg );
-        register( system );
+        initializeSystemPartition( factoryCfg );
         initializedPartitions.add( system );
-
+        
         Iterator i = factoryCfg.getConfiguration().getContextPartitionConfigurations().iterator();
         boolean success = false;
         try
@@ -159,10 +143,6 @@
                 cfg = ( ContextPartitionConfiguration ) i.next();
                 ContextPartition partition = cfg.getContextPartition();
                 partition.init( factoryCfg, cfg );
-                partition.add(
-                        cfg.getSuffix(),
-                        cfg.getNormalizedSuffix( factoryCfg.getGlobalRegistries().getMatchingRuleRegistry()
),
-                        cfg.getContextEntry() );
                 initializedPartitions.add( 0, partition );
                 register( partition );
             }
@@ -192,6 +172,42 @@
                 }
             }
         }
+    }
+
+
+    private void initializeSystemPartition( ContextFactoryConfiguration factoryCfg ) throws
NamingException
+    {
+        // initialize system partition first
+        MutableContextPartitionConfiguration systemCfg = new MutableContextPartitionConfiguration();
+        system = new SystemPartition();
+        systemCfg.setName( "system" );
+        systemCfg.setSuffix( SystemPartition.SUFFIX );
+        systemCfg.setContextPartition( system );
+        
+        // Add indexed attributes for system partition
+        Set indexedSystemAttrs = new HashSet();
+        indexedSystemAttrs.add( SystemPartition.ALIAS_OID );
+        indexedSystemAttrs.add( SystemPartition.EXISTANCE_OID );
+        indexedSystemAttrs.add( SystemPartition.HIERARCHY_OID );
+        indexedSystemAttrs.add( SystemPartition.NDN_OID );
+        indexedSystemAttrs.add( SystemPartition.ONEALIAS_OID );
+        indexedSystemAttrs.add( SystemPartition.SUBALIAS_OID );
+        indexedSystemAttrs.add( SystemPartition.UPDN_OID );
+        systemCfg.setIndexedAttributes( indexedSystemAttrs );
+        
+        // Add context entry for system partition
+        Attributes systemEntry = new BasicAttributes();
+        systemEntry.put( "objectClass", "top" ) ;
+        systemEntry.put( "objectClass", "organizationalUnit" ) ;
+        systemEntry.put( "creatorsName", SystemPartition.ADMIN_PRINCIPAL ) ;
+        systemEntry.put( "createTimestamp", DateUtils.getGeneralizedTime() ) ;
+        systemEntry.put(
+                NamespaceTools.getRdnAttribute( SystemPartition.SUFFIX ),
+                NamespaceTools.getRdnValue( SystemPartition.SUFFIX ) ) ;
+        systemCfg.setContextEntry( systemEntry );
+
+        system.init( factoryCfg, systemCfg );
+        register( system );
     }
 
 

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/SystemPartition.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/SystemPartition.java?rev=191498&r1=191497&r2=191498&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/SystemPartition.java
(original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/SystemPartition.java
Mon Jun 20 08:57:00 2005
@@ -18,14 +18,8 @@
 
 import javax.naming.Name;
 import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
 
-import org.apache.ldap.common.message.LockableAttributesImpl;
 import org.apache.ldap.common.name.LdapName;
-import org.apache.ldap.common.util.DateUtils;
-import org.apache.ldap.common.util.NamespaceTools;
-import org.apache.ldap.server.configuration.ContextPartitionConfiguration;
-import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 import org.apache.ldap.server.partition.store.impl.btree.jdbm.JdbmContextPartition;
 
 
@@ -151,32 +145,5 @@
      */
     public SystemPartition()
     {
-    }
-
-
-    // ------------------------------------------------------------------------
-    // B A C K E N D   M E T H O D S 
-    // ------------------------------------------------------------------------
-
-    public void init( ContextFactoryConfiguration factoryCfg, ContextPartitionConfiguration
cfg ) throws NamingException
-    {
-        super.init( factoryCfg, cfg );
-
-        Name suffix = cfg.getNormalizedSuffix( factoryCfg.getGlobalRegistries().getMatchingRuleRegistry()
);
-        
-        // add the root entry for the system root context if it does not exist
-        Attributes attributes = cfg.getContextEntry();
-        if( attributes == null || attributes.size() == 0 )
-        {
-            attributes = new LockableAttributesImpl() ;
-            attributes.put( "objectClass", "top" ) ;
-            attributes.put( "objectClass", "organizationalUnit" ) ;
-            attributes.put( "creatorsName", ADMIN_PRINCIPAL ) ;
-            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() ) ;
-            attributes.put( NamespaceTools.getRdnAttribute( SUFFIX ),
-                NamespaceTools.getRdnValue( SUFFIX ) ) ;
-
-            add( suffix.toString(), suffix, attributes ) ;
-        }
     }
 }

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/store/impl/btree/BTreeContextPartition.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/store/impl/btree/BTreeContextPartition.java?rev=191498&r1=191497&r2=191498&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/store/impl/btree/BTreeContextPartition.java
(original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/store/impl/btree/BTreeContextPartition.java
Mon Jun 20 08:57:00 2005
@@ -191,6 +191,10 @@
                 addIndexOn( type );
             }
         }
+        
+        add( cfg.getSuffix(),
+                cfg.getNormalizedSuffix( factoryCfg.getGlobalRegistries().getMatchingRuleRegistry()
),
+                cfg.getContextEntry() );
     }
 
     



Mime
View raw message