From 8aaa16f43f88550cbe7a8a2ddad12a917e845488 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 05 Jul 2007 05:56:48 +0000
Subject: [PATCH] Update the server processing for the LDAP no-op control so that it uses a nonzero result code.  For now, we're using a result code of 16654 (0x410e, which is what OpenLDAP uses).  If a new specification is released with an official OID and result code, then we'll use them.

---
 opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java               |    3 
 opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPDeleteTestCase.java         |    7 +
 opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java |   23 +++++--
 opends/src/server/org/opends/server/types/ResultCode.java                                         |   16 +++++
 opends/src/server/org/opends/server/core/ModifyDNOperation.java                                   |    8 ++
 opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPPasswordModifyTestCase.java |   12 +--
 opends/src/server/org/opends/server/protocols/ldap/LDAPResultCode.java                            |   18 ++++++
 opends/src/server/org/opends/server/messages/CoreMessages.java                                    |   30 +++------
 opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPModifyTestCase.java         |   25 +++++--
 9 files changed, 95 insertions(+), 47 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/ModifyDNOperation.java b/opends/src/server/org/opends/server/core/ModifyDNOperation.java
index 9c01614..979f3ac 100644
--- a/opends/src/server/org/opends/server/core/ModifyDNOperation.java
+++ b/opends/src/server/org/opends/server/core/ModifyDNOperation.java
@@ -1819,7 +1819,7 @@
           {
             appendErrorMessage(getMessage(MSGID_MODDN_NOOP));
 
-            // FIXME -- We must set a result code other than SUCCESS.
+            setResultCode(ResultCode.NO_OPERATION);
           }
           else
           {
@@ -1957,7 +1957,11 @@
             responseControls.add(responseControl);
           }
 
-          setResultCode(ResultCode.SUCCESS);
+
+          if (! noOp)
+          {
+            setResultCode(ResultCode.SUCCESS);
+          }
         }
         catch (DirectoryException de)
         {
diff --git a/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java b/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
index 70fe7ef..6a290af 100644
--- a/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
+++ b/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
@@ -1108,8 +1108,7 @@
       {
         operation.appendErrorMessage(getMessage(MSGID_EXTOP_PASSMOD_NOOP));
 
-        // FIXME -- We must set a result code other than SUCCESS.
-        operation.setResultCode(ResultCode.SUCCESS);
+        operation.setResultCode(ResultCode.NO_OPERATION);
       }
       else
       {
diff --git a/opends/src/server/org/opends/server/messages/CoreMessages.java b/opends/src/server/org/opends/server/messages/CoreMessages.java
index b6e7111..48da4b4 100644
--- a/opends/src/server/org/opends/server/messages/CoreMessages.java
+++ b/opends/src/server/org/opends/server/messages/CoreMessages.java
@@ -6169,16 +6169,6 @@
        CATEGORY_MASK_CORE | SEVERITY_MASK_NOTICE | 619;
 
 
-  /**
-   * The message ID for the message that will be used if a workflow is
-   * configured with no root workflow element. No root workflow element
-   * means no processing on the DIT attached to the workflow, which makes
-   * no sense.
-   */
-  public static final int MSGID_WARNING_ROOT_WORKFLOW_ELEMENT_NOT_DEFINED =
-    CATEGORY_MASK_CORE | SEVERITY_MASK_SEVERE_WARNING | 620;
-
-
 
   /**
    * The message ID for the message that will be used if an attribute used an
@@ -6222,6 +6212,16 @@
 
 
   /**
+   * The message ID for the string representation of the result code that will
+   * be used to indicate no action was taken as a result of the LDAP no-op
+   * control.  This does not take any arguments.
+   */
+  public static final int MSGID_RESULT_NO_OPERATION =
+       CATEGORY_MASK_CORE | SEVERITY_MASK_INFORMATIONAL | 624;
+
+
+
+  /**
    * Associates a set of generic messages with the message IDs defined
    * in this class.
    */
@@ -6390,6 +6390,7 @@
     registerMessage(MSGID_RESULT_CANNOT_CANCEL, "Cannot Cancel");
     registerMessage(MSGID_RESULT_ASSERTION_FAILED, "Assertion Failed");
     registerMessage(MSGID_RESULT_AUTHORIZATION_DENIED, "Authorization Denied");
+    registerMessage(MSGID_RESULT_NO_OPERATION, "No Operation");
 
 
     registerMessage(MSGID_UNKNOWN_ATTRIBUTE_USAGE,
@@ -8453,11 +8454,6 @@
                     "The Directory Server is leaving lockdown mode and will " +
                     "resume normal operation");
 
-    registerMessage(MSGID_WARNING_ROOT_WORKFLOW_ELEMENT_NOT_DEFINED,
-        "The workflow with base DN \"%s\" has no root workflow " +
-        "element"
-        );
-
 
     registerMessage(MSGID_COMPRESSEDSCHEMA_UNRECOGNIZED_AD_TOKEN,
                     "Unable to decode the provided attribute because it " +
@@ -8473,10 +8469,6 @@
     registerMessage(MSGID_ENTRYENCODECFG_INVALID_LENGTH,
                     "Unable to decode the provided entry encode " +
                     "configuration element because it has an invalid length");
-
-    registerMessage(MSGID_WARNING_ROOT_WORKFLOW_ELEMENT_NOT_DEFINED,
-                    "The workflow with base DN \"%s\" has no root workflow " +
-                    "element");
   }
 }
 
diff --git a/opends/src/server/org/opends/server/protocols/ldap/LDAPResultCode.java b/opends/src/server/org/opends/server/protocols/ldap/LDAPResultCode.java
index 114cb18..3e9552c 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/LDAPResultCode.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/LDAPResultCode.java
@@ -582,6 +582,21 @@
 
 
   /**
+   * The LDAP result code for operations in which no action is taken because the
+   * request include the LDAP no-op control.
+   *
+   * FIXME -- This is a temporary result code for use until
+   *          draft-zeilenga-ldap-noop is updated and an official result code is
+   *          allocated for it.  In the meantime, this result appears to be the
+   *          one used by OpenLDAP as per the message at
+   *          http://www.openldap.org/lists/openldap-devel/200601/msg00143.html
+   *          (0x410e = 16654).
+   */
+  public static final int NO_OPERATION = 16654;
+
+
+
+  /**
    * Retrieves a string representation of the provided LDAP result code.
    *
    * @param  resultCode  The LDAP result code value for which to obtain the
@@ -787,6 +802,9 @@
       case AUTHORIZATION_DENIED:
         msgID = MSGID_RESULT_AUTHORIZATION_DENIED;
         break;
+      case NO_OPERATION:
+        msgID = MSGID_RESULT_NO_OPERATION;
+        break;
       default:
         msgID = MSGID_RESULT_OTHER;
         break;
diff --git a/opends/src/server/org/opends/server/types/ResultCode.java b/opends/src/server/org/opends/server/types/ResultCode.java
index e5b60c6..7d6b01a 100644
--- a/opends/src/server/org/opends/server/types/ResultCode.java
+++ b/opends/src/server/org/opends/server/types/ResultCode.java
@@ -667,7 +667,17 @@
    * the client to use the requested authorization.
    */
   AUTHORIZATION_DENIED(LDAPResultCode.AUTHORIZATION_DENIED,
-                       MSGID_RESULT_AUTHORIZATION_DENIED);
+                       MSGID_RESULT_AUTHORIZATION_DENIED),
+
+
+
+  /**
+   * The result code that should be used if the server did not
+   * actually complete processing on the associated operation because
+   * the request included the LDAP No-Op control.
+   */
+  NO_OPERATION(LDAPResultCode.NO_OPERATION,
+               MSGID_RESULT_NO_OPERATION);
 
 
 
