From 4978cbcfce206fb43659395556b59c33127505bd Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 07 Apr 2008 11:56:09 +0000
Subject: [PATCH] Fix for issue 3121 (Bad management of upgrade -r on a already reverted installation)

---
 opends/src/quicksetup/org/opends/quicksetup/util/Utils.java |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 581b16a..06aeadd 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -307,6 +307,33 @@
   }
 
   /**
+   * Returns <CODE>true</CODE> if the the provided path is a directory, exists
+   * and is empty <CODE>false</CODE> otherwise.
+   * @param path the path that we are analyzing.
+   * @return <CODE>true</CODE> if the the provided path is a directory, exists
+   * and is empty <CODE>false</CODE> otherwise.
+   */
+  public static boolean directoryExistsAndIsEmpty(String path)
+  {
+    boolean directoryExistsAndIsEmpty = false;
+    boolean isDirectory = false;
+
+    File f = new File(path);
+    if (f != null)
+    {
+      isDirectory = f.isDirectory();
+    }
+    if (isDirectory)
+    {
+      String[] ch = f.list();
+
+      directoryExistsAndIsEmpty = (ch == null) || (ch.length == 0);
+    }
+
+    return directoryExistsAndIsEmpty;
+  }
+
+  /**
    * Returns <CODE>true</CODE> if the the provided string is a DN and
    * <CODE>false</CODE> otherwise.
    * @param dn the String we are analyzing.

--
Gitblit v1.10.0