directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r679219 - in /directory/apacheds/branches/bigbang: core-constants/src/main/java/org/apache/directory/server/constants/ core-integ/ core-integ/src/test/java/org/apache/directory/server/core/sp/ core-jndi/src/main/java/org/ core-jndi/src/main...
Date Wed, 23 Jul 2008 22:45:06 GMT
Author: akarasulu
Date: Wed Jul 23 15:45:05 2008
New Revision: 679219

URL: http://svn.apache.org/viewvc?rev=679219&view=rev
Log:
DIRSERVER-1206: moving code for JNDI into its own module out of core. Note some things like dns, kerberos etc seem still to depend on JNDI but that can be slowly decoupled

Added:
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/CoreContextFactory.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/CoreContextFactory.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/DeadContext.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/DeadContext.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/EventListenerAdapter.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/EventListenerAdapter.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/JndiUtils.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/JndiUtils.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/NamingEnumerationAdapter.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/NamingEnumerationAdapter.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirObjectFactory.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirObjectFactory.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirStateFactory.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirStateFactory.java
    directory/apacheds/branches/bigbang/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java
      - copied unchanged from r679150, directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java
    directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/
    directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/apache/
    directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/apache/directory/
    directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/apache/directory/server/
    directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/apache/directory/server/core/
    directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/apache/directory/server/core/jndi/
    directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java
      - copied, changed from r679150, directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java
Removed:
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/CoreContextFactory.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/DeadContext.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/EventListenerAdapter.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/JndiUtils.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/NamingEnumerationAdapter.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirObjectFactory.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirStateFactory.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java
    directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java
Modified:
    directory/apacheds/branches/bigbang/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java
    directory/apacheds/branches/bigbang/core-integ/pom.xml
    directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/sp/LdapClassLoaderIT.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/LdapClassLoader.java
    directory/apacheds/branches/bigbang/kerberos-shared/pom.xml
    directory/apacheds/branches/bigbang/mitosis/pom.xml
    directory/apacheds/branches/bigbang/protocol-dns/pom.xml
    directory/apacheds/branches/bigbang/server-jndi/pom.xml
    directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java

Modified: directory/apacheds/branches/bigbang/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java (original)
+++ directory/apacheds/branches/bigbang/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java Wed Jul 23 15:45:05 2008
@@ -135,4 +135,7 @@
     // WindowsFilePath
     String UNIX_FILE_AT                             = "unixFilePath";
     String UNIX_FILE_AT_OID                         = "1.3.6.1.4.1.18060.0.4.1.2.20";
+
+    String PREF_NODE_NAME_AT                        = "prefNodeName";
+    String PREF_NODE_NAME_AT_OID                    = "1.3.6.1.4.1.18060.0.4.1.2.8";
 }

Modified: directory/apacheds/branches/bigbang/core-integ/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/pom.xml?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-integ/pom.xml (original)
+++ directory/apacheds/branches/bigbang/core-integ/pom.xml Wed Jul 23 15:45:05 2008
@@ -48,7 +48,7 @@
 
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core</artifactId>
+      <artifactId>apacheds-core-jndi</artifactId>
       <version>${pom.version}</version>
     </dependency>  
 

Modified: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/sp/LdapClassLoaderIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/sp/LdapClassLoaderIT.java?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/sp/LdapClassLoaderIT.java (original)
+++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/sp/LdapClassLoaderIT.java Wed Jul 23 15:45:05 2008
@@ -81,7 +81,7 @@
         assertNotNull( defaultContext.lookup( "fullyQualifiedJavaClassName=HelloWorld" ) );
 
         // load the class
-        LdapClassLoader loader = new LdapClassLoader( ( ServerLdapContext ) ( root.lookup( "" ) ) );
+        LdapClassLoader loader = new LdapClassLoader( service );
         Class<?> clazz = loader.loadClass( "HelloWorld" );
 
         // assert class loaded successfully
@@ -130,7 +130,7 @@
         assertNotNull( defaultContext.lookup( "fullyQualifiedJavaClassName=HelloWorld" ) );
 
         // load the class
-        LdapClassLoader loader = new LdapClassLoader( ( ServerLdapContext ) ( root.lookup( "" ) ) );
+        LdapClassLoader loader = new LdapClassLoader( service );
         Class clazz = loader.loadClass( "HelloWorld" );
 
         // assert class loaded successfully