@@ -855,6 +865,10 @@
         return ASSERTION_FAILED;
       case LDAPResultCode.AUTHORIZATION_DENIED:
         return AUTHORIZATION_DENIED;
+      case LDAPResultCode.NO_OPERATION:
+        // FIXME -- We will also need to handle the official result
+        //          code when it is allocated.
+        return NO_OPERATION;
       default:
         return ResultCode.OTHER;
     }
diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
index 1fe984b..3fd4599 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
@@ -2067,7 +2067,7 @@
           {
             localOp.appendErrorMessage(getMessage(MSGID_MODIFY_NOOP));
 
-            // FIXME -- We must set a result code other than SUCCESS.
+            localOp.setResultCode(ResultCode.NO_OPERATION);
           }
           else
           {
@@ -2267,7 +2267,10 @@
             localOp.getResponseControls().add(responseControl);
           }
 
-          localOp.setResultCode(ResultCode.SUCCESS);
+          if (! noOp)
+          {
+            localOp.setResultCode(ResultCode.SUCCESS);
+          }
         }
         catch (DirectoryException de)
         {
@@ -5563,7 +5566,7 @@
             {
               localOp.appendErrorMessage(getMessage(MSGID_ADD_NOOP));
 
-              // FIXME -- We must set a result code other than SUCCESS.
+              localOp.setResultCode(ResultCode.NO_OPERATION);
             }
             else
             {
@@ -5652,7 +5655,11 @@
               localOp.addResponseControl(responseControl);
             }
 
-            localOp.setResultCode(ResultCode.SUCCESS);
+
+            if (! noOp)
+            {
+              localOp.setResultCode(ResultCode.SUCCESS);
+            }
           }
           catch (DirectoryException de)
           {
@@ -6387,7 +6394,7 @@
           {
             localOp.appendErrorMessage(getMessage(MSGID_DELETE_NOOP));
 
-            // FIXME -- We must set a result code other than SUCCESS.
+            localOp.setResultCode(ResultCode.NO_OPERATION);
           }
           else
           {
@@ -6476,7 +6483,11 @@
             localOp.addResponseControl(responseControl);
           }
 
-          localOp.setResultCode(ResultCode.SUCCESS);
+
+          if (! noOp)
+          {
+            localOp.setResultCode(ResultCode.SUCCESS);
+          }
         }
         catch (DirectoryException de)
         {
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPDeleteTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPDeleteTestCase.java
index 0e142a3..c4369fb 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPDeleteTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPDeleteTestCase.java
@@ -40,6 +40,7 @@
 import org.opends.server.core.AddOperation;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
+import org.opends.server.protocols.ldap.LDAPResultCode;
 import org.opends.server.types.Entry;
 import org.opends.server.types.OperatingSystem;
 import org.opends.server.types.ResultCode;
@@ -890,7 +891,8 @@
       "o=test"
     };
 
