From b117ed336a8744e6b2b7a8a531743ba58178d8a0 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 27 Nov 2013 10:50:45 +0000
Subject: [PATCH] Factor out duplicate code and fix cut n paste bug in LocalBackendModifyOperation which was preventing sync operations from bypassing backend INTERNAL_ONLY mode.

---
 opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java |   53 ++---------------------------------------------------
 1 files changed, 2 insertions(+), 51 deletions(-)

diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
index 037df6e..e63a8b4 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -582,7 +582,8 @@
         return;
       }
 
-      checkWritability();
+      LocalBackendWorkflowElement.checkIfBackendIsWritable(backend, this,
+          entryDN, ERR_MODIFY_SERVER_READONLY, ERR_MODIFY_BACKEND_READONLY);
 
       if (noOp)
       {
@@ -1994,56 +1995,6 @@
 
 
   /**
-   * Checks to ensure that both the Directory Server and the backend are
-   * writable.
-   *
-   * @throws  DirectoryException  If the modify operation should not be allowed
-   *                              as a result of the writability check.
-   */
-  protected void checkWritability()
-          throws DirectoryException
-  {
-    // If it is not a private backend, then check to see if the server or
-    // backend is operating in read-only mode.
-    if (! backend.isPrivateBackend())
-    {
-      switch (DirectoryServer.getWritabilityMode())
-      {
-        case DISABLED:
-          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
-                                       ERR_MODIFY_SERVER_READONLY.get(
-                                            String.valueOf(entryDN)));
-
-        case INTERNAL_ONLY:
-          if (! (isInternalOperation() || isSynchronizationOperation()))
-          {
-            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
-                                         ERR_MODIFY_SERVER_READONLY.get(
-                                              String.valueOf(entryDN)));
-          }
-      }
-
-      switch (backend.getWritabilityMode())
-      {
-        case DISABLED:
-          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
-                                       ERR_MODIFY_BACKEND_READONLY.get(
-                                            String.valueOf(entryDN)));
-
-        case INTERNAL_ONLY:
-          if (! isInternalOperation() || isSynchronizationOperation())
-          {
-            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
-                                         ERR_MODIFY_BACKEND_READONLY.get(
-                                              String.valueOf(entryDN)));
-          }
-      }
-    }
-  }
-
-
-
-  /**
    * Handles any account status notifications that may be needed as a result of
    * modify processing.
    */

--
Gitblit v1.10.0