From 18de8b9ed9f6ba9780d3292d2828f67de08b7483 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 24 Jul 2009 09:46:24 +0000
Subject: [PATCH] Refactor the code of dsreplication and extract some of its commodity methods and move them to the classes they apply to.

---
 opends/src/ads/org/opends/admin/ads/TopologyCache.java |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/opends/src/ads/org/opends/admin/ads/TopologyCache.java b/opends/src/ads/org/opends/admin/ads/TopologyCache.java
index 1f2045d..7c5949b 100644
--- a/opends/src/ads/org/opends/admin/ads/TopologyCache.java
+++ b/opends/src/ads/org/opends/admin/ads/TopologyCache.java
@@ -27,6 +27,11 @@
 
 package org.opends.admin.ads;
 
+import static org.opends.messages.QuickSetupMessages.
+ INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER;
+import static org.opends.messages.QuickSetupMessages.
+ INFO_NOT_GLOBAL_ADMINISTRATOR_PROVIDED;
+
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
@@ -51,6 +56,7 @@
 import org.opends.admin.ads.util.ConnectionUtils;
 import org.opends.admin.ads.util.PreferredConnection;
 import org.opends.admin.ads.util.ServerLoader;
+import org.opends.messages.Message;
 import org.opends.quicksetup.util.Utils;
 
 /**
@@ -370,6 +376,56 @@
     return adsContext;
   }
 
+
+
+  /**
+   * Returns a set of error messages encountered in the TopologyCache.
+   * @return a set of error messages encountered in the TopologyCache.
+   */
+  public LinkedHashSet<Message> getErrorMessages()
+  {
+    Set<TopologyCacheException> exceptions =
+      new HashSet<TopologyCacheException>();
+    Set<ServerDescriptor> servers = getServers();
+    LinkedHashSet<Message> exceptionMsgs = new LinkedHashSet<Message>();
+    for (ServerDescriptor server : servers)
+    {
+      TopologyCacheException e = server.getLastException();
+      if (e != null)
+      {
+        exceptions.add(e);
+      }
+    }
+    /* Check the exceptions and see if we throw them or not. */
+    for (TopologyCacheException e : exceptions)
+    {
+      switch (e.getType())
+      {
+        case NOT_GLOBAL_ADMINISTRATOR:
+          exceptionMsgs.add(INFO_NOT_GLOBAL_ADMINISTRATOR_PROVIDED.get());
+
+        break;
+      case GENERIC_CREATING_CONNECTION:
+        if ((e.getCause() != null) &&
+            Utils.isCertificateException(e.getCause()))
+        {
+          exceptionMsgs.add(
+              INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER.get(
+              e.getHostPort(), e.getCause().getMessage()));
+        }
+        else
+        {
+          exceptionMsgs.add(Utils.getMessage(e));
+        }
+        break;
+      default:
+        exceptionMsgs.add(Utils.getMessage(e));
+      }
+    }
+    return exceptionMsgs;
+  }
+
+
   /**
    * Updates the monitoring information of the provided replicas using the
    * information located in cn=monitor of a given replication server.

--
Gitblit v1.10.0