From 5630d1d870315aa2467a96cd866e996164a2d598 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 10 Jul 2007 17:50:04 +0000
Subject: [PATCH] Update the configuration for the Berkeley DB JE backend to ensure that it will require a valid value for the database logging level.

---
 opends/src/server/org/opends/server/messages/JebMessages.java     |   14 ++++++++++++++
 opends/src/server/org/opends/server/backends/jeb/BackendImpl.java |   39 ++++++++++++++++++++++++++++++++++-----
 2 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java b/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
index 69a15e5..b5e2aad 100644
--- a/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
+++ b/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -56,8 +56,7 @@
 import org.opends.server.core.SearchOperation;
 import org.opends.server.util.LDIFException;
 import org.opends.server.util.Validator;
-import org.opends.server.util.StaticUtils;
-import static org.opends.server.util.StaticUtils.getFileForPath;
+import static org.opends.server.util.StaticUtils.*;
 
 import static org.opends.server.messages.BackendMessages.*;
 import static org.opends.server.messages.MessageHandler.getMessage;
@@ -1391,12 +1390,42 @@
   /**
    * {@inheritDoc}
    */
+  @Override()
+  public boolean isConfigurationAcceptable(Configuration configuration,
+                                           List<String> unacceptableReasons)
+  {
+    JEBackendCfg config = (JEBackendCfg) configuration;
+    return isConfigurationChangeAcceptable(config, unacceptableReasons);
+  }
+
+
+
+  /**
+   * {@inheritDoc}
+   */
   public boolean isConfigurationChangeAcceptable(
       JEBackendCfg cfg,
       List<String> unacceptableReasons)
   {
-    // This listener handles only the changes to the base DNs.
-    // The base DNs are checked by the backend config manager.
+    // Make sure that the logging level value is acceptable.
+    String loggingLevel = cfg.getDatabaseLoggingLevel();
+    if (! (loggingLevel.equals("OFF") ||
+           loggingLevel.equals("SEVERE") ||
+           loggingLevel.equals("WARNING") ||
+           loggingLevel.equals("INFO") ||
+           loggingLevel.equals("CONFIG") ||
+           loggingLevel.equals("FINE") ||
+           loggingLevel.equals("FINER") ||
+           loggingLevel.equals("FINEST") ||
+           loggingLevel.equals("OFF")))
+    {
+      int    msgID   = MSGID_JEB_INVALID_LOGGING_LEVEL;
+      String message = getMessage(msgID,
+                                  String.valueOf(cfg.getDatabaseLoggingLevel()),
+                                  String.valueOf(cfg.dn()));
+      unacceptableReasons.add(message);
+      return false;
+    }
 
     return true;
   }
@@ -1472,7 +1501,7 @@
     }
     catch (Exception e)
     {
-      messages.add(StaticUtils.stackTraceToSingleLineString(e));
+      messages.add(stackTraceToSingleLineString(e));
       ccr = new ConfigChangeResult(DirectoryServer.getServerErrorResultCode(),
                                    false, messages);
       return ccr;
diff --git a/opends/src/server/org/opends/server/messages/JebMessages.java b/opends/src/server/org/opends/server/messages/JebMessages.java
index 1737345..1e5b8fc 100644
--- a/opends/src/server/org/opends/server/messages/JebMessages.java
+++ b/opends/src/server/org/opends/server/messages/JebMessages.java
@@ -1207,6 +1207,14 @@
   public static final int MSGID_JEB_IMPORT_CREATE_TMPDIR_ERROR =
       CATEGORY_MASK_JEB | SEVERITY_MASK_SEVERE_ERROR | 155;
 
+  /**
+   * The message ID of the message that will be used if an invalid logging level
+   * was requested.  This takes two arguments, which are the invalid logging
+   * level and the configuration entry DN.
+   */
+  public static final int MSGID_JEB_INVALID_LOGGING_LEVEL =
+       CATEGORY_MASK_JEB | SEVERITY_MASK_SEVERE_ERROR | 156;
+
 
   /**
    * Associates a set of generic messages with the message IDs defined in this
@@ -1244,6 +1252,12 @@
                     "for ID %s");
     registerMessage(MSGID_JEB_DATABASE_EXCEPTION,
                     "Database exception: %s");
+    registerMessage(MSGID_JEB_INVALID_LOGGING_LEVEL,
+                    "The database logging level string '%s' provided for " +
+                    "configuration entry '%s' is invalid.  The value must " +
+                    "be one of OFF, SEVERE, WARNING, INFO, CONFIG, FINE, " +
+                    "FINER, FINEST, or ALL.  Note that these values are " +
+                    "case sensitive");
     registerMessage(MSGID_CONFIG_DESCRIPTION_INDEX_ATTRIBUTE,
                     "The attribute type name of the attribute index");
     registerMessage(MSGID_CONFIG_DESCRIPTION_INDEX_TYPE,

--
Gitblit v1.10.0