From d42b15e420478dc45785fff6e00b863cc1f8a0f9 Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Thu, 18 Sep 2008 10:14:53 +0000
Subject: [PATCH] These changes are separating the current delivery into  an "Install Layout" (the binaries) and an "Instance Layout" (the user data).

---
 opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java |   69 +++++++++++++++++++++++++++++++---
 1 files changed, 63 insertions(+), 6 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
index fb7332f..770882a 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
@@ -163,8 +163,9 @@
                 Message buildInfo = INFO_UPGRADE_BUILD_ID_UNKNOWN.get();
                 Message date = INFO_GENERAL_UNKNOWN.get();
                 try {
+                  File f = appendFilesDirIfNeccessary(raDir);
                   Installation i =
-                          new Installation(appendFilesDirIfNeccessary(raDir));
+                          new Installation(f,f);
                   BuildInformation bi = i.getBuildInformation();
                   buildInfo = Message.raw(bi.toString());
                 } catch (Exception e) {
@@ -369,7 +370,7 @@
    */
   public String getInstallationPath() {
     String installationPath = null;
-    String path = Utils.getInstallPathFromClasspath();
+    String path =  System.getProperty("INSTALL_ROOT");
     if (path != null) {
       File f = new File(path);
       if (f.getParentFile() != null &&
@@ -387,6 +388,14 @@
   /**
    * {@inheritDoc}
    */
+  public String getInstancePath() {
+    String installPath = getInstallationPath() ;
+    return Utils.getInstancePathFromClasspath(installPath);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   public ProgressStep getCurrentProgressStep() {
     return this.currentProgressStep;
   }
@@ -481,8 +490,16 @@
   public Installation getInstallation() {
     if (installation == null) {
       String installPath = getInstallationPath();
+      String instancePath = getInstancePath();
       if (installPath != null) {
-        installation = new Installation(installPath);
+        if (instancePath != null)
+        {
+          installation = new Installation(installPath, instancePath);
+        }
+        else
+        {
+          installation = new Installation(installPath, installPath);
+        }
       }
     }
     return installation;
@@ -690,8 +707,23 @@
     try {
       Stage stage = getStage();
       Installation installation = getInstallation();
-      File root = installation.getRootDirectory();
-      stage.move(root, new RevertFileFilter(getReversionFilesDirectory()));
+      if (installation.instanceAndInstallInSameDir())
+      {
+        File root = installation.getRootDirectory();
+        stage.move(root, new RevertFileFilter(getReversionFilesDirectory()));
+      }
+      else
+      {
+        File root = installation.getRootDirectory();
+        File revFileRoot = new File(getReversionFilesDirectory(),
+            Installation.HISTORY_BACKUP_FILES_DIR_INSTALL);
+        stage.move(root, new RevertFileFilter(revFileRoot,true),true);
+
+        root = installation.getInstanceDirectory();
+        revFileRoot = new File(getReversionFilesDirectory(),
+            Installation.HISTORY_BACKUP_FILES_DIR_INSTANCE);
+        stage.move(root, new RevertFileFilter(revFileRoot,false),false);
+      }
 
       // The bits should now be of the new version.  Have
       // the installation update the build information so
@@ -734,8 +766,18 @@
       Set<String> cs = new HashSet<String>(Arrays.asList(children));
 
       // TODO:  more testing of file dir
+      String installPath = System.getProperty("INSTALL_ROOT");
+      String instancePath = System.getProperty("INSTANCE_ROOT");
+      if (installPath.equals(instancePath))
+      {
       isFilesDir = cs.contains(CONFIG_PATH_RELATIVE) &&
               cs.contains(LIBRARIES_PATH_RELATIVE);
+      }
+      else
+      {
+        isFilesDir = cs.contains(Installation.HISTORY_BACKUP_FILES_DIR_INSTALL)
+        && cs.contains( Installation.HISTORY_BACKUP_FILES_DIR_INSTANCE);
+      }
     }
     return isFilesDir;
   }
@@ -1089,7 +1131,22 @@
   {
     if (archiveInstallation == null) {
       File revFiles = getReversionFilesDirectory();
-      archiveInstallation = new Installation(revFiles);
+      String[] children = revFiles.list();
+      Set<String> cs = new HashSet<String>(Arrays.asList(children));
+      if ((cs.contains(Installation.HISTORY_BACKUP_FILES_DIR_INSTALL)) &&
+          (cs.contains(Installation.HISTORY_BACKUP_FILES_DIR_INSTANCE)))
+      {
+        File installRevFiles =
+          new File (revFiles,Installation.HISTORY_BACKUP_FILES_DIR_INSTALL);
+        File instanceRevFiles =
+          new File (revFiles,Installation.HISTORY_BACKUP_FILES_DIR_INSTANCE);
+        archiveInstallation =
+          new Installation(installRevFiles,instanceRevFiles);
+      }
+      else
+      {
+        archiveInstallation = new Installation(revFiles,revFiles);
+      }
     }
     return archiveInstallation;
   }

--
Gitblit v1.10.0