From 959c9ded0c297d00500678a0c80d7d6d8a5265fe Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 10 Jul 2007 16:03:42 +0000
Subject: [PATCH] Fix a set of problems with the configuration interface in which there were a number of cases in which insufficient validation was performed.  In particular, if a new configuration object was added over protocol or an existing configuration object was changed from disabled to enabled, then the server would only perform generic validation for that component and would not have any way to perform more detailed validation that could detect larger numbers of problems.

---
 opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java |   70 +++++++++++++++++++++-------------
 1 files changed, 43 insertions(+), 27 deletions(-)

diff --git a/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java b/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
index 4532629..637b741 100644
--- a/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
+++ b/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
@@ -35,6 +35,7 @@
 import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString;
 import static org.opends.server.util.StaticUtils.getFileForPath;
 import static org.opends.server.util.ServerConstants.PROPERTY_DEBUG_TARGET;
+import org.opends.server.admin.std.server.DebugLogPublisherCfg;
 import org.opends.server.admin.std.server.DebugTargetCfg;
 import org.opends.server.admin.std.server.FileBasedDebugLogPublisherCfg;
 import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn;
@@ -250,6 +251,47 @@
     config.addFileBasedDebugChangeListener(this);
   }
 
+
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override()
+  public boolean isConfigurationAcceptable(DebugLogPublisherCfg configuration,
+                                           List<String> unacceptableReasons)
+  {
+    FileBasedDebugLogPublisherCfg config =
+         (FileBasedDebugLogPublisherCfg) configuration;
+
+    // Validate retention and rotation policies.
+    for(DN dn : config.getRotationPolicyDN())
+    {
+      RotationPolicy policy = DirectoryServer.getRotationPolicy(dn);
+      if(policy == null)
+      {
+        int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY;
+        String message = getMessage(msgID, dn.toString(),
+                                    config.dn().toString());
+        unacceptableReasons.add(message);
+        return false;
+      }
+    }
+    for(DN dn: config.getRetentionPolicyDN())
+    {
+      RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn);
+      if(policy != null)
+      {
+        int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY;
+        String message = getMessage(msgID, dn.toString(),
+                                    config.dn().toString());
+        unacceptableReasons.add(message);
+        return false;
+      }
+    }
+
+    return true;
+  }
+
   /**
    * {@inheritDoc}
    */
@@ -282,33 +324,7 @@
       return false;
     }
 
-    // Validate retention and rotation policies.
-    for(DN dn : config.getRotationPolicyDN())
-    {
-      RotationPolicy policy = DirectoryServer.getRotationPolicy(dn);
-      if(policy == null)
-      {
-        int msgID = MSGID_CONFIG_LOGGER_INVALID_ROTATION_POLICY;
-        String message = getMessage(msgID, dn.toString(),
-                                    config.dn().toString());
-        unacceptableReasons.add(message);
-        return false;
-      }
-    }
-    for(DN dn: config.getRetentionPolicyDN())
-    {
-      RetentionPolicy policy = DirectoryServer.getRetentionPolicy(dn);
-      if(policy != null)
-      {
-        int msgID = MSGID_CONFIG_LOGGER_INVALID_RETENTION_POLICY;
-        String message = getMessage(msgID, dn.toString(),
-                                    config.dn().toString());
-        unacceptableReasons.add(message);
-        return false;
-      }
-    }
-
-    return true;
+    return isConfigurationAcceptable(config, unacceptableReasons);
   }
 
   /**

--
Gitblit v1.10.0