From 4a261fe8cd3300751284740534c91099604198f6 Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Mon, 30 Apr 2007 18:38:13 +0000
Subject: [PATCH] Fix for issue #1464: Getting errors exporting non-userRoot backend IDs. This change fixes export-ldif on the schema backend, but disables it for the config and monitor backends.

---
 opends/src/server/org/opends/server/backends/SchemaBackend.java |   82 ++++++++++++++++++++++++++++-------------
 1 files changed, 56 insertions(+), 26 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/SchemaBackend.java b/opends/src/server/org/opends/server/backends/SchemaBackend.java
index 102c583..4c6c56b 100644
--- a/opends/src/server/org/opends/server/backends/SchemaBackend.java
+++ b/opends/src/server/org/opends/server/backends/SchemaBackend.java
@@ -246,12 +246,19 @@
   }
 
 
-
   /**
-   * {@inheritDoc}
+   * Initialization shared by multiple backend methods.
+   * @param  configEntry  The configuration entry that contains the
+   *                      information to use to initialize this
+   *                      backend.
+   * @param  baseDNs      The set of base DNs that have been
+   *                      configured for this backend.
+   * @throws  ConfigException  If an unrecoverable problem arises in
+   *                           the process of performing the
+   *                           initialization.
    */
-  public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs)
-         throws ConfigException, InitializationException
+  private void initializeCommon(ConfigEntry configEntry, DN[] baseDNs)
+       throws ConfigException
   {
     // Make sure that a configuration entry was provided.  If not, then we will
     // not be able to complete initialization.
@@ -262,8 +269,8 @@
       throw new ConfigException(msgID, message);
     }
 
-    configEntryDN = configEntry.getDN();
     SchemaBackendCfg cfg = getSchemaBackendCfg(configEntry);
+    configEntryDN = configEntry.getDN();
 
     // Get all of the attribute types that we will use for schema elements.
     attributeTypesType =
@@ -295,6 +302,27 @@
     modifyTimestampType =
          DirectoryServer.getAttributeType(OP_ATTR_MODIFY_TIMESTAMP_LC, true);
 
+    // Construct the set of objectclasses to include in the schema entry.
+    schemaObjectClasses = new LinkedHashMap<ObjectClass,String>(3);
+    schemaObjectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+
+    ObjectClass subentryOC = DirectoryServer.getObjectClass(OC_LDAP_SUBENTRY_LC,
+                                                            true);
+    schemaObjectClasses.put(subentryOC, OC_LDAP_SUBENTRY);
+
+    ObjectClass subschemaOC = DirectoryServer.getObjectClass(OC_SUBSCHEMA,
+                                                             true);
+    schemaObjectClasses.put(subschemaOC, OC_SUBSCHEMA);
+
+
+    // Define empty sets for the supported controls and features.
+    supportedControls = new HashSet<String>(0);
+    supportedFeatures = new HashSet<String>(0);
+
+
+    configEntryDN = configEntry.getDN();
+    this.baseDNs = baseDNs;
+
     creatorsName  = new AttributeValue(creatorsNameType, baseDNs[0].toString());
     modifiersName =
          new AttributeValue(modifiersNameType, baseDNs[0].toString());
@@ -340,9 +368,20 @@
     showAllAttributes = cfg.isShowAllAttributes();
 
 
+    currentConfig = cfg;
+  }
+
+
+  /**
+   * {@inheritDoc}
+   */
+  public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs)
+         throws ConfigException, InitializationException
+  {
+    initializeCommon(configEntry, baseDNs);
+
     // Register each of the suffixes with the Directory Server.  Also, register
     // the first one as the schema base.
-    this.baseDNs = baseDNs;
     DirectoryServer.setSchemaDN(baseDNs[0]);
     for (int i=0; i < baseDNs.length; i++)
     {
@@ -365,24 +404,6 @@
     }
 
 
-    // Construct the set of objectclasses to include in the schema entry.
-    schemaObjectClasses = new LinkedHashMap<ObjectClass,String>(3);
-    schemaObjectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP);
-
-    ObjectClass subentryOC = DirectoryServer.getObjectClass(OC_LDAP_SUBENTRY_LC,
-                                                            true);
-    schemaObjectClasses.put(subentryOC, OC_LDAP_SUBENTRY);
-
-    ObjectClass subschemaOC = DirectoryServer.getObjectClass(OC_SUBSCHEMA,
-                                                             true);
-    schemaObjectClasses.put(subschemaOC, OC_SUBSCHEMA);
-
-
-    // Define an empty sets for the supported controls and features.
-    supportedControls = new HashSet<String>(0);
-    supportedFeatures = new HashSet<String>(0);
-
-
     // Identify any differences that may exist between the concatenated schema
     // file from the last online modification and the current schema files.  If
     // there are any differences, then they should be from making changes to the
@@ -494,8 +515,7 @@
 
 
     // Register with the Directory Server as a configurable component.
-    currentConfig = cfg;
-    cfg.addSchemaChangeListener(this);
+    currentConfig.addSchemaChangeListener(this);
   }
 
 
@@ -4134,6 +4154,16 @@
                          LDIFExportConfig exportConfig)
          throws DirectoryException
   {
+    try
+    {
+      initializeCommon(configEntry, baseDNs);
+    }
+    catch (ConfigException e)
+    {
+      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+                                   e.getMessage(), e.getMessageID());
+    }
+
     // Create the LDIF writer.
     LDIFWriter ldifWriter;
     try

--
Gitblit v1.10.0