From 9d0dd93d1e6751e7642a45f74dcad83ba7eb029e Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Mon, 07 Jun 2010 09:22:42 +0000
Subject: [PATCH] Fix an issue with the replication repair commands. The control was looked at after some checks it was supposed to skip. This prevented some entries to be repared. The changes are also updating the unit tests making sure the Replication Repair control is properly tested.

---
 opends/resource/schema/02-config.ldif                                                                            |    1 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationRepairControlTest.java |   82 ++++++++++++++++++++--------------------
 opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java                   |   19 +++++----
 3 files changed, 52 insertions(+), 50 deletions(-)

diff --git a/opends/resource/schema/02-config.ldif b/opends/resource/schema/02-config.ldif
index 2259683..6322ce2 100644
--- a/opends/resource/schema/02-config.ldif
+++ b/opends/resource/schema/02-config.ldif
@@ -594,6 +594,7 @@
   NAME 'ds-sync-hist'
   ORDERING historicalCsnOrderingMatch
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.40
+  NO-USER-MODIFICATION
   USAGE directoryOperation
   X-ORIGIN 'OpenDS Directory Server' )
 attributeTypes: ( 1.3.6.1.4.1.26027.1.1.120
diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
index de6a48f..60e5fc3 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -203,15 +203,6 @@
         break addProcessing;
       }
 
-      objectClasses = getObjectClasses();
-      userAttributes = getUserAttributes();
-      operationalAttributes = getOperationalAttributes();
-
-      if ((objectClasses == null ) || (userAttributes == null) ||
-          (operationalAttributes == null))
-      {
-        break addProcessing;
-      }
 
       // Check for a request to cancel this operation.
       checkIfCanceled(false);
@@ -304,6 +295,16 @@
           }
         }
 
+        objectClasses = getObjectClasses();
+        userAttributes = getUserAttributes();
+        operationalAttributes = getOperationalAttributes();
+
+        if ((objectClasses == null ) || (userAttributes == null) ||
+            (operationalAttributes == null))
+        {
+          break addProcessing;
+        }
+
         for (AttributeType at : userAttributes.keySet())
         {
           // If the attribute type is marked "NO-USER-MODIFICATION" then fail
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationRepairControlTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationRepairControlTest.java
index acab536..4bf0d9f 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationRepairControlTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationRepairControlTest.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2010 Sun Microsystems, Inc.
  */
 package org.opends.server.replication.plugin;
 
@@ -40,23 +40,23 @@
          throws Exception
   {
     TestCaseUtils.initializeTestBackend(true);
-    
+
     // Test that we can't add an entry with the entryuuid attribute
-    // without specifying the replication repair control. 
+    // without specifying the replication repair control.
     String path = TestCaseUtils.createTempFile(
         "dn: uid=test.repair," + TEST_ROOT_DN_STRING + "\n" +
         "changetype: add\n" +
         "objectClass: top\n" +
-        "objectClass: person" +
-        "objectClass: organizationalPerson" +
-        "objectClass: inetOrgPerson" +
-        "uid: test.repair" +
-        "givenName: Test" +
-        "sn: User" +
-        "cn: Test User" +
-        "userPassword: password" +
-        "entryuuid: d5b910d8-47cb-4ac0-9e5f-0f4a77de58d4");
-    
+        "objectClass: person\n" +
+        "objectClass: organizationalPerson\n" +
+        "objectClass: inetOrgPerson\n" +
+        "uid: test.repair\n" +
+        "givenName: Test\n" +
+        "sn: User\n" +
+        "cn: Test User\n" +
+        "userPassword: password\n" +
+        "entryuuid: d5b910d8-47cb-4ac0-9e5f-0f4a77de58d4\n");
+
     String[] args =
     {
       "-h", "127.0.0.1",
@@ -66,25 +66,25 @@
       "-a",
       "-f", path
     };
-    
-    assertEquals(LDAPModify.mainModify(args, false, null, null), 65);
-    
+
+    assertEquals(LDAPModify.mainModify(args, false, null, null), 53);
+
     // Test that we can't add an entry with the ds-sync-hist attribute
-    // without specifying the replication repair control. 
+    // without specifying the replication repair control.
     String path1 = TestCaseUtils.createTempFile(
         "dn: uid=test.repair," + TEST_ROOT_DN_STRING + "\n" +
         "changetype: add\n" +
         "objectClass: top\n" +
-        "objectClass: person" +
-        "objectClass: organizationalPerson" +
-        "objectClass: inetOrgPerson" +
-        "uid: test.repair" +
-        "givenName: Test" +
-        "sn: User" +
-        "cn: Test User" +
-        "userPassword: password" +
-        "ds-sync-hist: description:00000108b3a6cbb800000001:del:deleted_value");
-    
+        "objectClass: person\n" +
+        "objectClass: organizationalPerson\n" +
+        "objectClass: inetOrgPerson\n" +
+        "uid: test.repair\n" +
+        "givenName: Test\n" +
+        "sn: User\n" +
+        "cn: Test User\n" +
+        "userPassword: password\n" +
+        "ds-sync-hist: description:00000108b3a6cbb800000001:del:deleted_value\n");
+
     String[] args1 =
     {
       "-h", "127.0.0.1",
@@ -96,8 +96,8 @@
     };
 
 
-    assertEquals(LDAPModify.mainModify(args1, false, null, null), 65);
-    
+    assertEquals(LDAPModify.mainModify(args1, false, null, null), 53);
+
     // Now Test specifying the replication repair control makes
     // possible to add an entry with the entryuuid and ds-sync-hist attributes
     // (notice the -J repairControlOid in the ldapmodify arguments)
@@ -106,27 +106,27 @@
         "changetype: add\n" +
         "objectClass: top\n" +
         "objectClass: person" +
-        "objectClass: organizationalPerson" +
-        "objectClass: inetOrgPerson" +
-        "uid: test.repair" +
-        "givenName: Test" +
-        "sn: User" +
-        "cn: Test User" +
-        "userPassword: password" +
-        "ds-sync-hist: description:00000108b3a6cbb800000001:del:deleted_value" +
-        "entryuuid: d5b910d8-47cb-4ac0-9e5f-0f4a77de58d4");
-    
+        "objectClass: organizationalPerson\n" +
+        "objectClass: inetOrgPerson\n" +
+        "uid: test.repair\n" +
+        "givenName: Test\n" +
+        "sn: User\n" +
+        "cn: Test User\n" +
+        "userPassword: password\n" +
+        "ds-sync-hist: description:00000108b3a6cbb800000001:del:deleted_value\n" +
+        "entryuuid: d5b910d8-47cb-4ac0-9e5f-0f4a77de58d4\n");
+
     String[] args2 =
     {
       "-h", "127.0.0.1",
       "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
       "-D", "cn=Directory Manager",
       "-w", "password",
-      "-J", "1.3.6.1.4.1.26027.1.5.2", 
+      "-J", "1.3.6.1.4.1.26027.1.5.2",
       "-a",
       "-f", path2
     };
 
     assertEquals(LDAPModify.mainModify(args2, false, null, null), 0);
-  }  
+  }
 }

--
Gitblit v1.10.0