From 348b156e4ab1f209b181d68698ec1068ed9a7277 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Tue, 18 Nov 2008 13:32:15 +0000
Subject: [PATCH] Fix for issue 3614 (control panel: restore fails when the available backup is a directory)

---
 opends/src/guitools/org/opends/guitools/controlpanel/ui/renderer/BackupTableCellRenderer.java |   46 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/renderer/BackupTableCellRenderer.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/renderer/BackupTableCellRenderer.java
index b4f3c3a..4015dfd 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/renderer/BackupTableCellRenderer.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/renderer/BackupTableCellRenderer.java
@@ -51,6 +51,7 @@
 {
   private static final long serialVersionUID = -4645902129785751854L;
   private DateFormat formatter = DateFormat.getDateInstance(DateFormat.FULL);
+  private File backupParentPath;
   private final static Border fullBorder = BorderFactory.createCompoundBorder(
       BorderFactory.createMatteBorder(1, 0, 0, 0,
           ColorAndFontConstants.gridColor),
@@ -68,6 +69,16 @@
     setBackground(ColorAndFontConstants.tableBackground);
   }
 
+
+  /**
+   * Sets the path to which the backups are relative.
+   * @param backupParentPath the path to which the backups are relative.
+   */
+  public void setParentPath(File backupParentPath)
+  {
+    this.backupParentPath = backupParentPath;
+  }
+
   /**
    * {@inheritDoc}
    */
@@ -80,10 +91,39 @@
     == BackupDescriptor.Type.FULL;
     if (value instanceof File)
     {
-      s = "..."+File.separator+((File)value).getName();
-      if (!isFull)
+      File f = (File)value;
+      s = "";
+      boolean isParent = false;
+      while (f != null)
       {
-        s = "  "+s;
+        if (!f.equals(backupParentPath))
+        {
+          if (s.length() == 0)
+          {
+            s = f.getName();
+          }
+          else
+          {
+            s = f.getName() + File.separator + s;
+          }
+        }
+        else
+        {
+          isParent = true;
+          break;
+        }
+        f = f.getParentFile();
+      }
+      if (isParent)
+      {
+        if (!isFull)
+        {
+          s = "  "+s;
+        }
+      }
+      else
+      {
+        s = value.toString();
       }
     }
     else if (value instanceof Date)

--
Gitblit v1.10.0