-    assertEquals(LDAPDelete.mainDelete(args, false, null, System.err), 0);
+    assertEquals(LDAPDelete.mainDelete(args, false, null, System.err),
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
@@ -917,7 +919,8 @@
       "o=test"
     };
 
-    assertEquals(LDAPDelete.mainDelete(args, false, null, System.err), 0);
+    assertEquals(LDAPDelete.mainDelete(args, false, null, System.err),
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPModifyTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPModifyTestCase.java
index 9ccb68d..94368c0 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPModifyTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPModifyTestCase.java
@@ -40,6 +40,7 @@
 import org.opends.server.core.AddOperation;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
+import org.opends.server.protocols.ldap.LDAPResultCode;
 import org.opends.server.types.Entry;
 import org.opends.server.types.ResultCode;
 
@@ -988,7 +989,8 @@
       "-f", modifyFilePath
     };
 
-    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+    assertEquals(LDAPModify.mainModify(args, false, null, System.err),
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
@@ -1015,7 +1017,8 @@
       "-f", modifyFilePath
     };
 
-    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+    assertEquals(LDAPModify.mainModify(args, false, null, System.err),
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
@@ -1048,7 +1051,8 @@
       "-f", path
     };
 
-    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+    assertEquals(LDAPModify.mainModify(args, false, null, System.err),
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
@@ -1082,7 +1086,8 @@
       "-f", path
     };
 
-    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+    assertEquals(LDAPModify.mainModify(args, false, null, System.err),
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
@@ -1112,7 +1117,8 @@
       "-f", path
     };
 
-    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+    assertEquals(LDAPModify.mainModify(args, false, null, System.err),
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
@@ -1143,7 +1149,8 @@
       "-f", path
     };
 
-    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+    assertEquals(LDAPModify.mainModify(args, false, null, System.err),
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
@@ -1188,7 +1195,8 @@
       "-f", path
     };
 
-    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+    assertEquals(LDAPModify.mainModify(args, false, null, System.err),
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
@@ -1234,7 +1242,8 @@
       "-f", path
     };
 
-    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+    assertEquals(LDAPModify.mainModify(args, false, null, System.err),
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPPasswordModifyTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPPasswordModifyTestCase.java
index 9bc8f03..bc84b18 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPPasswordModifyTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPPasswordModifyTestCase.java
@@ -40,6 +40,7 @@
 import org.opends.server.core.AddOperation;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
+import org.opends.server.protocols.ldap.LDAPResultCode;
 import org.opends.server.types.Entry;
 import org.opends.server.types.ResultCode;
 
@@ -974,7 +975,7 @@
    * @throws  Exception  If an unexpected problem occurs.
    */
   @Test()
-  public void testLDAPNoOpUnsupportedCriticalControl()
+  public void testUnsupportedCriticalControl()
          throws Exception
   {
     TestCaseUtils.initializeTestBackend(true);
@@ -1023,9 +1024,8 @@
       "-J", OID_LDAP_NOOP_OPENLDAP_ASSIGNED + ":true"
     };
 
-    // FIXME -- Change this whenever the real LDAP No-Op result code is assigned
     assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null),
-                 0);
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
@@ -1055,9 +1055,8 @@
       "-J", "noop:true"
     };
 
-    // FIXME -- Change this whenever the real LDAP No-Op result code is assigned
     assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null),
-                 0);
+                 LDAPResultCode.NO_OPERATION);
   }
 
 
@@ -1088,9 +1087,8 @@
       "-J", OID_PASSWORD_POLICY_CONTROL + ":true"
     };
 
-    // FIXME -- Change this whenever the real LDAP No-Op result code is assigned
     assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null),
-                 0);
+                 LDAPResultCode.NO_OPERATION);
   }
 
 

--
Gitblit v1.10.0