From 5c47ab553c1fa329dbad90f5ecfd98b84e518cac Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Mon, 26 Mar 2007 07:17:13 +0000
Subject: [PATCH] This commit allows to complete issues 504, 505 and 507 by using the new import/export/backup/restore interface to get notifications of import and restore and then resynchronize the server approprietely.

---
 opendj-sdk/opends/src/server/org/opends/server/tasks/ImportTask.java |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/tasks/ImportTask.java b/opendj-sdk/opends/src/server/org/opends/server/tasks/ImportTask.java
index 688c4e8..826ac4f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tasks/ImportTask.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tasks/ImportTask.java
@@ -32,7 +32,6 @@
 import static org.opends.server.loggers.debug.DebugLogger.debugCaught;
 import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
 import org.opends.server.types.DebugLogLevel;
-import static org.opends.server.loggers.Error.logError;
 import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString;
 import static org.opends.server.config.ConfigConstants.*;
 import static org.opends.server.core.DirectoryServer.getAttributeType;
@@ -473,6 +472,11 @@
     DN[] baseDNs = new DN[defaultIncludeBranches.size()];
     defaultIncludeBranches.toArray(baseDNs);
 
+    // Notify the task listeners that an import is going to start
+    // this must be done before disabling the backend to allow
+    // listeners to get access to the backend configuration
+    // and to take appropriate actions.
+    DirectoryServer.notifyImportBeginning(backend, importConfig);
 
     // Disable the backend.
     try
@@ -528,9 +532,7 @@
       // Launch the import.
       try
       {
-        DirectoryServer.notifyImportBeginning(backend, importConfig);
         backend.importLDIF(configEntry, baseDNs, importConfig);
-        DirectoryServer.notifyImportEnded(backend, importConfig, true);
       }
       catch (DirectoryException de)
       {
@@ -600,6 +602,10 @@
       try
       {
         TaskUtils.setBackendEnabled(configEntry, true);
+        // It is necessary to retrieve the backend structure again
+        // because disabling and enabling it again may have resulted
+        // in a new backend being registered to the server.
+        backend = DirectoryServer.getBackend(backendID);
       }
       catch (DirectoryException e)
       {
@@ -612,6 +618,7 @@
                  e.getErrorMessage(), e.getErrorMessageID());
         return TaskState.STOPPED_BY_ERROR;
       }
+      DirectoryServer.notifyImportEnded(backend, importConfig, true);
     }
 
 

--
Gitblit v1.10.0