From 2406449c5f0309525bfd5d86de417b32bcc7c1b3 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 03 Sep 2007 14:35:07 +0000
Subject: [PATCH] Fix a bug with certificates in the uninstaller and replication command lines. Improve the error messages to be displayed to the user when the uninstall fails.Fix a infinite loop that occurred when the user provided a protocol not configured in the server to access the registration information. Fix a bug that prevented the uninstall to proceed when the user specified forceOnError and an error accessing the remote servers configuration occurred. Fix a bug that occurred when the user specified to use start TLS and it was not configured in the server (this bug applies to both the uninstaller and status command-lines).

---
 opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java |   50 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java b/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
index b27b742..3c9163a 100644
--- a/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
+++ b/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
@@ -108,8 +108,6 @@
   private ProgressDialog startProgressDlg;
   private MessageBuilder startProgressDetails = new MessageBuilder();
   private UninstallData conf;
-  private String replicationServerHostPort;
-
   /**
    * Default constructor.
    */
@@ -828,12 +826,14 @@
       }
 
     } catch (ApplicationException ex) {
+      LOG.log(Level.SEVERE, "Error: "+ex, ex);
       ue = ex;
       status = UninstallProgressStep.FINISHED_WITH_ERROR;
       Message msg = getFormattedError(ex, true);
       notifyListeners(msg);
     }
     catch (Throwable t) {
+      LOG.log(Level.SEVERE, "Error: "+t, t);
       ue = new ApplicationException(
               ReturnCode.BUG,
               getThrowableMsg(INFO_BUG_MSG.get(), t), t);
@@ -1348,7 +1348,6 @@
     {
       getUninstallUserData().setAdminUID(loginDialog.getAdministratorUid());
       getUninstallUserData().setAdminPwd(loginDialog.getAdministratorPwd());
-      getUninstallUserData().setReferencedHostName(loginDialog.getHostName());
       final InitialLdapContext ctx = loginDialog.getContext();
       try
       {
@@ -1360,8 +1359,9 @@
         LOG.log(Level.WARNING, "Could not find local server: "+ne, ne);
         getUninstallUserData().setLocalServerUrl("ldap://localhost:389");
       }
-      replicationServerHostPort = loginDialog.getHostName() + ":" +
-      conf.getReplicationServerPort();
+      getUninstallUserData().setReplicationServer(
+          loginDialog.getHostName() + ":" +
+          conf.getReplicationServerPort());
 
       BackgroundTask worker = new BackgroundTask()
       {
@@ -1449,6 +1449,7 @@
     /* Check the exceptions and see if we throw them or not. */
     for (TopologyCacheException e : exceptions)
     {
+      LOG.log(Level.INFO, "Analyzing exception: "+e, e);
       if (stopProcessing)
       {
         break;
@@ -1641,6 +1642,7 @@
       LOG.log(Level.WARNING, "The server ADS properties for the server to "+
           "uninstall could not be found.");
     }
+
     for (ServerDescriptor server : servers)
     {
       if (server.getAdsProperties() != serverADSProperties)
@@ -1652,8 +1654,7 @@
 
   /**
    * This method updates the replication in the remote server represented by
-   * a given ServerProperty object.  It does not thrown any exception and works
-   * in a best effort mode.
+   * a given ServerProperty object.
    * It also tries to delete the server registration entry from the remote ADS
    * servers if the serverADSProperties object passed is not null.
    * @param server the ServerDescriptor object representing the server where
@@ -1681,7 +1682,8 @@
       {
         for (Object o : replicationServers)
         {
-          if (replicationServerHostPort.equalsIgnoreCase((String)o))
+          if (getUninstallUserData().getReplicationServer().equalsIgnoreCase(
+              (String)o))
           {
             hasReferences = true;
             break;
@@ -1698,7 +1700,8 @@
         {
           for (Object o : replica.getReplicationServers())
           {
-            if (replicationServerHostPort.equalsIgnoreCase((String)o))
+            if (getUninstallUserData().getReplicationServer().equalsIgnoreCase(
+                (String)o))
             {
               hasReferences = true;
               break;
@@ -1799,7 +1802,8 @@
           String replServer = null;
           for (String o : replServers)
           {
-            if (replicationServerHostPort.equalsIgnoreCase(o))
+            if (getUninstallUserData().getReplicationServer().equalsIgnoreCase(
+                o))
             {
               replServer = o;
               break;
@@ -1836,7 +1840,8 @@
             String replServer = null;
             for (String o : replServers)
             {
-              if (replicationServerHostPort.equalsIgnoreCase(o))
+              if (getUninstallUserData().getReplicationServer().
+                  equalsIgnoreCase(o))
               {
                 replServer = o;
                 break;
@@ -1938,7 +1943,28 @@
           property = ServerDescriptor.ServerProperty.LDAP_PORT;
         }
         ArrayList ports = (ArrayList)server.getServerProperties().get(property);
-        isServerToUninstall = ports.contains(port);
+        if (ports == null)
+        {
+          isServerToUninstall = ports.contains(port);
+        }
+        else
+        {
+          // This occurs if the instance could not be loaded.
+          ADSContext.ServerProperty adsProperty;
+          if (isSecure)
+          {
+            adsProperty = ADSContext.ServerProperty.LDAPS_PORT;
+          }
+          else
+          {
+            adsProperty = ADSContext.ServerProperty.LDAPS_PORT;
+          }
+          String v = (String)server.getAdsProperties().get(adsProperty);
+          if (v != null)
+          {
+            isServerToUninstall = v.equals(String.valueOf(port));
+          }
+        }
       }
       catch (Throwable t)
       {

--
Gitblit v1.10.0