From 165fc0b3f173bd3af50e73679f07c447972ad14c Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Thu, 31 Jul 2014 10:07:47 +0000
Subject: [PATCH] Forward port fix OPENDJ-452: Manual add of new schema objectclass in 99-user.ldif are not replicated

---
 opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java  |   30 ++++++++++++++++++++++--------
 opendj3-server-dev/src/server/org/opends/server/replication/plugin/MultimasterReplication.java |    2 +-
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index cc581d0..57e546b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -3796,23 +3796,37 @@
 
 
   /**
-   * Push the modifications contained in the given parameter as 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 CSN is
-   * generated and the ServerState associated to this domain is updated.
+   * Push the schema modifications contained in the given parameter as a
+   * modification that would happen on a local server. The modifications are not
+   * applied to the local schema backend and historical information is not
+   * updated; but a CSN is generated and the ServerState associated to the
+   * schema domain is updated.
    *
    * @param modifications
-   *          The modification to push
+   *          The schema modifications to push
    */
-  void synchronizeModifications(List<Modification> modifications)
+  void synchronizeSchemaModifications(List<Modification> modifications)
   {
     ModifyOperation op = new ModifyOperationBasis(
         conn, nextOperationID(), nextMessageID(), null,
         DirectoryServer.getSchemaDN(), modifications);
-    LocalBackendModifyOperation localOp = new LocalBackendModifyOperation(op);
 
+    final Entry schema;
+    try
+    {
+      schema = DirectoryServer.getEntry(DirectoryServer.getSchemaDN());
+    }
+    catch (DirectoryException e)
+    {
+      logger.traceException(e);
+      logger.error(ERR_BACKEND_SEARCH_ENTRY.get(DirectoryServer.getSchemaDN().toString(),
+              stackTraceToSingleLineString(e)));
+      return;
+    }
+
+    LocalBackendModifyOperation localOp = new LocalBackendModifyOperation(op);
     CSN csn = generateCSN(localOp);
-    OperationContext ctx = new ModifyContext(csn, "schema");
+    OperationContext ctx = new ModifyContext(csn, getEntryUUID(schema));
     localOp.setAttachment(SYNCHROCONTEXT, ctx);
     localOp.setResultCode(ResultCode.SUCCESS);
     synchronize(localOp);
diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/MultimasterReplication.java b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/MultimasterReplication.java
index d3eb610..8317c8b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/MultimasterReplication.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/MultimasterReplication.java
@@ -597,7 +597,7 @@
     LDAPReplicationDomain domain = findDomain(DirectoryServer.getSchemaDN(), null);
     if (domain != null)
     {
-      domain.synchronizeModifications(modifications);
+      domain.synchronizeSchemaModifications(modifications);
     }
   }
 

--
Gitblit v1.10.0