Copied: directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java (from r679150, directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java?p2=directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java&p1=directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java&r1=679150&r2=679219&rev=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java (original)
+++ directory/apacheds/branches/bigbang/core-jndi/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java Wed Jul 23 15:45:05 2008
@@ -45,7 +45,7 @@
     {
         try
         {
-            LdapJndiProperties.getLdapJndiProperties( new Hashtable() );
+            LdapJndiProperties.getLdapJndiProperties( new Hashtable<String,Object>() );
             fail( "should never get here" );
         }
         catch ( LdapConfigurationException e )
@@ -69,7 +69,7 @@
 
     public void testNoAuthWithCredsEnv() throws Exception
     {
-        Hashtable env = new Hashtable();
+        Hashtable<String,Object> env = new Hashtable<String,Object>();
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
         env.put( Context.SECURITY_CREDENTIALS, "asdf" );
         env.put( Context.PROVIDER_URL, "" );
@@ -81,7 +81,7 @@
 
     public void testNoAuthWithNoCredsEnv() throws Exception
     {
-        Hashtable env = new Hashtable();
+        Hashtable<String,Object> env = new Hashtable<String,Object>();
         env.put( Context.SECURITY_PRINCIPAL, "" );
         env.put( Context.PROVIDER_URL, "" );
         LdapJndiProperties props = LdapJndiProperties.getLdapJndiProperties( env );
@@ -92,7 +92,7 @@
 
     public void testAuthWithNoCredsEnv() throws Exception
     {
-        Hashtable env = new Hashtable();
+        Hashtable<String,Object> env = new Hashtable<String,Object>();
         env.put( Context.SECURITY_PRINCIPAL, "" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         try
@@ -108,7 +108,7 @@
 
     public void testAuthWithNoCredsStrong() throws Exception
     {
-        Hashtable env = new Hashtable();
+        Hashtable<String,Object> env = new Hashtable<String,Object>();
         env.put( Context.SECURITY_PRINCIPAL, "" );
         env.put( Context.SECURITY_AUTHENTICATION, "DIGEST-MD5 CRAM-MD5" );
         env.put( Context.PROVIDER_URL, "" );
@@ -120,7 +120,7 @@
 
     public void testAuthWithCredsStrong() throws Exception
     {
-        Hashtable env = new Hashtable();
+        Hashtable<String,Object> env = new Hashtable<String,Object>();
         env.put( Context.SECURITY_PRINCIPAL, "" );
         env.put( Context.SECURITY_CREDENTIALS, "asdf" );
         env.put( Context.SECURITY_AUTHENTICATION, "DIGEST-MD5 CRAM-MD5" );

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Wed Jul 23 15:45:05 2008
@@ -46,7 +46,6 @@
 import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
 import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.interceptor.context.RemoveContextPartitionOperationContext;
-import org.apache.directory.server.core.jndi.ServerLdapContext;
 import org.apache.directory.server.core.normalization.NormalizationInterceptor;
 import org.apache.directory.server.core.operational.OperationalAttributeInterceptor;
 import org.apache.directory.server.core.partition.DefaultPartitionNexus;
@@ -1222,9 +1221,6 @@
      */
     private void createTestEntries() throws Exception
     {
-        LdapPrincipal principal = new LdapPrincipal( adminDn, AuthenticationLevel.SIMPLE );
-        ServerLdapContext ctx = new ServerLdapContext( this, principal, new LdapDN() );
-
         for ( LdifEntry testEntry : testEntries )
         {
             try
@@ -1235,7 +1231,7 @@
 
                 try
                 {
-                    ctx.createSubcontext( dn, attributes );
+                    getAdminSession().add( ServerEntryUtils.toServerEntry( attributes, new LdapDN( dn ), registries ) );
                 }
                 catch ( Exception e )
                 {

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java Wed Jul 23 15:45:05 2008
@@ -27,7 +27,6 @@
 import org.apache.directory.server.core.event.EventService;
 import org.apache.directory.server.core.interceptor.Interceptor;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
-import org.apache.directory.server.core.jndi.AbstractContextFactory;
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.core.schema.SchemaService;

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java Wed Jul 23 15:45:05 2008
@@ -24,7 +24,6 @@
 
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
-import org.apache.directory.server.core.jndi.ServerContext;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.shared.ldap.name.LdapDN;
 

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java Wed Jul 23 15:45:05 2008
@@ -21,30 +21,27 @@
 
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.jndi.CoreContextFactory;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.entry.DefaultServerAttribute;
+import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerModification;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
-import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.util.PreferencesDictionary;
 
-import javax.naming.Context;
-import javax.naming.NameClassPair;
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.ldap.LdapContext;
 
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.prefs.AbstractPreferences;
 import java.util.prefs.BackingStoreException;
@@ -61,55 +58,36 @@
  */
 public class ServerSystemPreferences extends AbstractPreferences
 {
-    /** an empty array of ModificationItems used to get array from list */
-    private static final ModificationItemImpl[] EMPTY_MODS = new ModificationItemImpl[0];
-
     /** an empty array of Strings used to get array from list */
     private static final String[] EMPTY_STRINGS = new String[0];
 
-    /** the LDAP context representing this preferences object */
-    private LdapContext ctx;
-
-    /** the changes (ModificationItems) representing cached alterations to preferences */
-    private List<ModificationItem> changes = new ArrayList<ModificationItem>( 3 );
+    /** the changes representing cached alterations to preferences */
+    private List<Modification> changes = new ArrayList<Modification>( 3 );
 
     /** maps changes based on key: key->list of mods (on same key) */
-    private HashMap<String, List<ModificationItem>> keyToChange = new HashMap<String, List<ModificationItem>>( 3 );
+    private HashMap<String, List<Modification>> keyToChange = new HashMap<String, List<Modification>>( 3 );
+    
+    private LdapDN dn;
+    
+    private DirectoryService directoryService;
+    
 
 
     /**
      * Creates a preferences object for the system preferences root.
-     * @param service the directory service core
+     * @param directoryService the directory service core
      */
-    public ServerSystemPreferences( DirectoryService service )
+    public ServerSystemPreferences( DirectoryService directoryService )
     {
         super( null, "" );
         super.newNode = false;
-
-        Hashtable<String, Object> env = new Hashtable<String, Object>();
-        env.put( DirectoryService.JNDI_KEY, service );
-        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
-        env.put( Context.PROVIDER_URL, ServerDNConstants.SYSPREFROOT_SYSTEM_DN );
-
-        try
-        {
-            ctx = new InitialLdapContext( env, null );
-        }
-        catch ( Exception e )
-        {
-            throw new ServerSystemPreferenceException( "Failed to open.", e );
-        }
+        dn = new LdapDN();
+        this.directoryService = directoryService;
     }
 
-
-    public synchronized void close() throws NamingException
+    
+    public void close() throws NamingException
     {
-        if ( this.parent() != null )
-        {
-            throw new ServerSystemPreferenceException( "Cannot close child preferences." );
-        }
-
-        this.ctx.close();
     }
 
 
@@ -122,12 +100,13 @@
     public ServerSystemPreferences( ServerSystemPreferences parent, String name )
     {
         super( parent, name );
-        LdapContext parentCtx = parent.getLdapContext();
 
         try
         {
-            ctx = ( LdapContext ) parentCtx.lookup( "prefNodeName=" + name );
+            dn = new LdapDN( "prefNodeName=" + name );
             super.newNode = false;
+            this.directoryService = parent.directoryService;
+            dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
         }
         catch ( NamingException e )
         {
@@ -153,49 +132,34 @@
     // ------------------------------------------------------------------------
 
     /**
-     * Wrapps this ServerPreferences object as a Dictionary.
+     * Wraps this ServerPreferences object as a Dictionary.
      *
      * @return a Dictionary that uses this ServerPreferences object as the underlying backing store
      */
-    public Dictionary wrapAsDictionary()
+    public Dictionary<String, String> wrapAsDictionary()
     {
         return new PreferencesDictionary( this );
     }
 
 
     /**
-     * Gets access to the LDAP context associated with this ServerPreferences node.
-     *
-     * @return the LDAP context associate with this ServerPreferences node
-     */
-    LdapContext getLdapContext()
-    {
-        return ctx;
-    }
-
-
-    /**
      * Sets up a new ServerPreferences node by injecting the required information
      * such as the node name attribute and the objectClass attribute.
      *
      * @param name the name of the new ServerPreferences node
      * @throws NamingException if we fail to created the new node
      */
-    private void setUpNode( String name ) throws NamingException
+    private void setUpNode( String name ) throws Exception
     {
-        Attributes attrs = new AttributesImpl();
-        Attribute attr = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
-        attr.add( SchemaConstants.TOP_OC );
-        attr.add( ApacheSchemaConstants.PREF_NODE_OC );
-        attr.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
-        attrs.put( attr );
-        attr = new AttributeImpl( "prefNodeName" );
-        attr.add( name );
-        attrs.put( attr );
-
-        LdapContext parent = ( ( ServerSystemPreferences ) parent() ).getLdapContext();
-        parent.bind( "prefNodeName=" + name, null, attrs );
-        ctx = ( LdapContext ) parent.lookup( "prefNodeName=" + name );
+        LdapDN parent = ( ( ServerSystemPreferences ) parent() ).dn;
+        LdapDN child = new LdapDN( parent.getNormName() + ",prefNodeName=" + name );
+        child.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+        ServerEntry entry = directoryService.newEntry( child );
+        entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, 
+            ApacheSchemaConstants.PREF_NODE_OC, SchemaConstants.EXTENSIBLE_OBJECT_OC );
+        entry.add( "prefNodeName", name );
+
+        directoryService.getAdminSession().add( entry );
         super.newNode = false;
     }
 
@@ -206,11 +170,6 @@
 
     protected void flushSpi() throws BackingStoreException
     {
-        if ( ctx == null )
-        {
-            throw new BackingStoreException( "Ldap context not available for " + super.absolutePath() );
-        }
-
         if ( changes.isEmpty() )
         {
             return;
@@ -218,10 +177,9 @@
 
         try
         {
-            //noinspection SuspiciousToArrayCall
-            ctx.modifyAttributes( "", changes.toArray( EMPTY_MODS ) );
+            directoryService.getAdminSession().modify( dn, changes );
         }
-        catch ( NamingException e )
+        catch ( Exception e )
         {
             throw new BackingStoreException( e );
         }
@@ -235,14 +193,13 @@
     {
         try
         {
-            ctx.destroySubcontext( "" );
+            directoryService.getAdminSession().delete( dn );
         }
-        catch ( NamingException e )
+        catch ( Exception e )
         {
             throw new BackingStoreException( e );
         }
 
-        ctx = null;
         changes.clear();
         keyToChange.clear();
     }
@@ -250,11 +207,6 @@
 
     protected void syncSpi() throws BackingStoreException
     {
-        if ( ctx == null )
-        {
-            throw new BackingStoreException( "Ldap context not available for " + super.absolutePath() );
-        }
-
         if ( changes.isEmpty() )
         {
             return;
@@ -262,10 +214,9 @@
 
         try
         {
-            //noinspection SuspiciousToArrayCall
-            ctx.modifyAttributes( "", changes.toArray( EMPTY_MODS ) );
+            directoryService.getAdminSession().modify( dn, changes );
         }
-        catch ( NamingException e )
+        catch ( Exception e )
         {
             throw new BackingStoreException( e );
         }
@@ -278,20 +229,19 @@
     protected String[] childrenNamesSpi() throws BackingStoreException
     {
         List<String> children = new ArrayList<String>();
-        NamingEnumeration list;
+        EntryFilteringCursor list;
 
         try
         {
-            list = ctx.list( "" );
-            
-            while ( list.hasMore() )
+            list = directoryService.getAdminSession().list( dn, AliasDerefMode.DEREF_ALWAYS, null );
+            list.beforeFirst();
+            while ( list.next() )
             {
-                NameClassPair ncp = ( NameClassPair ) list.next();
-
-                children.add( ncp.getName() );
+                ClonedServerEntry entry = list.get();
+                children.add( ( String ) entry.getDn().getRdn().getValue() );
             }
         }
-        catch ( NamingException e )
+        catch ( Exception e )
         {
             throw new BackingStoreException( e );
         }
@@ -302,27 +252,26 @@
 
     protected String[] keysSpi() throws BackingStoreException
     {
-        Attributes attrs;
         List<String> keys = new ArrayList<String>();
 
         try
         {
-            attrs = ctx.getAttributes( "" );
-            NamingEnumeration ids = attrs.getIDs();
-            
-            while ( ids.hasMore() )
+            ServerEntry entry = directoryService.getAdminSession().lookup( dn );
+            for ( EntryAttribute attr : entry )
             {
-                String id = ( String ) ids.next();
+                ServerAttribute sa = ( ServerAttribute ) attr;
+                String oid = sa.getAttributeType().getOid();
                 
-                if ( id.equals( SchemaConstants.OBJECT_CLASS_AT ) || id.equals( "prefNodeName" ) )
+                if ( oid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) || 
+                     oid.equals( ApacheSchemaConstants.PREF_NODE_NAME_AT_OID ) )
                 {
                     continue;
                 }
                 
-                keys.add( id );
+                keys.add( sa.getUpId() );
             }
         }
-        catch ( NamingException e )
+        catch ( Exception e )
         {
             throw new BackingStoreException( e );
         }
@@ -331,18 +280,27 @@
     }
 
 
-    protected void removeSpi( String key )
+    protected void removeSpi( String key ) 
     {
-        Attribute attr = new AttributeImpl( key );
-        ModificationItemImpl mi = new ModificationItemImpl( DirContext.REMOVE_ATTRIBUTE, attr );
-        addDelta( mi );
+        AttributeType at;
+        try
+        {
+            at = directoryService.getRegistries().getAttributeTypeRegistry().lookup( key );
+            ServerAttribute attr = new DefaultServerAttribute( at );
+            Modification mi = new ServerModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
+            addDelta( mi );
+        }
+        catch ( NamingException e )
+        {
+            e.printStackTrace();
+        }
     }
 
 
-    private void addDelta( ModificationItemImpl mi )
+    private void addDelta( Modification mi )
     {
-        String key = mi.getAttribute().getID();
-        List<ModificationItem> deltas;
+        String key = mi.getAttribute().getUpId();
+        List<Modification> deltas;
         changes.add( mi );
         
         if ( keyToChange.containsKey( key ) )
@@ -351,7 +309,7 @@
         }
         else
         {
-            deltas = new ArrayList<ModificationItem>();
+            deltas = new ArrayList<Modification>();
         }
 
         deltas.add( mi );
@@ -361,17 +319,15 @@
 
     protected String getSpi( String key )
     {
-        String value;
-
         try
         {
-            Attribute attr = ctx.getAttributes( "" ).get( key );
+            EntryAttribute attr = null;
+            
             if ( keyToChange.containsKey( key ) )
             {
-                List<ModificationItem> mods = keyToChange.get( key );
-                for ( ModificationItem mod : mods )
+                for ( Modification mod : keyToChange.get( key ) )
                 {
-                    if ( mod.getModificationOp() == DirContext.REMOVE_ATTRIBUTE )
+                    if ( mod.getOperation() == ModificationOperation.REMOVE_ATTRIBUTE )
                     {
                         attr = null;
                     }
@@ -386,24 +342,32 @@
             {
                 return null;
             }
-
-            value = ( String ) attr.get();
+            else
+            {
+                return attr.getUpId();
+            }
         }
         catch ( Exception e )
         {
             throw new ServerSystemPreferenceException( "Failed to get SPI.", e );
         }
-
-        return value;
     }
 
 
     protected void putSpi( String key, String value )
     {
-        Attribute attr = new AttributeImpl( key );
-        attr.add( value );
-        ModificationItemImpl mi = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, attr );
-        addDelta( mi );
+        AttributeType at;
+        try
+        {
+            at = directoryService.getRegistries().getAttributeTypeRegistry().lookup( key );
+            ServerAttribute attr = new DefaultServerAttribute( at, value );
+            Modification mi = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attr );
+            addDelta( mi );
+        }
+        catch ( NamingException e )
+        {
+            e.printStackTrace();
+        }
     }
 
 

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/LdapClassLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/LdapClassLoader.java?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/LdapClassLoader.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/LdapClassLoader.java Wed Jul 23 15:45:05 2008
@@ -17,24 +17,29 @@
  *  under the License. 
  *  
  */
-
-
 package org.apache.directory.server.core.sp;
 
 
-import javax.naming.NamingEnumeration;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.core.jndi.ServerLdapContext;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
+import org.apache.directory.server.core.interceptor.context.ListSuffixOperationContext;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.EqualityNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 import org.slf4j.Logger;
@@ -59,90 +64,110 @@
 {
     private static final Logger log = LoggerFactory.getLogger( LdapClassLoader.class );
     public static String defaultSearchContextsConfig = "cn=classLoaderDefaultSearchContext,ou=configuration,ou=system";
-    private ServerLdapContext RootDSE;
+    
+    private LdapDN defaultSearchDn;
+    private DirectoryService directoryService;
 
-    public LdapClassLoader( ServerLdapContext RootDSE ) throws NamingException
+    
+    public LdapClassLoader( DirectoryService directoryService ) throws NamingException
     {
         super( LdapClassLoader.class.getClassLoader() );
-        this.RootDSE = ( ( ServerLdapContext ) RootDSE.lookup( "" ) );
+        this.directoryService = directoryService;
+        defaultSearchDn = new LdapDN( defaultSearchContextsConfig );
+        defaultSearchDn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
     }
 
-    private byte[] findClassInDIT( NamingEnumeration searchContexts, String name ) throws ClassNotFoundException
+    
+    private byte[] findClassInDIT( List<LdapDN> searchContexts, String name ) throws ClassNotFoundException
     {
-        String currentSearchContextName = null;
-        ServerLdapContext currentSearchContext = null;
-        NamingEnumeration javaClassEntries = null;
-        byte[] classBytes = null;
-        
+        // Set up the search filter
         BranchNode filter = new AndNode( );
-        filter.addNode( new EqualityNode( "fullyQualifiedJavaClassName", new ClientStringValue( name ) ) );
-        filter.addNode( new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, new ClientStringValue( ApacheSchemaConstants.JAVA_CLASS_OC ) ) );
-        
-        SearchControls controls = new SearchControls();
-        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+        filter.addNode( new EqualityNode<String>( "fullyQualifiedJavaClassName", 
+            new ClientStringValue( name ) ) );
+        filter.addNode( new EqualityNode<String>( SchemaConstants.OBJECT_CLASS_AT, 
+            new ClientStringValue( ApacheSchemaConstants.JAVA_CLASS_OC ) ) );
         
         try
         {
-            while( searchContexts.hasMore() )
+            for ( LdapDN base : searchContexts )
             {
-                currentSearchContextName = ( String ) searchContexts.next();
-                
-                if ( currentSearchContextName == null )
+                EntryFilteringCursor cursor = null;
+                try
                 {
-                    continue;
+                    cursor = directoryService.getAdminSession()
+                        .search( base, SearchScope.SUBTREE, filter, AliasDerefMode.DEREF_ALWAYS, null );
+                    
+                    cursor.beforeFirst();
+                    if ( cursor.next() ) // there should be only one!
+                    {
+                        log.debug( "Class {} found under {} search context.", name, base );
+                        ServerEntry classEntry = cursor.get();
+
+                        if ( cursor.next() )
+                        {
+                            ServerEntry other = cursor.get();
+                            log.warn( "More than one class found on classpath at locations: {} \n\tand {}", 
+                                classEntry, other );
+                        }
+
+                        return classEntry.get( "javaClassByteCode" ).getBytes();
+                    }
                 }
-                
-                currentSearchContext = ( ServerLdapContext ) RootDSE.lookup( currentSearchContextName );
-                
-                javaClassEntries = currentSearchContext.search( LdapDN.EMPTY_LDAPDN, filter, controls );
-                if ( javaClassEntries.hasMore() ) // there should be only one!
+                finally
                 {
-                    log.debug( "Class " + name + " found under " + currentSearchContextName + " search context." );
-                    SearchResult javaClassEntry = ( SearchResult ) javaClassEntries.next();
-                    Attribute byteCode = javaClassEntry.getAttributes().get( "javaClassByteCode" );
-                    classBytes = ( byte[] ) byteCode.get();
-                    break; // exit on first hit!
+                    if ( cursor != null )
+                    {
+                        cursor.close();
+                    }
                 }
             }
         }
-        catch ( NamingException e )
+        catch ( Exception e )
         {
-            throw new ClassNotFoundException();
+            log.error( "Exception while searching the DIT for class: " + name, e );
         }
-        
-        return classBytes;
+
+        throw new ClassNotFoundException();
     }
     
+    
     public Class<?> findClass( String name ) throws ClassNotFoundException
     {
         byte[] classBytes = null;
 
-        NamingEnumeration defaultSearchContexts = null;
-        NamingEnumeration namingContexts = null;
-        
-        ServerLdapContext defaultSearchContextsConfigContext = null;
-        
         try 
         {   
+            // TODO we should cache this information and register with the event
+            // service to get notified if this changes so we can update the cached
+            // copy - there's absolutely no reason why we should be performing this
+            // lookup every time!!!
+            
+            ServerEntry configEntry = null;
+            
             try
             {
-                defaultSearchContextsConfigContext = 
-                    ( ServerLdapContext ) RootDSE.lookup( defaultSearchContextsConfig );
+                configEntry = directoryService.getAdminSession().lookup( defaultSearchDn );
             }
             catch ( NamingException e )
             {
                 log.debug( "No configuration data found for class loader default search contexts." );
             }
             
-            if ( defaultSearchContextsConfigContext != null )
+            if ( configEntry != null )
             {
-                defaultSearchContexts = defaultSearchContextsConfigContext
-                    .getAttributes( "", new String[] { "classLoaderDefaultSearchContext" } )
-                    .get( "classLoaderDefaultSearchContext" ).getAll();
+                List<LdapDN> searchContexts = new ArrayList<LdapDN>();
+                EntryAttribute attr = configEntry.get( "classLoaderDefaultSearchContext" );
+                
+                for ( Value<?> val : attr )
+                {
+                    LdapDN dn = new LdapDN( ( String ) val.get() );
+                    dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+                    searchContexts.add( dn );
+                }
                 
                 try
                 {
-                    classBytes = findClassInDIT( defaultSearchContexts, name );
+                    classBytes = findClassInDIT( searchContexts, name );
                     
                     log.debug( "Class " + name + " found under default search contexts." );
                 }
@@ -154,29 +179,35 @@
             
             if ( classBytes == null )
             {
-                namingContexts = RootDSE
-                    .getAttributes( "", new String[] { "namingContexts" } )
-                    .get( "namingContexts" ).getAll();
+                List<LdapDN> namingContexts = new ArrayList<LdapDN>();
+                
+                // TODO - why is this an operation????  Why can't we just list these damn things
+                // who went stupid crazy making everything into a damn operation  !!!! grrrr 
+                Iterator<String> suffixes = 
+                    directoryService.getPartitionNexus().listSuffixes( 
+                        new ListSuffixOperationContext( directoryService.getAdminSession() ) );
+
+                while ( suffixes.hasNext() )
+                {
+                    LdapDN dn = new LdapDN( suffixes.next() );
+                    dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+                    namingContexts.add( dn );
+                }
                 
                 classBytes = findClassInDIT( namingContexts, name );
             }
         } 
-        catch ( NamingException e ) 
-        {
-            String msg = "Encountered JNDI failure while searching directory for class: " + name;
-            log.error( msg + e );
-            throw new ClassNotFoundException( msg );
-        }
         catch ( ClassNotFoundException e )
         {
             String msg = "Class " + name + " not found in DIT.";
             log.debug( msg );
             throw new ClassNotFoundException( msg );
         }
-        finally
+        catch ( Exception e ) 
         {
-            if ( defaultSearchContexts != null ) { try { defaultSearchContexts.close(); } catch( Exception e ) {} }
-            if ( namingContexts != null ) { try { namingContexts.close(); } catch( Exception e ) {} }
+            String msg = "Encountered failure while searching directory for class: " + name;
+            log.error( msg + e );
+            throw new ClassNotFoundException( msg );
         }
         
         return defineClass( name, classBytes, 0, classBytes.length );

Modified: directory/apacheds/branches/bigbang/kerberos-shared/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/pom.xml?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/pom.xml (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/pom.xml Wed Jul 23 15:45:05 2008
@@ -41,9 +41,10 @@
       <artifactId>mina-core</artifactId>
     </dependency>
 
+    <!-- TODO remove dependency on JNDI core -->
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core</artifactId>
+      <artifactId>apacheds-core-jndi</artifactId>
       <version>${pom.version}</version>
     </dependency>
 

Modified: directory/apacheds/branches/bigbang/mitosis/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/pom.xml?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/pom.xml (original)
+++ directory/apacheds/branches/bigbang/mitosis/pom.xml Wed Jul 23 15:45:05 2008
@@ -82,9 +82,10 @@
       <artifactId>mina-core</artifactId>
     </dependency>
 
+    <!-- TODO remove dependency on JNDI core -->
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core</artifactId>
+      <artifactId>apacheds-core-jndi</artifactId>
       <version>${pom.version}</version>
     </dependency>
 

Modified: directory/apacheds/branches/bigbang/protocol-dns/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-dns/pom.xml?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-dns/pom.xml (original)
+++ directory/apacheds/branches/bigbang/protocol-dns/pom.xml Wed Jul 23 15:45:05 2008
@@ -37,9 +37,10 @@
 
   <dependencies>
 
+    <!-- TODO remove dependency on JNDI core -->
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core</artifactId>
+      <artifactId>apacheds-core-jndi</artifactId>
       <version>${pom.version}</version>
     </dependency>
 

Modified: directory/apacheds/branches/bigbang/server-jndi/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-jndi/pom.xml?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-jndi/pom.xml (original)
+++ directory/apacheds/branches/bigbang/server-jndi/pom.xml Wed Jul 23 15:45:05 2008
@@ -76,9 +76,10 @@
     </dependency>
 -->
 
+    <!-- TODO remove dependency on JNDI core -->
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core</artifactId>
+      <artifactId>apacheds-core-jndi</artifactId>
       <version>${pom.version}</version>
     </dependency>  
   </dependencies>

Modified: directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java?rev=679219&r1=679218&r2=679219&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java (original)
+++ directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java Wed Jul 23 15:45:05 2008
@@ -23,18 +23,15 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.constants.ServerDNConstants;
-import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.jndi.ServerLdapContext;
 import org.apache.directory.server.newldap.LdapServer;
 import org.apache.directory.server.protocol.shared.store.LdifFileLoader;
 import org.apache.directory.server.protocol.shared.store.LdifLoadFilter;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.mina.common.ByteBuffer;
@@ -42,7 +39,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 
 import java.io.File;
@@ -261,20 +257,27 @@
      * 
      * The files are stored in ou=loadedLdifFiles,ou=configuration,ou=system
      */
-    private void ensureLdifFileBase( DirContext root )
+    private void ensureLdifFileBase() throws Exception
     {
-        Attributes entry = new AttributesImpl( SchemaConstants.OU_AT, "loadedLdifFiles", true );
-        entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC );
-        entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
-
+        LdapDN dn = new LdapDN( ServerDNConstants.LDIF_FILES_DN );
+        ServerEntry entry = null;
+        
         try
         {
-            root.createSubcontext( ServerDNConstants.LDIF_FILES_DN, entry );
-            LOG.info( "Creating " + ServerDNConstants.LDIF_FILES_DN );
+            entry = directoryService.getAdminSession().lookup( dn );
+        }
+        catch( Exception e )
+        {
+            LOG.error( "Failure while looking up " + ServerDNConstants.LDIF_FILES_DN, e );
         }
-        catch ( Exception e )
+
+        if ( entry == null )
         {
-            LOG.info( ServerDNConstants.LDIF_FILES_DN + " exists" );
+            entry = directoryService.newEntry( new LdapDN( ServerDNConstants.LDIF_FILES_DN ) );
+            entry.add( SchemaConstants.OU_AT, "loadedLdifFiles" );
+            entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC );
+    
+            directoryService.getAdminSession().add( entry );
         }
     }
 
@@ -284,51 +287,31 @@
      * 
      * It is associated with the attributeType wrt to the underlying system.
      */
-    private String buildProtectedFileEntry( File ldif )
+    private LdapDN buildProtectedFileEntryDn( File ldif ) throws Exception
     {
         String fileSep = File.separatorChar == '\\' ? 
                 ApacheSchemaConstants.WINDOWS_FILE_AT : 
                 ApacheSchemaConstants.UNIX_FILE_AT;
 
-        return  fileSep + 
+        return  new LdapDN( fileSep + 
                 "=" + 
                 StringTools.dumpHexPairs( StringTools.getBytesUtf8( getCanonical( ldif ) ) ) +
                 "," + 
-                ServerDNConstants.LDIF_FILES_DN; 
+                ServerDNConstants.LDIF_FILES_DN ); 
     }
 
     
-    private void addFileEntry( DirContext root, File ldif ) throws Exception
+    private void addFileEntry( File ldif ) throws Exception
     {
         String rdnAttr = File.separatorChar == '\\' ? 
             ApacheSchemaConstants.WINDOWS_FILE_AT : 
             ApacheSchemaConstants.UNIX_FILE_AT;
         String oc = File.separatorChar == '\\' ? ApacheSchemaConstants.WINDOWS_FILE_OC : ApacheSchemaConstants.UNIX_FILE_OC;
 
-        Attributes entry = new AttributesImpl( rdnAttr, getCanonical( ldif ), true );
-        entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC );
-        entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( oc );
-        root.createSubcontext( buildProtectedFileEntry( ldif ), entry );
-    }
-
-
-    /**
-     * 
-     * @param root
-     * @param ldif
-     * @return
-     */
-    private Attributes getLdifFileEntry( DirContext root, File ldif )
-    {
-        try
-        {
-            return root.getAttributes( buildProtectedFileEntry( ldif ), new String[]
-                { SchemaConstants.CREATE_TIMESTAMP_AT } );
-        }
-        catch ( Exception e )
-        {
-            return null;
-        }
+        ServerEntry entry = directoryService.newEntry( buildProtectedFileEntryDn( ldif ) );
+        entry.add( rdnAttr, getCanonical( ldif ) );
+        entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, oc );
+        directoryService.getAdminSession().add( entry );
     }
 
 
@@ -357,22 +340,24 @@
      * @param ldifFile The ldif file to read
      * @throws NamingException If something went wrong while loading the entries
      */
-    private void loadLdif( DirContext root, File ldifFile ) throws Exception
+    private void loadLdif( File ldifFile ) throws Exception
     {
-        Attributes fileEntry = getLdifFileEntry( root, ldifFile );
+        ServerEntry fileEntry = directoryService.getAdminSession().lookup( buildProtectedFileEntryDn( ldifFile ) );
 
         if ( fileEntry != null )
         {
-            String time = ( String ) fileEntry.get( SchemaConstants.CREATE_TIMESTAMP_AT ).get();
+            String time = fileEntry.get( SchemaConstants.CREATE_TIMESTAMP_AT ).getString();
             LOG.info( "Load of LDIF file '" + getCanonical( ldifFile )
                     + "' skipped.  It has already been loaded on " + time + "." );
         }
         else
         {
+            DirContext root = new ServerLdapContext( directoryService, 
+                directoryService.getAdminSession(), new LdapDN() );
             LdifFileLoader loader = new LdifFileLoader( root, ldifFile, ldifFilters );
             int count = loader.execute();
             LOG.info( "Loaded " + count + " entries from LDIF file '" + getCanonical( ldifFile ) + "'" );
-            addFileEntry( root, ldifFile );
+            addFileEntry( ldifFile );
         }
     }
     
@@ -404,11 +389,7 @@
         AttributeTypeRegistry reg = directoryService.getRegistries().getAttributeTypeRegistry();
         dn.normalize( reg.getNormalizerMapping() );
         
-        LdapPrincipal admin = new LdapPrincipal( dn, AuthenticationLevel.STRONG );
-        CoreSession session = directoryService.getSession( admin );
-        DirContext root = new ServerLdapContext( directoryService, session, new LdapDN() );
-
-        ensureLdifFileBase( root );
+        ensureLdifFileBase();
 
         // if ldif directory is a file try to load it
         if ( ldifDirectory.isFile() )
@@ -421,7 +402,7 @@
 
             try
             {
-                loadLdif( root, ldifDirectory );
+                loadLdif( ldifDirectory );
             }
             catch ( Exception ne )
             {
@@ -459,7 +440,7 @@
                 try
                 {
                     LOG.info(  "Loading LDIF file '{}'", ldifFile.getName() );
-                    loadLdif( root, ldifFile );
+                    loadLdif( ldifFile );
                 }
                 catch ( Exception ne )
                 {



Mime
View raw message