From 8b0277f9fd2b5a2997dc456363da85f02b60df0d Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Fri, 15 May 2015 12:50:26 +0000
Subject: [PATCH] OPENDJ-1758 UI Restore/Backup shows exceptions

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BackupListPanel.java |   52 +++++++++++++++++++++-------------------------------
 1 files changed, 21 insertions(+), 31 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BackupListPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BackupListPanel.java
index a7e8e3b..0c39aed 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BackupListPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BackupListPanel.java
@@ -28,8 +28,8 @@
 package org.opends.guitools.controlpanel.ui;
 
 import static org.opends.messages.AdminToolMessages.*;
-import static org.opends.messages.CoreMessages.*;
 import static org.opends.messages.ToolMessages.*;
+import static org.opends.server.util.ServerConstants.*;
 
 import static com.forgerock.opendj.util.OperatingSystem.*;
 
@@ -73,7 +73,6 @@
 import org.opends.quicksetup.Installation;
 import org.opends.server.types.BackupDirectory;
 import org.opends.server.types.BackupInfo;
-import org.opends.server.types.OpenDsException;
 import org.opends.server.util.StaticUtils;
 
 /** Abstract class used to refactor code in panels that contain a backup list on it. */
@@ -326,15 +325,20 @@
         // Open the backup directory and make sure it is valid.
         Set<BackupInfo> backups = new LinkedHashSet<>();
         Throwable firstThrowable = null;
-        try
+
+        if (new File(parentPath, BACKUP_DIRECTORY_DESCRIPTOR_FILE).exists())
         {
-          BackupDirectory backupDir = BackupDirectory.readBackupDirectoryDescriptor(parentPath);
-          backups.addAll(backupDir.getBackups().values());
+          try
+          {
+            BackupDirectory backupDir = BackupDirectory.readBackupDirectoryDescriptor(parentPath);
+            backups.addAll(backupDir.getBackups().values());
+          }
+          catch (Throwable t)
+          {
+            firstThrowable = t;
+          }
         }
-        catch (Throwable t)
-        {
-          firstThrowable = t;
-        }
+
         // Check the subdirectories
         File f = new File(parentPath);
 
@@ -420,28 +424,14 @@
 
       private void performErrorActions(Throwable t, BackupTableModel model)
       {
-        boolean displayError = true;
-        if (t instanceof OpenDsException)
-        {
-          OpenDsException e = (OpenDsException) t;
-          if (StaticUtils.hasDescriptor(e.getMessageObject(), ERR_BACKUPDIRECTORY_NO_DESCRIPTOR_FILE))
-          {
-            displayError = false;
-          }
-        }
-
-        if (displayError)
-        {
-          LocalizableMessage details = ERR_RESTOREDB_CANNOT_READ_BACKUP_DIRECTORY.get(
-              parentDirectory.getText(), StaticUtils.getExceptionMessage(t));
-
-          updateErrorPane(errorPane,
-                          ERR_ERROR_SEARCHING_BACKUPS_SUMMARY.get(),
-                          ColorAndFontConstants.errorTitleFont,
-                          details,
-                          errorPane.getFont());
-          packParentDialog();
-        }
+        LocalizableMessage details = ERR_RESTOREDB_CANNOT_READ_BACKUP_DIRECTORY.get(
+            parentDirectory.getText(), StaticUtils.getExceptionMessage(t));
+        updateErrorPane(errorPane,
+                        ERR_ERROR_SEARCHING_BACKUPS_SUMMARY.get(),
+                        ColorAndFontConstants.errorTitleFont,
+                        details,
+                        errorPane.getFont());
+        packParentDialog();
         updateUI(false, model);
      }
 

--
Gitblit v1.10.0