From db8ccd3607a951d74b373afc6ca63b3b18554ab1 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Thu, 08 Mar 2007 08:50:49 +0000
Subject: [PATCH] Issue 613 : Add the capability to deal with schema changes made be editing the schema files : The core server provides a notification to the synchronization. The synchronization generates a pseudo changes and propagate it to the other LDAP servers through the synchronization servers.

---
 opends/src/server/org/opends/server/synchronization/plugin/SynchronizationDomain.java |   45 +++++++++++++++++++++++++++++++++------------
 1 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/opends/src/server/org/opends/server/synchronization/plugin/SynchronizationDomain.java b/opends/src/server/org/opends/server/synchronization/plugin/SynchronizationDomain.java
index 7a4f620..11880b9 100644
--- a/opends/src/server/org/opends/server/synchronization/plugin/SynchronizationDomain.java
+++ b/opends/src/server/org/opends/server/synchronization/plugin/SynchronizationDomain.java
@@ -90,6 +90,7 @@
 import org.opends.server.types.Entry;
 import org.opends.server.types.ErrorLogCategory;
 import org.opends.server.types.ErrorLogSeverity;
+import org.opends.server.types.Modification;
 import org.opends.server.types.RDN;
 import org.opends.server.types.ResultCode;
 import org.opends.server.types.SearchFilter;
@@ -259,25 +260,19 @@
     configAttributes.add(baseDn);
 
     /*
-     * Modify conflicts are solved for all suffixes but the cn=schema suffix
+     * Modify conflicts are solved for all suffixes but the schema suffix
      * because we don't want to store extra information in the schema
      * ldif files.
      * This has no negative impact because the changes on schema should
      * not produce conflicts.
      */
-    try
+    if (baseDN.compareTo(DirectoryServer.getSchemaDN()) == 0)
     {
-      if (baseDN.compareTo(DN.decode("cn=schema")) == 0)
-      {
-        solveConflictFlag = false;
-      }
-      else
-      {
-        solveConflictFlag = true;
-      }
-    } catch (DirectoryException e1)
+      solveConflictFlag = false;
+    }
+    else
     {
-      // never happens because "cn=schema" is a valid DN
+      solveConflictFlag = true;
     }
 
     state = new PersistentServerState(baseDN);
@@ -1933,4 +1928,30 @@
   {
     // Nothing is needed at the moment
   }
+
+  /**
+   * Push the modifications contain the in given parameter has
+   * a modification that would happen on a local server.
+   * The modifications are not applied to the local database,
+   * historical information is not updated but a ChangeNumber
+   * is generated and the ServerState associated to this domain is
+   * updated.
+   * @param modifications The modification to push
+   */
+  public void synchronizeModifications(List<Modification> modifications)
+  {
+    Operation op =
+      new ModifyOperation(InternalClientConnection.getRootConnection(),
+                          InternalClientConnection.nextOperationID(),
+                          InternalClientConnection.nextMessageID(),
+                          null, DirectoryServer.getSchemaDN(),
+                          modifications);
+
+    ChangeNumber cn = generateChangeNumber(op);
+    System.out.println("cn is " + cn);
+    OperationContext ctx = new ModifyContext(cn, "schema");
+    op.setAttachment(SYNCHROCONTEXT, ctx);
+    op.setResultCode(ResultCode.SUCCESS);
+    synchronize(op);
+  }
 }

--
Gitblit v1.10.0