From 7f020de74c831dc15d5e70a7f423f87f4d5e8a37 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 07 Jan 2008 12:54:54 +0000
Subject: [PATCH] Fix for issue 2780.

---
 opends/src/quicksetup/org/opends/quicksetup/upgrader/RevertFileFilter.java |   53 ++++++++++++++++++++++++++
 opends/src/quicksetup/org/opends/quicksetup/upgrader/Stage.java            |   11 +++--
 opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java         |    8 ++-
 opends/src/ads/org/opends/admin/ads/ADSContext.java                        |    6 ++-
 opends/src/quicksetup/org/opends/quicksetup/Installation.java              |    8 +++
 opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java         |    5 +-
 6 files changed, 79 insertions(+), 12 deletions(-)

diff --git a/opends/src/ads/org/opends/admin/ads/ADSContext.java b/opends/src/ads/org/opends/admin/ads/ADSContext.java
index 3154f86..bea0f71 100644
--- a/opends/src/ads/org/opends/admin/ads/ADSContext.java
+++ b/opends/src/ads/org/opends/admin/ads/ADSContext.java
@@ -22,11 +22,12 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2007-2008 Sun Microsystems, Inc.
  */
 
 package org.opends.admin.ads;
 
+import java.io.File;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.Set;
@@ -57,6 +58,7 @@
 import javax.naming.ldap.Control;
 import javax.naming.ldap.LdapContext;
 
+
 /**
  * Class used to update and read the contents of the Administration Data.
  */
@@ -2140,7 +2142,7 @@
    */
   public static String getAdminLDIFFile()
   {
-    return "config/admin-backend.ldif";
+    return "config"+File.separator+"admin-backend.ldif";
   }
 
 
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Installation.java b/opends/src/quicksetup/org/opends/quicksetup/Installation.java
index 5f90141..6940aaf 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Installation.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Installation.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
  */
 
 package org.opends.quicksetup;
@@ -261,6 +261,12 @@
   public static final String DEFAULT_JAVA_PROPERTIES_FILE = "java.properties";
 
   /**
+   * The default java properties file relative path.
+   */
+  public static final String RELATIVE_JAVA_PROPERTIES_FILE =
+    CONFIG_PATH_RELATIVE+File.separator+"java.properties";
+
+  /**
    * The set java home and arguments properties file for Windows.
    */
   public static final String SET_JAVA_PROPERTIES_FILE_WINDOWS =
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/RevertFileFilter.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/RevertFileFilter.java
new file mode 100644
index 0000000..6956e9b
--- /dev/null
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/RevertFileFilter.java
@@ -0,0 +1,53 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Portions Copyright 2008 Sun Microsystems, Inc.
+ */
+
+package org.opends.quicksetup.upgrader;
+
+import java.io.File;
+import java.util.HashSet;
+
+/**
+   * Filter defining files we want to manage in the upgrade
+ * process.
+ */
+class RevertFileFilter extends UpgradeFileFilter {
+
+  /**
+   * Creates a filter for ignoring in an OpenDS installation at
+   * <code>root</code>certain OpenDS files below root.
+   * @param root the root of the installation
+   */
+  public RevertFileFilter(File root) {
+    super(root);
+    this.filesToIgnore = new HashSet<File>();
+    for (String rootFileNamesToIgnore :
+            Upgrader.ROOT_FILES_TO_IGNORE_DURING_BACKUP) {
+      filesToIgnore.add(new File(root, rootFileNamesToIgnore));
+    }
+  }
+}
+
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
index 6d47afd..d99c15c 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
@@ -549,6 +549,7 @@
             notifyListeners(getLineBreak());
           }
         } catch (ApplicationException ae) {
+          runError = ae;
           notifyListeners(getFormattedErrorWithLineBreak());
         }
       }
@@ -598,6 +599,7 @@
             notifyListeners(getLineBreak());
           }
         } catch (ApplicationException ae) {
+          runError = ae;
           notifyListeners(getFormattedErrorWithLineBreak());
         }
       }
@@ -626,7 +628,7 @@
     {
       log = getFormattedWithPoints(log);
     }
-    notifyListeners(progress, log, log);
+    notifyListeners(progress, summary, log);
   }
 
   private void initialize() throws ApplicationException {
@@ -644,7 +646,7 @@
       File filesBackupDirectory = getTempBackupDirectory();
       FileManager fm = new FileManager();
       File root = getInstallation().getRootDirectory();
-      FileFilter filter = new UpgradeFileFilter(root);
+      FileFilter filter = new RevertFileFilter(root);
       for (String fileName : root.list()) {
         File f = new File(root, fileName);
 
@@ -676,7 +678,7 @@
       Stage stage = getStage();
       Installation installation = getInstallation();
       File root = installation.getRootDirectory();
-      stage.move(root);
+      stage.move(root, new RevertFileFilter(getReversionFilesDirectory()));
 
       // The bits should now be of the new version.  Have
       // the installation update the build information so
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Stage.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Stage.java
index 8a491c4..8167b98 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Stage.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Stage.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
  */
 
 package org.opends.quicksetup.upgrader;
@@ -35,6 +35,7 @@
 import org.opends.quicksetup.util.FileManager;
 
 import java.io.File;
+import java.io.FileFilter;
 import java.io.IOException;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -71,14 +72,16 @@
    * Moves the files in the staging area to a destination directory.
    *
    * @param destination for the staged files
+   * @param fileFilter the file filter to be used
    * @throws ApplicationException if something goes wrong
    */
-  public void move(File destination) throws ApplicationException {
-    UpgradeFileFilter ff = new UpgradeFileFilter(root);
+  public void move(File destination, FileFilter fileFilter)
+  throws ApplicationException {
     for (String fileName : root.list()) {
       File dest = new File(destination, fileName);
       File src = getSourceForCopy(fileName, dest);
-      fm.copyRecursively(src, destination, ff, /*overwrite=*/true);
+      //fm.copyRecursively(src, destination, fileFilter, /*overwrite=*/true);
+      fm.copyRecursively(src, destination, fileFilter, /*overwrite=*/true);
     }
   }
 
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
index 26ec629..9247880 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2008 Sun Microsystems, Inc.
  */
 
 package org.opends.quicksetup.upgrader;
@@ -139,6 +139,7 @@
   // Files that will be ignored during backup
   static final String[] FILES_TO_IGNORE_DURING_BACKUP = {
           TOOLS_PROPERTIES, // tools.properties
+          RELATIVE_JAVA_PROPERTIES_FILE, // java.properties
           ADSContext.getAdminLDIFFile() // admin-backend.ldif
   };
 
@@ -1357,7 +1358,7 @@
       Stage stage = getStage();
       Installation installation = getInstallation();
       File root = installation.getRootDirectory();
-      stage.move(root);
+      stage.move(root, new UpgradeFileFilter(getStageDirectory()));
 
       // The bits should now be of the new version.  Have
       // the installation update the build information so

--
Gitblit v1.10.0